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
{ method: 'POST', | |
headers: | |
{ 'content-type': 'application/json', | |
accept: 'application/json' }, | |
uri: 'http://localhost:5984/eggchair', | |
body: '{"_id":"vQAcIFx.jpg","timestamp":1371708302000,"_attachments":{"content":"/9j/4gv4SUNDX1BST0ZJTEUAAQEAAAvoAAAAAAIAAABtbnRyUkdCIFhZWiAH2QADABsAFQAkAB9hY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAA9tYAAQAAAADTLQAAAAAp+D3er/JVrnhC+uTKgzkNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBkZXNjAAABRAAAAHliWFlaAAABwAAAABRiVFJDAAAB1AAACAxkbWRkAAAJ4AAAAIhnWFlaAAAKaAAAABRnVFJDAAAB1AAACAxsdW1pAAAKfAAAABRtZWFzAAAKkAAAACRia3B0AAAKtAAAABRyWFlaAAAKyAAAABRyVFJDAAAB1AAACAx0ZWNoAAAK3AAAAAx2dWVkAAAK6AAAAId3dHB0AAALcAAAABRjcHJ0AAALhAAAADdjaGFkAAALvAAAACxkZXNjAAAAAAAAAB9zUkdCIElFQzYxOTY2LTItMSBibGFjayBzY2FsZWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFlaIAAAAAAAACSgAAAPhAAAts9jdXJ2AAAAAAAABAAAAAAFAAoADwAUABkAHgAjACgALQAyADcAOwBAAEUASgBPAFQAWQBeAGMAaABtAHIAdwB8AIEAhgCLAJAAlQCaAJ8ApACpAK4AsgC3ALwAwQDGAMsA0ADVANsA4ADlAO |
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
var config = require("./config") | |
, request = require("request") | |
, i = 0; | |
function ping(){ | |
request.post({ | |
url: config.push_url, | |
json: { | |
api_key: config.api_key, | |
data:{ |
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
(1..5).each do |i| | |
config.vm.define "box#{i}" do |box| | |
box.vm.network :forwarded_port, guest: 5984, host: 8000+i, | |
auto_correct: true | |
end | |
end |
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
map = (doc) -> | |
size = 4 # = the n in ngram | |
# chunk function | |
chunk = (arr, len) -> | |
chunks = [] | |
i = 0 | |
while i < arr.length | |
chunks.push arr.slice(i, i += len) | |
return (x for x in chunks when x.length is len) | |
# reduce to tokens |
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
#!/usr/bin/python | |
import flask | |
import markdown | |
import sys | |
app = flask.Flask(__name__) | |
md = sys.stdin.read() | |
@app.route('/') |
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
echo "00 * * * * `which fortune` | say" | crontab |
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 csv | |
from collections import Counter | |
class Reading(object): | |
def __init__(self, **kwargs): | |
for k,v in kwargs.iteritems(): | |
setattr(self, k, v) | |
file_list = [] # list of files | |
readings = [] |
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 requests | |
import json | |
api_key = 'your_api_key' | |
url = "https://api.fullcontact.com/v2/person.json" | |
def whois(**kwargs): | |
if 'apiKey' not in kwargs: | |
kwargs['apiKey'] = api_key | |
r = requests.get(url, params=kwargs) |
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
var DummyView = Backbone.View.extend({ | |
initialize: function(options) { | |
this.template = _.template(options.template.html()); | |
this.render(); | |
}, | |
render: function() { | |
this.$el.html(this.template({})); | |
} | |
}); |
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
""" | |
I hate CSVs, so this converts them into an array of dicts, with each key-value pair matching that column's header, and the row's value for that column. | |
""" | |
def jsonize_csv(fp): | |
with open(fp, 'r') as f: | |
headers = f.readline().split(',')[:-1] | |
lines = [] | |
for line in f: | |
line = line.split(',') |