Skip to content

Instantly share code, notes, and snippets.

View cameronneylon's full-sized avatar

Cameron Neylon cameronneylon

View GitHub Profile
WITH aggregate_data AS (
SELECT
crossref.published_year as year,
-- crossref.type as type,
COUNT(*) AS n_outputs,
SUM(CASE WHEN coki.oa.coki.open = TRUE THEN 1 ELSE 0 END) AS n_outputs_open,
SUM(CASE WHEN coki.oa.coki.closed = TRUE THEN 1 ELSE 0 END) AS n_outputs_closed,
SUM(CASE WHEN coki.oa.coki.publisher_only = TRUE THEN 1 ELSE 0 END) as n_publisher_open,
SUM(CASE WHEN coki.oa.coki.other_platform_only = TRUE THEN 1 ELSE 0 END) as n_other_platform_open,
SUM(CASE WHEN coki.oa.coki.both = TRUE THEN 1 ELSE 0 END) as n_both_open,
WITH
-- UNNEST the funder DOIs in the Crossref DOI table
CR_FUNDER_DOI_TABLE AS (
SELECT
a.doi,
crossref.published_year,
-- Deal with the Crossref Month 13 issue
CASE WHEN crossref.published_month > 12 then 12 ELSE crossref.published_month END as published_month,
unpaywall.* EXCEPT(doi),
crossref.type,
@cameronneylon
cameronneylon / ced-pull.py
Created August 7, 2019 02:55
COKI code for pulling for CED
import requests
import datetime
from google.cloud import firestore
from google.cloud import storage
import time
import logging
db = firestore.Client()
@cameronneylon
cameronneylon / README.md
Last active February 9, 2016 14:50 — forked from Neilos/README.md
Bi-directional hierarchical sankey diagram

This is a fork of Neil Atkinson's demonstration of a bi-directional sankey diagram produced in javascript, html and css using d3.

I'm aiming to demonstrate some flows between different classes of members in "Knowledge Clubs"

Sankey diagrams represent flows between nodes by varying the thickness of the connecting links.

This diagram was based off of Mike Bostock's sankey diagram, but additionally incorporates bi-directionality into the flow and caters for hierarchical relationships between nodes to allow drill down into the data.

All javascript code to generate the diagram markup is contained in the app.js file, but the underlying calculations are performed using a custom plugin: bihisankey.js.

@cameronneylon
cameronneylon / percolation.py
Created July 18, 2013 21:39
Code for percolation network simulation used in my talk at #BOSC July 19 2013 in Berlin. Based on code from http://dragly.org/2013/03/25/working-with-percolation-clusters-in-python/. The license for the source code is not entirely clear so this code is made available under a CC BY-SA license as per the blog it was derived from. For reasons not e…
from pylab import *
from scipy.ndimage import measurements
import numpy as np
import matplotlib.pyplot as plt
import time
import sys
import signal
def signal_handler(signal, frame):
sys.exit(0)
@cameronneylon
cameronneylon / iPython_Vagrant_Shell_provison.sh
Last active December 17, 2015 06:39
Shell script for provisioning a Vagrant VM instance running iPython notebook.
# Provisioning script for a Vagrant VM running iPythonNotebook
# Obtain curl and install setuptools and pip
apt-get update
apt-get -y install python-setuptools
easy_install pip
# Get ipython and dependencies
echo
echo Installing iPython and dependencies...