Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am atomizer on github.
  • I am atomizer (https://keybase.io/atomizer) on keybase.
  • I have a public key whose fingerprint is 4AB4 3BCC 242E 7D1A 2EE5 145A 8C03 EC0C 1005 5AB1

To claim this, I am signing this object:

@atomizer
atomizer / gist:9688885
Last active September 11, 2020 18:20
id
@atomizer
atomizer / main.js
Created September 29, 2013 17:50
a console.log replacement that prints callee file name and line
// this goes in the main file
// (assumes that all the modules that use this function are in the same directory or below)
// the Error.stack trick suggested by isaacbw on #Node.js on freenode
global.log = function() {
var line = new Error().stack.match(/at .+\n/g)[1]
var filename = line.match(/\((.+?\.js:\d+)/)[1].replace(__dirname, '').slice(1)
var args = [].slice.call(arguments)
args.unshift('[%s]', filename)
console.log.apply(this, args)
@atomizer
atomizer / extract.py
Last active January 17, 2019 19:04
rotmg asset extractor
#!/usr/bin/python
import re, os, sys
import tempfile
import shutil
import argparse
from subprocess import *
from urllib2 import urlopen, HTTPError
# for parsing swfdump output
@atomizer
atomizer / hostpack.js
Created November 4, 2012 01:02
dns host pack
function enc(s) {
if (!s) throw new Error('need hostname')
if (s.slice(-1) != '.') s += '.'
var r = Buffer(s.length + 1)
s = s.split('.')
var cc = 0
for (var i = 0; i < s.length; i++) {
r.writeUInt8(s[i].length, cc)
cc++
r.write(s[i], cc)
import sys, re
try:
from lxml import etree
except ImportError:
try:
import xml.etree.cElementTree as etree
except ImportError:
try:
import xml.etree.ElementTree as etree
@atomizer
atomizer / bezier.js
Created June 27, 2011 20:23
de Casteljau's algorithm in javascript
function bezier(pts) {
return function (t) {
for (var a = pts; a.length > 1; a = b) // do..while loop in disguise
for (var i = 0, b = [], j; i < a.length - 1; i++) // cycle over control points
for (b[i] = [], j = 0; j < a[i].length; j++) // cycle over dimensions
b[i][j] = a[i][j] * (1 - t) + a[i+1][j] * t; // interpolation
return a[0];
}
}