Skip to content

Instantly share code, notes, and snippets.

View parshap's full-sized avatar

Parsha Pourkhomami parshap

View GitHub Profile
@parshap
parshap / foo.js
Created September 27, 2011 23:57
node-browserify watch test
// This file should be stored as js/foo.js
console.log("test")
@parshap
parshap / gist:1813827
Created February 13, 2012 05:02
irc - async example w/ async.js
function getRooms(callback) {
client.smembers('rooms', callback)
}
function getResults(rooms, callback) {
async.parallel(rooms, function(room, callback) {
client.hgetall('room_' + room, callback);
}, callback);
}
@parshap
parshap / screencap.js
Created November 11, 2012 21:17
CasperJS capture screen
var casper = require("casper").create();
// Maximum size of capture
var MAX_WIDTH = 1000,
MAX_HEIGHT = 1500;
casper.start("http://www.google.com", function() {
// Figure out how big the BODY element of the document is
var bounds = this.getElementBounds("body"),
width = Math.min(bounds.width, MAX_WIDTH),
@parshap
parshap / app.sh
Last active December 11, 2015 23:29
sudo -H bash -c "
set -a
source ./test.conf
exec env
"
description "app"
author "me"
env APP_DIR=/srv/app
env APP_PATH=/srv/app/bin/app
env LOG_PATH=/var/log/app.log
env CONF_PATH=/etc/app.conf
start on startup
stop on shutdown
@parshap
parshap / Makefile
Last active December 11, 2015 23:48
default:
npm rebuild
clean:
git clean -xdf && git checkout -f
@parshap
parshap / recipe.rb
Last active December 19, 2015 05:49
Chef recipe refactoring
NAME = "parshap"
HOME = "/home/#{NAME}"
# Known hosts
parshap_file "#{HOME}/.ssh/known_hosts" do
source "known_hosts"
mode 0600
end
# Authorized keys
@parshap
parshap / blocks.rb
Last active December 19, 2015 06:39
RUN_LIST.each do |recipe|
chef.add_recipe recipe
end
RUN_LIST.each &chef.add_recipe
@parshap
parshap / limited-map-stream.js
Last active December 23, 2015 01:09
Rate limited map-stream
var es = require("event-stream");
// Wraps a map-stream to only process *limit* chunks at a time
module.exports = function(mapStream, limit) {
var waiting = 0, ended = false, buffer = [];
var stream = es.through(write, function() {
ended = true;
maybeEnd();
});
@parshap
parshap / sphero-with-node.md
Last active December 28, 2015 22:19
Orbotix Sphero with Node.js

Sphero with Node

This document will help you get started with controlling an Orbotix Sphero using Node.js.

Client Libraries

There are several different libraries for controlling the Sphero. Currently, the best one seems to be spheron. This module provides a simple interface to the Sphero API.

There is also CylonJS, but this just uses the spheron module and exposes the same API, so unless you are already using Cylon to control different hardware it probably makes sense to just use spheron directly.