Skip to content

Instantly share code, notes, and snippets.

View cincodenada's full-sized avatar

Ell Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / delayspec.pl
Created February 11, 2016 04:19
Gifsicle Speed Changer
use POSIX;
if($#ARGV == -1) { die "No speedup value specified!"; }
$speedup = shift(@ARGV);
while(<>) {
if(/\+ image #(\d+)/) {
$num = $1;
} elsif(/delay ([\d\.]+)s/) {
$delay = POSIX::strtod($1);
$delay /= $speedup;
if($lastdelay && $lastdelay != $delay) {
@cincodenada
cincodenada / fix_vagrant_gid.sh
Last active February 6, 2017 22:33
Patches Vagrant bug #7616
#!/bin/bash
# Patches a Vagrant permissions-creating script that breaks assigning groups
# that don't have a matching user. See Vagrant bug #7616
# Thanks to @Jc-L for the patch
paths=( "/usr/share/vagrant/" "/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/" )
for p in "${paths[@]}"; do
if [ -d "$p" ]; then
PREFIX="$p"
@cincodenada
cincodenada / README.md
Last active April 1, 2016 23:55
Robin Counter

Copy/paste the following into the target for a bookmark:

javascript:void%20function(){function%20o(s){n.forEach(function(o){var%20n=$(%22.robin-room-participant.robin--vote-class--%22+o).length;$(%22.robinmod-users-%22+o).text(n),console.log(%22Updated%20%22+o+%22%20count:%20%22+n)});var%20a=$(%22.robin-room-participant%22).length;$(%22.robinmod-users-total%22).text(a),console.log(%22Updated%20total%20count:%20%22+a),setTimeout(o,s)}$ourdiv=$(%22%23robinmod-counts%22);var%20n=[%22increase%22,%22continue%22,%22abandon%22,%22novote%22];$ourdiv.length||($ourdiv=$('%3Cdiv%20id=%22robinmod-counts%22%20style=%22margin:%205px%2015px%22%3EUsers%20here:%20%3Cspan%20class=%22robinmod-users-total%22%3E%3C/span%3E%20(%3Cspan%20class=%22robinmod-subcounts%22%3E%3C/span%3E)%20%3C/div%3E'),n.forEach(function(o){$ourdiv.find(%22.robinmod-subcounts%22).append('%3Cspan%20class=%22robin--vote-class--'+o+'%22%3E%3Cspan%20class=%22robin--icon%22%3E%3C/span%3E%3Cspan%20class=%22robinmod-users-'+o+'%22%3E%3C/span%3E%3C/span%3E

@cincodenada
cincodenada / tableizer.js
Last active March 13, 2016 19:32
Pulls arbitrary table data out into a TSV
trs = document.querySelectorAll('tr');
Array.prototype.map.call(trs, function(tr) {
if(tr.children.length > 2) {
return Array.prototype.map.call(tr.children, function(td) {
return td.textContent.trim();
}).join("\t");
} else {
return null;
}
}).join("\n");
@cincodenada
cincodenada / save_body.py
Last active February 27, 2016 15:32 — forked from mhils/save_body.py
Update for new API
from libmproxy.model import decoded
def response(context, flow):
with decoded(flow.response): # automatically decode gzipped responses.
with open("body.txt","ab") as f:
f.write(flow.response.content)
(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 / 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)
void setup() { } // no setup needed
void loop() {
if (digitalRead(PIN_C2)) {
Keyboard.print("A");
delay(250); //Really simple debouncing
}
}
@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
@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