Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@andrew
andrew / xbox.js
Created December 29, 2012 01:38
Xbox Controller in Node.js (wip)
var HID = require('HID');
var util = require('util');
var events = require('events');
var devices = HID.devices();
var device
devices.forEach((function(d) {
if(typeof d === 'object' && d.product.toLowerCase() === 'controller') {
@dugdaniels
dugdaniels / index.html
Created January 7, 2013 00:34
An example of a browser-based input for Johnny-Five. Clicking the button in index.html turns on and off an LED installed on the Arduino board.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
$(document).ready(function() {
var socket = io.connect('http://localhost');
$('#button').click(function(e){
socket.emit('click');
e.preventDefault();
@cowboy
cowboy / call-invo-cursion.js
Last active March 30, 2023 01:59
JavaScript: call invo-cursion?
// OOP
console.log( 'OHAI'.blink() );
// Call invocation
console.log( String.prototype.blink.call('OHAI') );
// $ always makes things look awesome.
var $ = Function.prototype.call;
// Very explicit call invocation
@jlongster
jlongster / input.ljs
Last active December 15, 2015 04:29
LLJS compiling to asm.js
struct Point {
function void Point(double x, double y) {
this->x = x;
this->y = y;
}
double x, y;
}
function int add1(int x) {
@dfkaye
dfkaye / es6-timeout.md
Last active December 15, 2015 14:49
ES6 needs a timeout - I reserve the right to change my mind about this

2013-3-30

Some recent activity from active contributors regarding ES6 proposals threaten to undermine its acceptance from the community at large.

ES6 proposals include the fat arrow, destructured assignment, splat args, let/block scope, class syntax, class-based inheritance, setters/getters with export, the module loader syntax, weak maps, weak events, @symbols, and so forth.

That is a lot for a community user of the language to comprehend. It is a lot for a single iteration of any project.

The sheer amount of change is at root of the confusion apparent even among the es-discuss mailing list ~ [see this conversation for an example] (https://twitter.com/kangax/status/315863525899780096 ""that was removed from the spec", "I thought it was back in", "it's on the table", "'on the table' does not mean 'in the spec'"").

@Protonk
Protonk / legis.R
Last active December 17, 2015 07:49
Moved to a package: https://github.com/Protonk/preroll
# fast json library for R.
# drop in replacement for rjson (another library)
# use whatever you prefer
library(RJSONIO)
## hardcoded for this test
ny.json <- fromJSON("/Users/protonk/dev/R/nomnom/data.json")
unflatten <- function(json) {
@domenic
domenic / unabashed-monadic-promises.md
Last active December 17, 2015 15:29
Unabashed Monadic Promises on top of Q-Like Promises

Unabashed Monadic Promises on top of Q-Like Promises

Using the terminology from Mark Miller's "The Paradox of Partial Parametricity", this gist shows how you can build unabashed monadic promises on top of Q-like promises.

Problem Statement

Given:

Q: Ref<t> → Promise<t>
class Mapping {
// Subclasses define at least @@iterator().
@@iterator() {
throw TypeError("abstract operation")
}
// Mutable subclasses also define set() and delete().
set(key, value) {
throw TypeError("mapping is not mutable");
}
@polotek
polotek / event_emitter_example.js
Last active December 17, 2015 22:59
Simple example of a node event emitter
// Grab the EventEmitter constructor. events is a core node module.
var Emitter = require('events').EventEmitter;
// Our internal function will generate random numbers
function randomInt(limit) {
return Math.ceil( Math.random() * limit );
}
module.exports = function(limit) {
if(!(limit && limit > 0)) {
@Protonk
Protonk / notquitefusion.js
Last active December 18, 2015 10:29
Adjust the smoothing parameter w/ the sensor slider value.
var five = require("./lib/johnny-five.js"),
board, slider;
board = new five.Board();
board.on("ready", function() {
var accel = new five.Accelerometer({
pins: [ "I0", "I1" ],
freq: 100