Skip to content

Instantly share code, notes, and snippets.

View willbailey's full-sized avatar

Will Bailey willbailey

  • Facebook
  • San Francisco, CA
View GitHub Profile
@willbailey
willbailey / index.js
Created December 14, 2011 19:16
making property observation intrinsic to classes
'use strict';
var B = typeof exports !== 'undefined' ? exports : {};
// prefix for internal property state
var __PROP__ = '__PROP__';
// default constructor used in setting up prototype chain
var ctor = function() {};
B.extend = function(__super__, proto) {
Feedback on Home Alpha/Beta:
----------------------------
package im.wsb.example
import java.lang.reflect.Field;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.AbsListView;
import android.widget.ListView;
@willbailey
willbailey / twelvedays.c
Created December 9, 2012 04:56
Twelve Days of Christmas
#include <stdio.h>
int main(int argc, char *argv[]) {
char *days[] = {"first", "second", "third", "fourth", "fifth", "sixth",
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"};
char *gifts[] = {"a partridge in a pear tree", "two turtle doves",
"three french hens", "four calling birds", "***** five golden rings *****",
"six geese a laying", "seven swans a swimming", "eight maids a milking",
@willbailey
willbailey / flocking.coffee
Created September 16, 2012 16:30
flocking algorithm
###
CoffeeScript port of http://processing.org/learning/topics/flocking.html
###
window.FlockingSketch = class FlockingSketch
# setup the environment and start the draw loop
constructor: ->
@setup()
@draw()
randomColor = function() {
var i = 0, val = null, out = '';
while (i < 3) {
val = Math.round(Math.random() * 255).toString(16);
if (val.length < 2) {
val = '0' + val;
}
out +=val;
i++;
}
@willbailey
willbailey / example.html
Created April 10, 2012 21:59
transformation library
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Index</title>
<script type="text/javascript" charset="utf-8" src="https://raw.github.com/gist/2354906/aefea983f6ca0b0e22656726a74250608397ab83/transformations.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener('DOMContentLoaded', function() {
// creating a transformable element
@willbailey
willbailey / gist:1302885
Created October 21, 2011 01:31
connections
// ### Events
// Event mixin copied from Backbone
var Events = {
bind: function(evt, callback) {
var events = this._events = this._events || {};
var callbacks = events[evt] = events[evt] || [];
callbacks.push(callback);
},
unbind: function(evt, callback) {
@willbailey
willbailey / WBVector.h
Created October 6, 2011 07:51
WBVector
@interface WBVector : NSObject <NSCopying> {
CGFloat _x;
CGFloat _y;
CGFloat _z;
}
@property (nonatomic) CGFloat x;
@property (nonatomic) CGFloat y;
@property (nonatomic) CGFloat z;
@willbailey
willbailey / gist:1210437
Created September 12, 2011 01:54
springy
var extend = function(dest) {
var sources = Array.prototype.slice.call(arguments, 1), source, key;
for (var i = 0, l = sources.length; i < l; i++) {
source = sources[i];
for (key in source) {
if (source.hasOwnProperty(key)) {
dest[key] = source[key];
}
}
}