Skip to content

Instantly share code, notes, and snippets.

@kerspoon
kerspoon / singlequote.js
Created April 8, 2015 15:44
convert a javascript file to only contain singlequotes.
'use strict';
/*eslint-env node */
var fs = require('fs'),
esprima = require('esprima');
var input = process.argv[2],
output = input,
offset = 0,
content = fs.readFileSync(input, 'utf-8'),
@kerspoon
kerspoon / globals.js
Created May 15, 2012 14:29
Find Added Globals
var GLOBAL_Env = [];
for (var x in window) {
if (window.hasOwnProperty(x)) {
GLOBAL_Env.push(x);
}
}
function GLOBAL_FindAdded() {
var newVars = [];
@kerspoon
kerspoon / browse-apropos-url.el
Created October 12, 2011 08:27
emacs customisations
;; http://www.emacswiki.org/emacs/BrowseAproposURL
(require 'browse-url)
(setq apropos-url-alist
'(
("^g:? +\\(.*\\)" . ;; Google Web
"http://www.google.com/search?q=\\1")
("^g?w:? +\\(.*\\)" . ;; Google Wikipedia
@kerspoon
kerspoon / escape_as_javascript_string_literal.py
Created August 16, 2011 22:31
Escape the required characters and surround with double quotes to produce a valid ECMAScript string literal from any normal string.
def escape_as_javascript_string_literal(text):
"""
Escape the required characters and surround with double quotes to produce a
valid ECMAScript string literal from any normal string.
----
ECMA-262 -> 7.8.4 String Literals
A string literal is zero or more characters enclosed in single or
@kerspoon
kerspoon / simple perlin noise
Created January 8, 2010 10:34
simple perlin noise
#! /usr/local/bin/python
# simple perlin noise
#------------------------------------------------------------------------------
# Copyright (C) 2009 James Brooks (kerspoon)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
@kerspoon
kerspoon / template.py
Created November 17, 2009 10:40
template for python programs
#! /usr/local/bin/python
# template for python programs
#------------------------------------------------------------------------------
# Copyright (C) 2009 James Brooks (kerspoon)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
@kerspoon
kerspoon / pymisc.py
Created November 16, 2009 15:55
Python Utilities - replaced by `defaultdict` and `join`
#! /usr/bin/env python
# Python Utilities - replaced by `defaultdict` and `join`
import csv
import sys
from itertools import islice
# ---------------------------------------------------------------------------- #
# countedadd :: {set(T)=int}, set(T) -> {set(T)=int}
def countedadd(database,sample):
@kerspoon
kerspoon / parsefile.py
Created November 3, 2009 16:17
Plaintext table parser
#! /usr/local/bin/python
from pyparsing import *
import StringIO
from decimal import Decimal
import string
import logging
logger = logging.getLogger(__name__)