Skip to content

Instantly share code, notes, and snippets.

import csv
from collections import defaultdict
with open('/Users/adam/Downloads/languages-2014.csv', 'r') as f:
results_2014 = [row for row in csv.reader(f)][1:]
with open('/Users/adam/Downloads/languages-2013.csv', 'r') as f:
results_2013 = [row for row in csv.reader(f)][1:]
with open('/Users/adam/Downloads/languages-2012.csv', 'r') as f:
TSTapstream *tracker = [TSTapstream instance];
// Call getConversionData to get the user's timeline history
[tracker getConversionData:^(NSData *jsonInfo) {
if(jsonInfo == nil)
{
// No conversion data available
}
else
{
// Chart.redraw
redraw: function (animation) {
var chart = this,
//...
series = chart.series,
//...
;
// ...<snip>...
@adambard
adambard / gist:9844556
Created March 28, 2014 22:46
keybase.md
### Keybase proof
I hereby claim:
* I am adambard on github.
* I am adambard (https://keybase.io/adambard) on keybase.
* I have a public key whose fingerprint is D7B0 3610 4BA0 86AA 366A 2733 2E89 85DE 39A5 2FFC
To claim this, I am signing this object:
import hashlib
import requests
from bs4 import BeautifulSoup
URL = ("http://www.forbes.com/pictures/emjl45gkke/on-startups/")
# $('.next.prev_next a').attr('href')
@adambard
adambard / multipart_test.clj
Created November 8, 2013 09:53
Posting multipart/form-data messages with Content-Id headers (for cid: tags) in Clojure, using Jersey 1.17.1.
(ns multipart-test
(:import
javax.ws.rs.core.MediaType
com.sun.jersey.api.client.Client
com.sun.jersey.api.client.ClientResponse
com.sun.jersey.api.client.config.DefaultClientConfig
com.sun.jersey.api.client.filter.HTTPBasicAuthFilter
com.sun.jersey.multipart.FormDataMultiPart
com.sun.jersey.multipart.file.FileDataBodyPart
com.sun.jersey.multipart.impl.MultiPartWriter)
import csv
import numpy
with open("c46145.csv", "rb") as f:
r = csv.reader(f)
headers = r.next()
print headers
vwh_idx = headers.index('VWH$')
@adambard
adambard / config.rb
Created July 11, 2013 00:07
Here's the bit from my config.rb
# Count contributors
ready do
# Prepare the pages
pages = sitemap.resources.select{ |r|
r.path.match(/^docs\/.*\.html/) and not r.path.include?("README") and not r.path.match /file\.html$/
}.sort_by{ |r|
r.metadata[:page]["language"].downcase
}
; Comments start with semicolons.
; Clojure is written in "forms", which are just
; lists of things inside parentheses, separated by whitespace.
;
; The clojure reader assumes that the first thing is a
; function or macro to call, and the rest are arguments.
;
; Here's a function that sets the current namespace:
(ns test)
@adambard
adambard / errors.clj
Created May 13, 2013 05:48
An example of functional error handling in clojure.
(ns example.errors)
(defn clean-address [params]
"Ensure (params :address) is present"
(if (empty? (params :address))
[nil "Please enter your address"]
[params nil]))
(defn clean-email [params]
"Ensure (params :email) matches *@*.*"