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/env python | |
class AnObjectThatCanBeCalled(object): | |
def __call__(self): | |
print 'Called an object' | |
def AFunction(): | |
print 'Called an actual function' | |
obj = AnObjectThatCanBeCalled() |
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
{ | |
total: 1, | |
start: 0, | |
size: 10, | |
hits: [{ | |
_index: "artemis-0319", | |
_type: "story", | |
_id: "931678", | |
_score: 14.204842, | |
_source: { |
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
curl --user $USERNAME:$PASSWORD -X POST -H "Content-Type: application/json" -d '{ "scopes": ["repo","gist","notifications"], "client_id": "$OAUTH_APP_ID", "client_secret": "$OAUTH_APP_SECRET" }' https://api.github.com/authorizations |
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/env python | |
# -*- coding: utf-8 -*- | |
import getpass | |
import json | |
import requests | |
from requests.auth import HTTPBasicAuth | |
# CHANGE THESE CONSTANTS |
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
combos = combinations(state_ids, 1); | |
_.each(combos, function(combo) { | |
// Calculate available votes | |
var combo_votes = _.reduce(combo, function(memo, id) { return memo + states_by_id[id].electoral_votes; }, 0); | |
// (1) Skip combinations which don't have enough votes to win for Romney | |
if (combo_votes >= red_needs && red_needs > 0) { | |
// (2) Skip supersets of prior combinations | |
if (!is_subset(red_combos, combo)) { |
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
function combinations(superset, min_size, max_size) { | |
/* | |
* Compute all possible combinations of a given array. | |
* | |
* Algorithm via http://stackoverflow.com/a/4061167 | |
*/ | |
var result = []; | |
var size = min_size || 1; | |
var max_size = max_size || superset.length |
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 = <c-w>><c-w>><c-w>><c-w>><c-w>> | |
map - <c-w><<c-w><<c-w><<c-w><<c-w>< |
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
session: | |
name: "electris" | |
windows: | |
- name: "term" | |
clear: true | |
root: "~/src/electris" | |
filters: | |
before: | |
- "workon electris" | |
splits: |
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
$ cloc --exclude-dir=media,.coverage,_site,docs,test_data,coverage_html,client/static/js/lib . | |
400 text files. | |
392 unique files. | |
1072 files ignored. | |
http://cloc.sourceforge.net v 1.55 T=4.0 s (68.2 files/s, 7816.5 lines/s) | |
------------------------------------------------------------------------------- | |
Language files blank comment code | |
------------------------------------------------------------------------------- |
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
First order approximation of this image's actual slice size using pixel counts: | |
https://motherjones.com/files/images/komen_expenses_300px.jpg | |
Graphic had numbers painted out and text cropped before processing with stupid.py. | |
Pixel counts, l to r: | |
(255, 162, 194, 255) 1602 | |
(177, 178, 180, 255) 392 |