Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjie benjie

View GitHub Profile
@benjie
benjie / HSBC.js
Created Mar 22, 2012
HSBC Personal Statement to CSV
View HSBC.js
/******************************
HSBC Personal Statement to CSV
v0.5
Copyright: Benjie Gillam (2012)
License: WTFPL v2.0 ( http://en.wikipedia.org/wiki/WTFPL )
Instructions:
Add the following bookmarklet to your browser:
@benjie
benjie / event-listener.coffee
Created Apr 9, 2012
CoffeeScript EventListener class
View event-listener.coffee
# To use this, just do `EventListener.infect(YourClassHere)`
class EventListener
@infect: (Class) ->
Class::unlistenAll = EventListener::unlistenAll
Class::listenTo = EventListener::listenTo
Class::listenOnceTo = EventListener::listenOnceTo
Class::unlistenTo = EventListener::unlistenTo
unlistenAll: (destroy = true)->
@benjie
benjie / README.md
Created May 15, 2012
`git bisect` demo using CoffeeScript 1.3.2 "=> super" bug
View README.md

To run this,

git clone git://github.com/jashkenas/coffee-script.git
cd coffee-script

Copy test.sh into the coffee-script directory, then

git bisect start
# git checkout 1.3.2

sh test.sh # FAIL -> BAD

@benjie
benjie / XMPP-vs-Pim.md
Created Jun 15, 2012
Jabber/Pidgin vs Pim
View XMPP-vs-Pim.md

Jabber/Pidgin vs Pim

This table compares Jaber/Pidgin (which compares reasonably to most XMPP client/servers) to Pim. Note we're comparing against how we expect Pim to be in early 2013 - not Pim as it currently stands today (15th June 2012). Note however that many of the features have already been implemented in basic forms, so we'll add an asterisk* to entries that aren't currently up to par, but we expect to be by early 2013.

@benjie
benjie / certificate-chain.coffee
Created Jun 28, 2012
Commented Certificate Chain Code
View certificate-chain.coffee
# Require the https/fs modules
# Akin to Apache's configuration directive:
# LoadModule ssl_module libexec/libssl.so
# (Apache's FS module is built in, I think)
https = require 'https'
fs = require 'fs'
# List the certificate chain files
# (with Apache you might put these 4 files into 1 file, called your certificate chain)
files = [
@benjie
benjie / README.md
Created Jun 28, 2012
How NOT to write a RegExp
View README.md

The below code (regexp-freeze.coffee) makes V8 lock up (both NodeJS and Chrome). It's my fault for nesting repeats (+), but it would be nice if V8 (or it's RegExp library) detected this lock-up in some way - I don't think there's many situations in which it's okay for a RegExp to take more than a second on a 134byte string on a modern desktop computer...

How not to write it:

/`((?:[^\\`\n]+|(?:\\[^\n]))+)`/g

How to write it:

@benjie
benjie / lighting5.spec.coffee
Created Nov 5, 2012
JS vs Coffee for node-rfxcom tests
View lighting5.spec.coffee
rfxcom = require("../lib")
matchers = require("./matchers")
FakeSerialPort = require("./helper")
beforeEach ->
@addMatchers toHaveSent: matchers.toHaveSent
fakeSerialPort = new FakeSerialPort()
device = new rfxcom.RfxCom "/dev/ttyUSB0", {port: fakeSerialPort}
describe "Lighting5 class", ->
lighting5 = undefined
@benjie
benjie / sorted.txt
Last active Dec 12, 2015
Possible bytes where no binary zeros can touch.
View sorted.txt
# Sorted, and matched against LightwaveRF unitcodes.
1111 1111
1111 1110
1111 1101
1111 1011
1111 1010 !!!
1111 0111
1111 0110 - Unit 1
1111 0101 !!!
@benjie
benjie / README.md
Created Mar 12, 2013
Fat arrow binding inheritance bug in CoffeeScript 1.6.1
View README.md

This bug has already been fixed in CoffeeScript master - I'd use 1.5.0 until an update to 1.6.1 is available.

To run this,

git clone git://github.com/jashkenas/coffee-script.git
cd coffee-script

Copy test.sh into the coffee-script directory, then

git bisect start
@benjie
benjie / .vimrc
Created Mar 25, 2013
My vimrc, uses Vundle for dependencies.
View .vimrc
set nocompatible " be iMproved
filetype off " required!
let mapleader = "\<Space>"
set rtp+=~/.vim/bundle/vundle/
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
call vundle#rc()