Skip to content

Instantly share code, notes, and snippets.

View samuelclay's full-sized avatar

Samuel Clay samuelclay

View GitHub Profile
@samuelclay
samuelclay / keybase.md
Created September 17, 2014 22:02
keybase.md

Keybase proof

I hereby claim:

  • I am samuelclay on github.
  • I am samuelclay (https://keybase.io/samuelclay) on keybase.
  • I have a public key whose fingerprint is 067A A5F2 BCFA A27D 952B 61E7 B83A 60E5 4AFB F343

To claim this, I am signing this object:

var pageCount = 3;
var thumbnails = {
1: "http://s3.documentcloud.org/documents/8941/pages/fbi-agent-william-h-lawrence-testifies-before-congress-p1-thumbnail.gif",
2: "http://s3.documentcloud.org/documents/8941/pages/fbi-agent-william-h-lawrence-testifies-before-congress-p2-thumbnail.gif",
3: "http://s3.documentcloud.org/documents/8941/pages/fbi-agent-william-h-lawrence-testifies-before-congress-p3-thumbnail.gif"
};
var thumbnailsHTML = JST.thumbnails({
pageCount : pageCount,
thumbnails : thumbnails
var someSet = Backbone.Collection.extend({
model : someModel,
constructor : function() {
this.bind('change', _.bind(function() {
onModelChange();
}, this);
}
});
someModelInstance.set('key', 'value'); // Triggers a `change` that `someSet` will see.
@samuelclay
samuelclay / gist:1163547
Created August 22, 2011 21:00 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
  • Day job: Engineer at Tasty Labs, on a Python/Tornado stack

  • Favorite Python project: NewsBlur, my visual RSS feed reader written entirely in Python on the backend. Uses a 100% python distributed feed fetcher that makes use of celery, mongoengine, pymongo, and Django. Entirely on GitHub: http://github.com/samuelclay/NewsBlur

  • Favorite Conference: Djangocon, where everybody knows they might the right decision to go Python.

  • Python Experience Level: Somewhere between expert and way out of my element.

@samuelclay
samuelclay / Monday Morning.txt
Created September 27, 2011 01:22
"Why live in the world when you can live in your head?"
There's nothing to do so you just stay in bed / (oh / poor thing) / Why live in the world when you can live in your head? / Oh / And you can go out late from Monday / till Saturday turns into Sunday / and now you're back here at Monday / so you can do it all over again / And we go ah/ah/ah... / I want a refund / I want a light / I want a reason / to make it through the night / All right / And so you finally left school / so now what are you going to do? / Now you're so grown up / yeah / O h / ah / ah / Oh / so mature / Going out late from Monday / chuck up in the street on Sunday / you don't want to live till Monday / and have to do it all over again / And you go ah/ah/ah... / I want a refund / I want a light / I want a reason / for all this night after night after night after night / Oh / I know that it's stupid but I just can't seem to spend a night at home / 'cause my friends left town / and I'm here all alone / Oh oh / Yeah / They say the past must die / for the futur e to be born / In that case / die / l
@samuelclay
samuelclay / gist:1338319
Created November 4, 2011 00:10
The Verge RSS feed
>>> import feedfinder
>>> feedfinder.feed('http://theverge.com')
'http://theverge.com/rss/index.xml'
>>> import feedparser
>>> fp = feedparser.parse('http://theverge.com/rss/index.xml')
>>> fp
{'feed': {}, 'status': 200, 'bozo': 1, 'headers': {'status': '200 OK', 'content-length': '19383', 'via': '1.1 sbnation.com', 'content-encoding': 'deflate', 'vary': 'Accept-Encoding', 'x-runtime': '578', 'connection': 'Keep-Alive', 'etag': '"fd2f3a5b33a1a706fea1dec62ad25df3"', 'cache-control': 'private, max-age=0, must-revalidate, private, max-age=0, must-revalidate', 'date': 'Fri, 04 Nov 2011 00:06:59 GMT', 'p3p': 'CP="CAO DSP COR CURa ADMa DEVa PSAa PSDa CONi OUR IND PHY ONL UNI COM NAV INT CNT STA"', 'content-type': 'application/xml; charset=utf-8'}, 'etag': u'"fd2f3a5b33a1a706fea1dec62ad25df3"', 'href': u'http://www.theverge.com/rss/index.xml', 'entries': [], 'bozo_exception': error('Error -3 while decompressing data: incorrect header check',)}
>>> fp.entries
[]
@samuelclay
samuelclay / entries.md
Created March 21, 2012 19:10
Top entries in Knight News Challenge 2012
class ImageOps:
"""Module that holds all image operations. Since there's no state,
everything is a classmethod."""
@classmethod
def adjust_image_orientation(cls, image):
"""Since the iPhone will store an image on its side but with EXIF
data stating that it should be rotated, we need to find that
EXIF data and correctly rotate the image before storage."""
@samuelclay
samuelclay / image_dominant_color.py
Created April 14, 2011 01:21
Algorithm to find the dominant color in an image.
from PIL import Image
import scipy
import scipy.cluster
from pprint import pprint
image = Image.open('logo_newsblur_512.png')
NUM_CLUSTERS = 15
# Convert image into array of values for each point.
ar = scipy.misc.fromimage(image)
@samuelclay
samuelclay / radix_trie.js
Created January 30, 2013 16:55
A Radix Trie (aka PATRICIA trie) implemented in JavaScript. Play with it at this interactive JS fiddle: http://jsfiddle.net/jCYAw/
var RadixTrie = function(words) {
this.T = {};
this.initialize(words);
};
RadixTrie.prototype = {
initialize: function(words) {
var self = this;
words = words || [];