Skip to content

Instantly share code, notes, and snippets.


Ted Blackman belisarius222

View GitHub Profile
belisarius222 /
Last active Aug 29, 2015
python3 implementation of long_to_bytes from pysrp package
def long_to_bytes(n):
l = []
x = 0
off = 0
while x != n:
b = (n >> off) & 0xFF
l.append( b )
x = x | (b << off)
off += 8
belisarius222 / location.js
Last active Dec 17, 2015
a super-bare-bones implementation of a reactive window.location (include this somewhere on the client in a Meteor app)
View location.js
var Location = {};
this.Location = Location;
Location.dep = new Deps.Dependency;
Location.state = window.history.state;
window.onpopstate = function(event){
Location.state = event.state;
// note that popstate gets fired on initial page load in Webkit,
belisarius222 /
Last active Dec 21, 2015
little script to download files sequentially from an S3 bucket. This will download all the mongo binaries into the same directory as the script.
import requests
filenames = [
belisarius222 / loadTiming.js
Created Mar 30, 2013
Log start time, end time, and duration for requests using phantomjs. Also print out the average request durations. You should probably modify it a bit to make sure it exits under whatever conditions make the most sense for you. Run like: phantomjs loadTiming.js
View loadTiming.js
var page = require('webpage').create(),
system = require('system'),
startTime, address, requestStartTimes, requestDurations;
if (system.args.length === 1) {
console.log('Usage: netlog.js <some URL>');
address = system.args[1];
belisarius222 /
Last active Apr 15, 2016
Custom Python Exceptions
class HandGrenadeError: pass
class WrongNumberError(HandGrenadeError): pass
class HolyHandGrenade:
def reference(self):
return "Armaments, chapter two, verses nine through twenty-one."
def lob(self, number):
if number != 3:
import cv2
def downsample(im):
return im[::2, ::2, :]
def smoothIm(im, kernelSize=5):
return cv2.GaussianBlur(im, (kernelSize, kernelSize), 0)
belisarius222 / hoon.kak
Created Sep 2, 2017
hoon syntax highlighting for kakoune
View hoon.kak
# Detection
hook global BufCreate .*[.](hoon) %{
set buffer filetype hoon
# Highlighters & Completion

up 1: forward %ford, toward 0k

up: 1
authors: [~rovnys-ricfer(, ~pittyp-datfun(]


%ford is urbit's build system. It's one of the seven kernel modules (vanes)

belisarius222 / meetup.hoon
Last active Sep 23, 2017
some examples of compiling hoon to nock
View meetup.hoon
:::: it's a trap!
=/ a 3
?: =(a 5)
$(a +(a))
belisarius222 / .vimrc
Created Nov 15, 2017
View .vimrc
set nocompatible
set encoding=utf-8
let mapleader = " "
" Vundle stuff
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'