This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#!/usr/bin/env python | |
### Example code to access the Mendeley OAuth2 API | |
### Author: Juan Pablo Alperin | |
import requests | |
import requests.auth | |
import urllib | |
CLIENT_ID = '' | |
CLIENT_SECRET = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cribbed from http://vimeo.com/52569901 (Twilio carrier call origination moderation) | |
# The idea is that many fan-in queues can enqueue at any rate, but | |
# dequeue needs to happen in a rate-controlled manner without allowing | |
# any individual input queue to starve other queues. | |
# http://en.wikipedia.org/wiki/Leaky_bucket (second sense, "This version is referred to here as the leaky bucket as a queue.") | |
# | |
# requires: | |
# redis 2.6+ | |
# redis-py>=2.7.0 | |
# anyjson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplejson | |
import sqlalchemy | |
from sqlalchemy import String | |
from sqlalchemy.ext.mutable import Mutable | |
class JSONEncodedObj(sqlalchemy.types.TypeDecorator): | |
"""Represents an immutable structure as a json-encoded string.""" | |
impl = String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
def convert(dictionary): | |
return namedtuple('GenericDict', dictionary.keys())(**dictionary) | |
""" | |
>>> d = dictionary(a=1, b='b', c=[3]) | |
>>> named = convert(d) | |
>>> named.a == d.a | |
True | |
>>> named.b == d.b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Heather Piwowar | |
### MIT open license. | |
### blog post about interm results: | |
library(rms) | |
# if true, draw figures on screen instead of in a file | |
SCREEN=TRUE | |
# set to ".eps" or ".png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Heather Piwowar | |
# Modifications to add confidence intervals added by Heather Piwowar | |
# Based on dotchart2{Hmisc} | |
dotchart2.CIs = | |
function (data, labels, groups = NULL, gdata = NA, horizontal = TRUE, | |
pch = 16, xlab = "", ylab = "", auxdata, auxgdata = NULL, | |
auxtitle, lty = if (.R.) 1 else 2, lines = TRUE, dotsize = 0.8, | |
cex = par("cex"), cex.labels = cex, cex.group.labels = cex.labels * | |
1.25, sort. = TRUE, add = FALSE, dotfont = par("font"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified from http://bit.ly/dEyw03 | |
import unittest | |
class TestMyGoods(unittest.TestCase): | |
pass | |
def create_dynamic_method(pair): | |
"""just don't include `test` in the function name here, nose will try to | |
run it""" |