Skip to content

Instantly share code, notes, and snippets.

@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),
@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
(
@flodel
flodel / image.gallery.R
Created May 2, 2012 04:04
Basic Craigslist API
@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"
@nivertech
nivertech / README.md
Created May 11, 2012 09:58 — forked from bergie/README.md
MQTT pub/sub example

This is a simple example of the MQTT protocol with Node.js. The client code has also been tested with a combination of C++ servers and clients.

@Nimster
Nimster / gist:2838511
Created May 30, 2012 19:45
Quick reference to some common R idioms/capabilities - mainly to serve as a reminder for me
### Most of the summary is taken from the awesome R twotorials at http://www.twotorials.com/ by Anthony Damico
### Some of it are my additions from my experience. This is intended so you can Ctrl+F and find what you want using
### common names of functions and concepts from other languages or statistics.
### Troubleshooting: Search http://tolstoy.newcastle.edu.au/R/ , http://www.r-bloggers.com/, http://www.rseek.org/
### Basics
traceback() # Get the call stack after an error, for debugging
32 %% 2 # == 0 mod operator
5 %/% 3 # == 1 integer division
@l4u
l4u / gist:3368486
Created August 16, 2012 08:46
Installing esl-erlang on ubuntu
deb http://binaries.erlang-solutions.com/debian precise contrib
wget -O - http://binaries.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install esl-erlang
@ericbmerritt
ericbmerritt / dialyzer.mkf
Created September 2, 2012 14:59
Dialyzer Example Makefile
# -*- mode: Makefile; fill-column: 80; comment-column: 75; -*-
ERL = $(shell which erl)
ERLFLAGS= -pa $(CURDIR)/.eunit -pa $(CURDIR)/ebin -pa $(CURDIR)/*/ebin
REBAR=$(shell which rebar)
ifeq ($(REBAR),)
$(error "Rebar not available on this system")
@ralight
ralight / printer.py
Created October 31, 2012 19:07
Print incoming MQTT messages with a maximum width of 32 characters.
#!/usr/bin/python
import mosquitto
import textwrap
def on_message(mosq, obj, msg):
for s in textwrap.wrap(msg.payload, width=32):
print(s)
mqttc = mosquitto.Mosquitto()
namespace :app do
desc "create a new app with the given name -- for example, app:create[new_app_name]"
task :create, [:name] => :environment do |t, args|
underscore = get_underscore(args)
name = underscore.camelize
directory = get_directory(args)
raise "#{directory} already exists!" if File.exists?(directory)
puts "Creating app #{name} in #{directory}"