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 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/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
When you need to use scalar arguments after function arguments use one of the following approaches:
delayed_ping = (client) ->
log "delayed_ping"
setTimeout (c) ->
log 'ping'
c.pingreq {}
, KEEP_ALIVE_SEC*1000
This file contains 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
-- ------------------------------------------------------------------------------------------------------- | |
-- A SQL script for importing GFTS data from the State of Delaware into a MySQL database. | |
-- | |
-- Copyright 2010 Mark J. Headd | |
-- http://www.voiceingov.org | |
-- | |
-- This file is free software; you can redistribute it and/or modify it under the terms of the | |
-- GNU Library General Public License as published by the Free Software Foundation; either version 2 of the | |
-- License, or (at your option) any later version. | |
-- This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
This file contains 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
-- ------------------------------------------------------------------------------------------------------- | |
-- A SQL script for importing GFTS data from the State of Delaware into a MySQL database. | |
-- | |
-- Copyright 2010 Mark J. Headd | |
-- http://www.voiceingov.org | |
-- | |
-- This file is free software; you can redistribute it and/or modify it under the terms of the | |
-- GNU Library General Public License as published by the Free Software Foundation; either version 2 of the | |
-- License, or (at your option) any later version. | |
-- This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
This file contains 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
-- ---------------------------------------------------------------------------------------------------- | |
-- Stored Procedures for querying GFTS data from the State of Delaware in a MySQL database. | |
-- | |
-- Copyright 2010 Mark J. Headd | |
-- http://www.voiceingov.org | |
-- | |
-- This file is free software; you can redistribute it and/or modify it under the terms of the | |
-- GNU Library General Public License as published by the Free Software Foundation; either version 2 of the | |
-- License, or (at your option) any later version. | |
-- This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
This file contains 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 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 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 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.