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 / SpringChain.java
Last active August 29, 2015 14:06
SpringChain.java
/*
* This file provided by Facebook is for non-commercial testing and evaluation purposes only.
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@willbailey
willbailey / gist:56d2b94c5e9d0a9cf40c
Created September 12, 2014 17:01
SpringChain.java
package com.facebook.rebound;
import java.util.concurrent.CopyOnWriteArrayList;
public class SpringChain implements SpringListener {
private final SpringSystem mSpringSystem;
private final CopyOnWriteArrayList<SpringListener> mListeners;
private final CopyOnWriteArrayList<Spring> mSprings;
private static final SpringConfig ATTACHMENT_SPRING = SpringConfig.fromOrigamiTensionAndFriction(70, 10);
@willbailey
willbailey / hamburgerButton.js
Created August 3, 2014 15:39
Hamburger Button Animation with Rebound JS
(function() {
var hb = {};
var deg2rad = rebound.MathUtil.degreesToRadians;
var mapVal = rebound.MathUtil.mapValueInRange;
hb.HamburgerButton = function(container, size, color, cornerRadius) {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.padding = size * 0.1;
(function() {
var hb = {};
var deg2rad = rebound.MathUtil.degreesToRadians;
var mapVal = rebound.MathUtil.mapValueInRange;
hb.HamburgerButton = function(container, size, color, cornerRadius) {
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.padding = size * 0.1;
package com.facebook.rebound.origami;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
Feedback on Home Alpha/Beta:
----------------------------
@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