Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / fix_migrations.sh
Last active Nov 21, 2020
A test script to fix old migrations in Bookwyrm
View fix_migrations.sh
#!/bin/bash
set -e
function echo_header {
echo -e "\e[1m\e[4m\n$1\e[0m"
}
source .env
@cincodenada
cincodenada / words_in_words.py
Created Oct 3, 2018
A quick script to find words that are subsets of other words. Designed to find country names that contain other countries, but should be generally applicable.
View words_in_words.py
import fileinput
import re
from collections import defaultdict
class Word:
def __init__(self, word):
self.word = word
self.allcaps = re.sub("[^A-Z]","",word.upper())
self.countified()
@cincodenada
cincodenada / geonames.py
Created Apr 7, 2017 — forked from pamelafox/geonames.py
Geonames Python wrapper
View geonames.py
import sys
import urllib
import urllib2
import json
import logging
class GeonamesError(Exception):
def __init__(self, status):
@cincodenada
cincodenada / fix_vagrant_gid.sh
Last active Feb 6, 2017
Patches Vagrant bug #7616
View fix_vagrant_gid.sh
#!/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"
View README.md

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 Mar 13, 2016
Pulls arbitrary table data out into a TSV
View tableizer.js
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 / delayspec.pl
Created Feb 11, 2016
Gifsicle Speed Changer
View delayspec.pl
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 / save_body.py
Last active Feb 27, 2016 — forked from mhils/save_body.py
Update for new API
View save_body.py
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)
@cincodenada
cincodenada / 3dify.sh
Created Sep 29, 2015
Script that takes a gif and attempts to make a crossview 3D gif by duplicating sbs and delaying the right half by two frames.
View 3dify.sh
#!/bin/bash
FRAME="frame.gif"
INFILE=$1
OUTFILE=$2
MOVEBY=2
NUMFRAMES=`gifsicle -I $INFILE |
perl -ne 'if(/(\d+) images/) { print $1;}'`
echo "Cleaning up any previous runs..."
rm -rf left
rm -rf right
View country.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Country</title>
<meta name="description" content="">
<!-- Mobile-friendly viewport -->
You can’t perform that action at this time.