Skip to content

Instantly share code, notes, and snippets.

View belisarius222's full-sized avatar

Ted Blackman belisarius222

View GitHub Profile
@belisarius222
belisarius222 / long_to_bytes.py
Last active August 29, 2015 13:57
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
l.reverse()
@belisarius222
belisarius222 / location.js
Last active December 17, 2015 04:58
a super-bare-bones implementation of a reactive window.location (include this somewhere on the client in a Meteor app)
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
belisarius222 / get-from-bucket.py
Last active December 21, 2015 06:09
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 = [
'doxygenConfig',
'firstExample',
'secondExample',
'SConstruct',
'mongod',
'mongo',
'mongodump',
@belisarius222
belisarius222 / loadTiming.js
Created March 30, 2013 19:24
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 http://www.google.com
var page = require('webpage').create(),
system = require('system'),
startTime, address, requestStartTimes, requestDurations;
if (system.args.length === 1) {
console.log('Usage: netlog.js <some URL>');
phantom.exit(1);
}
address = system.args[1];
@belisarius222
belisarius222 / handgrenade.py
Last active April 15, 2016 05:18
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
belisarius222 / hoon.kak
Created September 2, 2017 08:36
hoon syntax highlighting for kakoune
# Detection
#
hook global BufCreate .*[.](hoon) %{
set buffer filetype hoon
}
# Highlighters & Completion
#
@belisarius222
belisarius222 / up-forward-toward-%ford-0.md
Last active September 22, 2017 19:15
up-forward-toward-%ford-0

up 1: forward %ford, toward 0k

up: 1
authors: [~rovnys-ricfer(ted@tlon.io), ~pittyp-datfun(anton@tlon.io)]

overview

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

@belisarius222
belisarius222 / meetup.hoon
Last active September 23, 2017 03:05
some examples of compiling hoon to nock
::
:::: it's a trap!
::
!=
=/ a 3
|.
?: =(a 5)
a
$(a +(a))
::
@belisarius222
belisarius222 / .vimrc
Created November 15, 2017 21:36
.vimrc_11_15_2017
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'