Skip to content

Instantly share code, notes, and snippets.

@passcod
passcod / toSource2.coffee
Last active December 11, 2015 09:08
Gecko-style #toSource() shim
toSource2 = (data) ->
typ = typeof data
if typ == "number" and isNaN data
"NaN"
else if ["string", "number", "boolean"].indexOf(typ) != -1
JSON.stringify data
else if typ == "function"
"(#{data.toString()})"
else if data instanceof Array
"[#{data.map(toSource2).join(", ")}]"
anonymous
anonymous / gist:5308457
Created April 4, 2013 07:13
Binary-to-url benchmark in node.js
#!/usr/bin/env node
var fs = require('fs');
var re = /(..)/g;
var methods = {
with_escape: function(data) {
return escape(data.toString('binary'));
},
with_loop: function (data) {
@passcod
passcod / attention
Last active December 15, 2015 23:58
Obfuscated
Google's Closure Compiler
throws up if you give it this.
Just sayin'
anonymous
anonymous / dump
Created May 3, 2013 13:05
7 generations of git://github.com/tbranyen/nodegit.git
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0~ ## ####
1~ # ## ###
2~ ######
3~ # # ## #
4~ # ####
5~ # # #
6~ ##
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@passcod
passcod / hookz.rb
Created August 15, 2013 04:10 — forked from anonymous/hookz.rb
Hookz: Lolcommits plugin to execute custom hooks. Place an executable (shell script, binary, something else with a shebang...) in ~/.lolcommits/project-name/Hookfile, and it will be called every time a commit picture is taken, with its path as argument. Use for anything you can't be bothered writing Ruby for: posting to tumblr, sending email, up…
module Lolcommits
class Hookz < Plugin
def initialize(runner)
super
self.name = 'hookz'
self.default = true
end
def run
@passcod
passcod / extend.coffee
Last active December 21, 2015 17:29
This is really normal prototypal inheritance, and the #extend and #create methods are just there for convenience, not to hide away the magic.
Namespace.extend = (src, obj = {}) ->
if typeof obj.init is 'function'
newObj = obj.init
delete obj.init
else
newObj = ->
newObj.prototype = Object.create src.prototype
newObj.prototype.constructor = newObj
for prop of obj
@hamishcampbell
hamishcampbell / polyomino.py
Created September 6, 2013 23:26
Polyomino Reference Source - PyCon 2013
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import sys
class Polyomino(object):
def __init__(self, iterable):
self.squares = tuple(sorted(iterable))
def __repr__(self):
@passcod
passcod / music-for-making.markdown
Created September 17, 2013 08:35
My playlist for moments of epic creativity

Music for Making

Air Traffic Controller

  • Can't Let Go

Apocalyptica

  • Quutamo
@relsqui
relsqui / examples.txt
Last active September 28, 2017 03:55
Older versions of the PSU out list don't have great spacing, so the identity labels and the academic fields sort of run together. The result is funny. Rather than standing in the QRC reading the out list and giggling, here's a script to generate them.
C:\home\relsqui\queermajors> ./pickmajor.py
polyamorous music
C:\home\relsqui\queermajors> ./pickmajor.py
androgynous spanish
C:\home\relsqui\queermajors> ./pickmajor.py
genderfluid pre-health
C:\home\relsqui\queermajors> ./pickmajor.py
intersex music composition
C:\home\relsqui\queermajors> ./pickmajor.py
gay chemistry