Skip to content

Instantly share code, notes, and snippets.

View onyxfish's full-sized avatar

Christopher Groskopf onyxfish

View GitHub Profile
@onyxfish
onyxfish / example.py.ipynb
Last active October 24, 2015 01:51
Using agate in a Jupyter notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@onyxfish
onyxfish / oauth.sh
Created December 14, 2012 15:47
Generate a Github OAuth token using Curl
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import getpass
import json
import requests
from requests.auth import HTTPBasicAuth
# CHANGE THESE CONSTANTS
@onyxfish
onyxfish / app.js
Created October 24, 2012 19:19
Code to generate and prune state combinations
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)) {
@onyxfish
onyxfish / combinations.js
Created October 24, 2012 17:32
Algorithm for non-recursively generating combinations in JavasScript
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
@onyxfish
onyxfish / .vimrc
Created September 27, 2012 19:41
Map - and = to resize vertical window splits by five columns at a time
map = <c-w>><c-w>><c-w>><c-w>><c-w>>
map - <c-w><<c-w><<c-w><<c-w><<c-w><
@onyxfish
onyxfish / electris.yml
Created September 27, 2012 14:16
Teamocil Config
session:
name: "electris"
windows:
- name: "term"
clear: true
root: "~/src/electris"
filters:
before:
- "workon electris"
splits:
@onyxfish
onyxfish / cloc.txt
Created September 5, 2012 19:25
PANDA Project Stats
$ 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
-------------------------------------------------------------------------------
@onyxfish
onyxfish / results.txt
Created February 7, 2012 16:48
Stupid Komen graphic
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
@onyxfish
onyxfish / 10periodic
Created November 18, 2011 03:15
Configuration files for hacktyler_project
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::RandomSleep "1800";