Skip to content

Instantly share code, notes, and snippets.

Avatar

Rick Waldron rwaldron

View GitHub Profile
@andrew
andrew / xbox.js
Created Dec 29, 2012
Xbox Controller in Node.js (wip)
View xbox.js
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 Jan 7, 2013
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.
View index.html
<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 Jul 18, 2017
JavaScript: call invo-cursion?
View call-invo-cursion.js
// 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 Dec 15, 2015
LLJS compiling to asm.js
View input.ljs
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 Dec 15, 2015
ES6 needs a timeout - I reserve the right to change my mind about this
View es6-timeout.md

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'"").

View legis.R
# 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 Dec 17, 2015
Unabashed Monadic Promises on top of Q-Like Promises
View unabashed-monadic-promises.md

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>
View Mapping.js
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 Dec 17, 2015
Simple example of a node event emitter
View event_emitter_example.js
// 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 Dec 18, 2015
Adjust the smoothing parameter w/ the sensor slider value.
View notquitefusion.js
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
You can’t perform that action at this time.