View gist:ba785487b635ade67701
1 2 3 4 5 6 7 8 9 10
# These instructions work for OS X 10.6 with homebrew pre-installed.
 
brew install python --framework
brew install gcc
# install other dependencies through pip:
 
pip install numpy
 
# the regular pip build for matplotlib is b0rken, and it can't find the built-in libraries for OSX
export LDFLAGS="-L/usr/X11/lib"
View agent.nut
1 2 3 4 5 6 7 8 9
// Run on Agent
 
// Thresholds to adjust for better accuracy
dataThreshold <- 300; // Minimum accelerometer value to count as ON
onThreshold <- 24; // Number of ON samples before machine enters RUNNING state
offThreshold <- 60; // Number of OFF samples before machine enters OFF state
 
// State variable
running <- false;
View edison-output.txt
1 2 3 4 5 6 7 8 9 10
******************************
PSH KERNEL VERSION: b0182727
WR: 20104000
******************************
 
SCU IPC: 0x800000d0 0xfffce92c
 
PSH miaHOB version: TNG.B0.VVBD.0000000c
 
microkernel built 23:15:13 Apr 24 2014
View edison-output.txt
1 2 3 4 5 6 7 8 9 10
******************************
PSH KERNEL VERSION: b0182727
WR: 20104000
******************************
 
SCU IPC: 0x800000d0 0xfffce92c
 
PSH miaHOB version: TNG.B0.VVBD.0000000c
 
microkernel built 23:15:13 Apr 24 2014
View package.json
1 2 3 4 5 6 7 8 9 10
{
"name": "pinoccio-couch-example",
"description": "couch example for saving pinoccio stats",
"version": "0.0.0",
"repository": {
"url":"https://gist.github.com/c11d6ae6f4bead140838.git"
},
"main": "index.js",
"scripts": {
"test": "tape test/*.js"
View promises.md

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
View app.js
1 2 3 4 5 6 7 8 9 10
var express = require('express'),
mongoose = require('mongoose'),
app;
 
app = module.exports = express.createServer();
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
View nginx.conf
1 2 3 4 5 6 7 8 9
# Puma upstream
upstream puma {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
 
# for UNIX domain socket setups:
server unix:/mnt/project/api/shared/tmp/sockets/puma.sock fail_timeout=0;
}
View queue_select.rb
1 2 3 4 5 6 7 8 9 10
require 'thwait'
 
# Synchronous hand-off between two threads.
# Both threads will block until a transfer is successful.
class Rendevous
def initialize
@mutex = Mutex.new
@send_flag = ConditionVariable.new
@recv_flag = ConditionVariable.new
@container = []
Something went wrong with that request. Please try again.