Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@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();
@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') {
@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

@andrespagella
andrespagella / Custom.css
Created October 29, 2012 15:22
IR_Dark_Monokai
/**********************************************/
/*
/* IR_Dark_Monokai
/* Designed and developed by Andres Pagella (@mapagella)
/* http://www.andrespagella.com/customising-chrome-devtools
/*
/* Based on Ben Truyman's IR_Black
/* which is...
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
@disnet
disnet / scheme.sjs
Created October 8, 2012 19:02
start of scheme in sweet.js (modified from http://pastebin.com/0nPBg8LY)
macro sexp {
case () => {
;
}
case ($p) => {
$p
}
case ($x $y) => {
$x($y);
}
@jacaetevha
jacaetevha / gist:3795784
Created September 27, 2012 19:02
Smalltalk syntax on a postcard
exampleWithNumber: x
"A method that illustrates every part of Smalltalk method syntax
except primitives. It has unary, binary, and keyword messages,
declares arguments and temporaries, accesses a global variable
(but not and instance variable), uses literals (array, character,
symbol, string, integer, float), uses the pseudo variables
true false, nil, self, and super, and has sequence, assignment,
return and cascade. It has both zero argument and one argument blocks."
let defaults = {},
overrides = {};
function foo(bar, options) {
// YUI
options = Y.merge(defaults, options, overrides);
// Underscore
options = _.extend({}, defaults, options, overrides);
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@cowboy
cowboy / object-forin-forown.js
Created June 5, 2012 17:34
JavaScript: Object#forIn and Object#forOwn
/*
* Object#forIn, Object#forOwn
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
Object.defineProperties(Object.prototype, {
forIn: {
@adnbr
adnbr / max7219-basic.c
Last active November 23, 2023 23:09
Simple AVR code for using a MAX7219 7-segment display driver
/* MAX7219 Interaction Code
* ---------------------------
* For more information see
* http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
*
* 668 bytes - ATmega168 - 16MHz
*/
// 16MHz clock
#define F_CPU 16000000UL