Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
(ns mc-map.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
(enable-console-print!)
(def app-state (atom {:mapOptions #js {:center (google.maps.LatLng. -34.397 150.644)
:zoom 8}}))
(defn map-view [app owner]
function move(positions, speed) {
joints.forEach(function(part, i) {
legs[part].to(positions[i], speed);
});
}
var inits = [
{ pin: 10, id: "rf", startAt: 91 },
{ pin: 11, id: "rk", startAt: 92 },
{ pin: 12, id: "rh", startAt: 98 },
@rwaldron
rwaldron / a.js
Last active August 29, 2015 13:56
Servo.animateGroup({
cuePoints: [0.125, 0.5, 0.625, 1.0],
duration: 2000,
members: [
{ servo: lf.coxa, deg: [82, dir === "fwd" ? 130 : 82, 103, 103] },
{ servo: lf.femur, deg: [111, dir === "fwd" ? 0 : 111, 70, 70] },
{ servo: lf.tibia, deg: [103, 103, 77, 77] },
{ servo: lb.coxa, deg: [98, dir === "fwd" ? 98 : 130, 77, 77] },
{ servo: lb.femur, deg: [111, dir === "fwd" ? 111 : 0, 70, 70] },
{ servo: lb.tibia, deg: [103, 103, 77, 77] },
var five = require("../lib/johnny-five.js");
/**
* PVector is a slightly-ported version of
* Processing.js's PVector.
*/
var PVector = require("./pvector.js").PVector;
/**
* To run this program you must first install
* libusb and OpenNI... Good luck with that.
*
@rwaldron
rwaldron / string-trimmers.md
Created April 16, 2014 15:11
ES7 Proposal: String.prototype.trimLeft(), String.prototype.trimRight()

String.prototype.trimRight()

This function interprets a string value as a sequence of code points, as described in 6.1.4.

The following steps are taken:

  1. Let O be CheckObjectCoercible(this value).
  2. Let S be ToString(O).
  3. ReturnIfAbrupt(S).
  4. Let T be a String value that is a copy of S with trailing white space removed. The definition of white space is the union of WhiteSpace and )LineTerminator. When determining whether a Unicode code point is in Unicode general category “Zs”, code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in 6.1.4.

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

/*global chrome*/
var EventEmitter = require('./events.js').EventEmitter;
var util = require('./util.js');
function SerialPort(port, options) {
var self = this;
var id;
var bytesToRead = options.buffersize || 1;

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

#!/bin/bash
# Initialize the port for output:
echo -n "3" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio3/direction
# Turn the on-board Led on:
echo "1" > /sys/class/gpio/gpio3/value
# Now turn it off:
var Leap = require("leapjs");
var five = require("../lib/johnny-five.js");
var board = new five.Board();
var scale = five.Fn.scale;
var max = 0;
var min = 0;
function toDegrees(value) {
var degrees = value > 0 ?
scale(value, max, min, 0, 90) :