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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image.gallery <- function(url, ncol = 3L) { | |
## This function reformats the contents of a Craigslist search result URL | |
## into an image gallery, opened into the default browser | |
## | |
## Inputs: | |
## - url: a Craigslist search URL as created by search.url | |
## - ncol: the number of columns for the output image gallery | |
## | |
## Output: none. As a side effect, a browser is opened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |