(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |
import Leap, sys, OSC | |
class Listener(Leap.Listener): | |
def __init__(self): | |
super(Listener, self).__init__() | |
client = OSC.OSCClient() | |
client.connect(('127.0.0.1', 9000)) | |
self.client = client |
/** | |
* Converts an RGB color value to HSL. Conversion formula | |
* adapted from http://en.wikipedia.org/wiki/HSL_color_space. | |
* Assumes r, g, and b are contained in the set [0, 255] and | |
* returns h, s, and l in the set [0, 1]. | |
* | |
* @param Number r The red color value | |
* @param Number g The green color value | |
* @param Number b The blue color value | |
* @return Array The HSL representation |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | |
<style> | |
body { | |
margin: 0px; | |
overflow: hidden; | |
} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body style="background:#fff;"> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"></script> | |
<canvas id="canvas"></canvas> | |
<script id="jsbin-javascript"> |
var writeTextToFile = function(text, filePath) { | |
var t = [NSString stringWithFormat:@"%@", text], | |
f = [NSString stringWithFormat:@"%@", filePath]; | |
return [t writeToFile:f atomically:true encoding:NSUTF8StringEncoding error:nil]; | |
} | |
var readTextFromFile = function(filePath) { | |
var fileManager = [NSFileManager defaultManager]; | |
if([fileManager fileExistsAtPath:filePath]) { | |
return [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; |
/** | |
* @param {object} scope - Object that all bound data will be attached to. | |
*/ | |
function twoWayBind(scope) { | |
// a list of all bindings used in the DOM | |
// @example | |
// { 'person.name': [<input type="text" data-bind="person.name"/>] } | |
var bindings = {}; | |
// each bindings old value to be compared for changes |
// svgPathToCommands('M10,10 l 5,7 C-5,7.2,.3-16,24,10 z'); | |
// | |
// produces: | |
// | |
// [ { marker: "M", values: [ 10, 10 ] }, | |
// { marker: "l", values: [ 5, 7 ] }, | |
// { marker: "C", values: [ -5, 7.2, 0.3, -16, 24, 10 ] }, | |
// { marker: "z", values: [ ] } ] | |
// | |
// commandsToSvgPath(svgPathToCommands('M10,10 l 5,7 C-5,7.2,.3-16,24,10 z')) |