Skip to content

Instantly share code, notes, and snippets.

@garrows
garrows / ProxyEventer.js
Last active December 24, 2015 11:09
Simple proxy and event listener
MyObject.prototype.on = function (eventName, callback) {
if (this.eventListeners[eventName] == undefined) {
this.eventListeners[eventName] = [];
}
if (typeof callback == "function") {
this.eventListeners[eventName].push(callback);
} else {
throw "can not subscribe with a non function callback";
}
}
@garrows
garrows / gulpfile.js
Last active August 29, 2015 13:57
Gulp watch with LiveReload
var gulp = require('gulp'),
compress = require('gulp-uglify'),
stylus = require('gulp-stylus'),
concat = require('gulp-concat'),
browserify = require('gulp-browserify'),
livereload = require('gulp-livereload');
var liveReloadServer = livereload();
gulp.task('styles', function() {
@garrows
garrows / debuggingGaffa.md
Last active August 29, 2015 13:57
Debugging Gaffa

Debugging Gaffa

Inspect element. Click it. The selected element is now $0 in the javascript console

$0.viewModel
$0.viewModel.enabled
$0.viewModel.enabled.binding
$0.viewModel.enabled.value
@garrows
garrows / SetupBluetooth.ino
Last active December 17, 2022 12:30
Configure HC-06 bluetooth chip to work with the Johnny-Five javascript robotics library
/*
This is for configuring the hc-06 bluetooth chip to work with Johnny-Five javascript robotics library.
Might also work with the hc-05.
Author: Glen Arrowsmith (@garrows)
*/
#define ROBOT_NAME "RandomBot"
### Keybase proof
I hereby claim:
* I am garrows on github.
* I am garrows (https://keybase.io/garrows) on keybase.
* I have a public key whose fingerprint is 0A4E 7772 7EB5 DBA9 B1F7 1DE8 5565 4B63 238A B2F9
To claim this, I am signing this object:
@garrows
garrows / Sumo.ino
Created July 16, 2014 13:22
Sumo Bot Code
#include <ZumoBuzzer.h>
#include <ZumoMotors.h>
#include <Pushbutton.h>
#include <QTRSensors.h>
#include <ZumoReflectanceSensorArray.h>
#define LED 13
#define DISTANCE_SENSOR A1
// this might need to be tuned for different lighting conditions, surfaces, etc.
@garrows
garrows / Sumo.js
Created July 16, 2014 14:48
Sumo.js
var five = require("johnny-five");
board = new five.Board({
// port: "/dev/rfcomm1"
port: "/dev/tty.NodeBot-DevB"
});
board.on("ready", function() {
(new five.Led(13)).strobe(500);
@garrows
garrows / index.html
Last active August 29, 2015 14:06
Window Pane Slider
<html>
<head>
<title>Slider Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<style>
body {
margin: 0px;
padding: 0px;
}
@garrows
garrows / index.js
Created May 4, 2015 14:21
Middleware Stacker
// In the express generated example, this is /routes/index.js
var express = require('express');
var router = express.Router();
var TheService = function() {};
TheService.prototype = {
getTitle: function(req, res, next) {
console.log('getTitle');
res.title = 'Express';
@garrows
garrows / style.css
Last active August 29, 2015 14:20
Atom.io random cat background
.panes::after {
content: "";
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
pointer-events: none;
background: url("http://thecatapi.com/api/images/get?format=src&type=jpg,png");
background-size: cover;