Skip to content

Instantly share code, notes, and snippets.

@jimtla
jimtla / underscoreR.coffee
Created May 6, 2012 21:51
Add CoffeeScript friendly argument order to Underscore.js
# Five lines of code that will make your underscore + CoffeeScript use cleaner.
# Creates an underscore function for each function in to_reverse with R (short for Reversed) appended to the name.
# The R version moves the function argument (first argument in normal underscore) to the end,
# so you can write:
$(window).scroll _.throttleR 500, ->
console.log "This print's at most every 500ms"
# Instead of:
$(window).scroll _.throttle ->
console.log "This prints at most every 500ms too"
@flodel
flodel / image.gallery.R
Created May 2, 2012 04:04
Basic Craigslist API
@joelreymont
joelreymont / subman.sql
Created April 30, 2012 20:30
Mix SQL from a real project
CREATE TABLE Subman_Publisher
(
id string AUTO PRIMARY KEY, -- auto-generated, uuid
stacks set of string REFERENCES Subman_Stack, -- primary key ref
subscription_count int
);
CREATE TABLE Subman_Stack
(
@maxlapshin
maxlapshin / parse_erlang.erl
Created April 29, 2012 06:59
Parse erlang config file loaded into binary
parse(Text) when is_binary(Text) ->
parse(binary_to_list(Text));
parse(Text) when is_list(Text) ->
parse(Text, [], 0, []).
parse(Text, Env, Line, Acc) ->
case erl_scan:tokens([], Text, Line) of
{done, {ok, Scanned, NewLine}, Rest} ->
{ok, Parsed} = erl_parse:parse_exprs(Scanned),
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@evilpie
evilpie / disassembler.js
Created April 4, 2012 11:51
Disassembler for Notch's 'DCPU-16'
/* See: http://0x10c.com/doc/dcpu-16.txt */
function hex(n) {
return '0x' + n.toString(16);
}
function disassemble (code) {
var PC = 0;
var operand = function (bits) {
@davatron5000
davatron5000 / gist:2254924
Created March 30, 2012 20:57
Static Site Generators

Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.

Ruby

@donavanm
donavanm / elasticat.json
Created March 22, 2012 05:44
CloudFormation EC2 & Route53 template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Create an EC2 instance, set up Apache, and create Route53 A records",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
./redis-benchmark -n 1000000 -P 16 -q
PING_INLINE: 672947.56 requests per second
PING_BULK: 716845.88 requests per second
SET: 309693.41 requests per second
GET: 463606.84 requests per second
INCR: 357142.88 requests per second
LPUSH: 360100.84 requests per second
LPOP: 364298.75 requests per second
SADD: 340831.62 requests per second
SPOP: 461893.78 requests per second
@njh
njh / bbc_now_next_mqtt.rb
Created February 5, 2012 23:19
Submit BBC Programme Now and Next to MQTT
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'net/http'
require 'uri'
require 'mqtt'
require 'pp'
NOW_NEXT_RADIO_URL = 'http://www.bbc.co.uk/iplayer/ion/multinownext/service_type/radio/format/json'