Skip to content

Instantly share code, notes, and snippets.

View cincodenada's full-sized avatar

Ell Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / slice_ngrams.sh
Created February 14, 2013 07:30
Search Google NGrams for total occurrences of pairs of words, in this case CRC32 collisions in dictionary files. Reads in a CSV of pairs of words, one pair per line. Run the shell script in a directory that has the g-zipped 1grams in it, it will slice out just the needed lines out of the ngrams. Then the perl script will total them up.
gunzip -c googlebooks-eng-all-1gram-*-[a-z].gz | pv | grep -P `cat reddit_words.csv | perl -e "while(<>) { s/\'s//g; chomp; push @words, split ','; } printf '^(%s)\\t', join '|', @words;"` > collision_stats.tsv
@cincodenada
cincodenada / xkcd_time.js
Last active December 15, 2015 10:29
The main part of Javascript that drives xkcd's "Time" comic (http://xkcd.com/1190/), deobfuscated and annotated. The bulk of the script seems to be an implementation of EventSource - which, while important, is not terribly interesting for our purposes, so I've omitted it here. After some Googling around, I am in fact fairly certain that the Even…
//This event appears to ping xkcd's servers when various things happen
//Probably for serverside logging/analytics/debugging/statistics
function ping_event(evt_name) {
(new Image).src = "http://xkcd.com/events/" + evt_name
}
//This function ouputs debug info into the javascript console if the URL has a "#verbose" anchor appended
function log() {
location.hash == "#verbose" && console.log.apply(console, arguments)
}
//A list of event streams to choose from at random, for load balancing
void setup() { } // no setup needed
void loop() {
if (digitalRead(PIN_C2)) {
Keyboard.print("A");
delay(250); //Really simple debouncing
}
}
@cincodenada
cincodenada / rot.py
Created September 14, 2013 00:09
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):
@cincodenada
cincodenada / logsb
Created November 2, 2013 01:39
A quick alias in irssi to save the scrollback log to a file. I recently turned on logging (/set autolog ON), and wanted to save what scrollback I'd kept as well. After some reading up, this should add the /logsb command, which stores logs for the current channel in the same place as the default logging, in files tagged .scrollback.log. The alias…
/alias logsb lastlog -file ~/irclogs/${tag}/${C}.${F}_${Z}.scrollback.log
@cincodenada
cincodenada / xmonad.hs
Created December 12, 2013 19:53
Current xmonad config
import XMonad
import XMonad.Actions.CopyWindow
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
--import XMonad.Hooks.ICCCMFocus
import XMonad.Hooks.SetWMName
import XMonad.Layout.NoBorders
import XMonad.Layout.Spiral
import XMonad.Util.Run(spawnPipe)
(function(){
GEvent.clearListeners(gmap, "click");
document.getElementsByTagName('input')[0].insertAdjacentHTML('afterend','Drive Times: <input id="minutes" style="width:5em" type="text" value="5 15"/> (in minutes, separate multiple times with spaces)');
GEvent.addListener(gmap, "click", function(marker, point) {
if(!marker){
mapExtension.removeFromMap(gOverlays);
var frslayer = new esri.arcgis.gmaps.FeatureSet();
var feature = new esri.arcgis.gmaps.Feature();
feature.geometry = point;
@cincodenada
cincodenada / startling.pl
Last active August 29, 2015 13:57
Word deconstruction finder
#!/usr/bin/perl
use Data::Dumper;
use strict;
my $len;
my %tree;
while(<>) {
chomp;
if(/^[A-Za-z]+$/) {
$tree{length($_)}{$_} = [];
@cincodenada
cincodenada / hotelstuff.R
Last active August 29, 2015 14:04
Hotel Graph from /r/dataisugly
library(ggplot2)
library(scales)
library(grid)
nicer_still = T
hotelstuff = read.csv('hotelstuff.tsv',sep="\t")
if(nicer_still) {
#Order by revenue change
hotelstuff = hotelstuff[with(hotelstuff,order(-Revenue.Change)),]
@cincodenada
cincodenada / data.tsv
Created August 21, 2014 05:13
Music Purchase graph re-creatgion from /r/dataisbeautiful
8-Track 1980 14.3
8-Track 1981 7.9
8-Track 1982 1.0
8-Track 1983 0.0
8-Track 1984 0.0
8-Track 1985 0.0
8-Track 1986 0.0
8-Track 1987 0.0
8-Track 1988 0.0
8-Track 1989 0.0