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 / 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...