Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / rot.py
Created Sep 14, 2013
Quick binary rotation (rotl/rotr) in Python
View rot.py
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 Nov 2, 2013
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…
View logsb
/alias logsb lastlog -file ~/irclogs/${tag}/${C}.${F}_${Z}.scrollback.log
@cincodenada
cincodenada / demo.js
Last active Sep 27, 2021
A version of my Bull demo script that attempts to clear jobs during their run, used to demonstrate bug #2167
View demo.js
const Queue = require('bull')
const delay = require('delay')
const shouldReAdd = process.argv.includes('--readd')
const timelog = (...args) => { console.log(+Date.now(), ...args) }
;(async () => {
timelog('Creating queue')
const queue = new Queue('example')
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
checkReadOnly = false;
appName = 'Ember Twiddle';
}
View controllers.application\.js
import Controller from '@ember/controller';
export default Controller.extend({})
View controllers.application\.js
import Controller from '@ember/controller';
const BaseController = Controller.extend({
actions: {
nameAlert: function(person){
window.alert('alert from BaseController: ' + person.lastName + ', ' + person.firstName);
}
}
})
@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 / 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 / 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 / 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) {