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
PyWebsocket http://code.google.com/p/pywebsocket/ | |
HTML from http://pedroassuncao.com/blog/2009/12/18/websockets-tutorialexample-with-pywebsocket/ |
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
#author: Davit Khaburdzania | |
#email: [email protected] | |
#github: github.com/davit-khaburdzania | |
fs = require "fs" | |
mongojs = require "mongojs" | |
db = mongojs 'mongodb://db_address', ['airports'] | |
#countries in europe | |
eu_countries = ["austria", "belgium", "bulgaria", "cyprus", "czech republic", "denmark", "estonia", "finland", "france", "germany", "greece", "hungary", "ireland", "iceland", "italy", "latvia", "lithuania", "luxembourg", "malta", "netherlands", "norway", "poland", "portugal", "romania", "slovakia", "slovenia", "spain", "sweden", "switzerland", "united kingdom"] |
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
# you can make a text file of request times (in ms, one number per line) and import it here, or you can use a probability distribution to simulate request times (see below where setting req_durations_in_ms) | |
# rq = read.table("~/Downloads/request_times.txt", header=FALSE)$V1 | |
# argument notes: | |
# parallel_router_count is only relevant if router_mode is set to "intelligent" | |
# choice_of_two, power_of_two, and unicorn_workers_per_dyno are only relevant if router_mode is set to "naive" | |
# you can only select one of choice_of_two, power_of_two, and unicorn_workers_per_dyno | |
run_simulation = function(router_mode = "naive", | |
reqs_per_minute = 9000, |
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
######### Intro to R ############### | |
######### The Data Frame ########### | |
df <- data.frame( | |
row.names = c('HaLikud', 'Yesh Atid', 'HaAvoda', 'HaBait HaYehudi', 'Yehadut HaTora', 'Meretz', 'Shas'), | |
LeaderName = c('Netanyahu', 'Lapid', 'Yehimovitch', 'Bennet', 'Litzman', 'GalOn', 'Yishai'), | |
Category = c('Right', 'Center', 'Left', 'Right', 'Religious', 'Left', 'Religious'), | |
Mandates = c(31, 19, 15, 12, 7, 6, 11) | |
) |
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}" |
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
# -*- 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
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
### 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 |