This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Point(x, y) { | |
if (arguments.length === 1 && typeof x === 'string') { | |
return x.slice(1, -1) | |
.split('}{') | |
.map(function(tuple) { | |
return tuple.split(',', 2).map(parseFloat) | |
}) | |
.reduce(function(point, coords) { | |
point.x += coords[0]; | |
point.y += coords[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = new Angle().radians(Math.PI * 3 / 4), | |
b = new Angle().degrees(135); | |
var c = new Angle(a + b); | |
Math.sin(a); | |
Math.cos(b); | |
a.add(new Angle().degrees(30)); | |
b.add(Math.PI); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
EventEmitter is usable as constructor and as mixin. | |
*/ | |
function EventEmitter() {} | |
// this does the trick | |
EventEmitter.prototype = EventEmitter; | |
EventEmitter.addListener = function(type, listener) { | |
this.listeners(type, true).push(listener); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<title>has touch?</title> | |
<h1>Has this device touch? </h1> | |
<script> | |
var isTouch = (function(){ | |
try{ | |
var event = document.createEvent("TouchEvent"); // Should throw an error if not supported | |
return !!event.initTouchEvent; // Check for existance of initialization method | |
}catch(error){ | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BaseObject = { | |
create: function create() { | |
var instance = Object.create(this); | |
instance._construct.apply(instance, arguments); | |
return instance; | |
}, | |
extend: function extend(properties, propertyDescriptors) { | |
propertyDescriptors = propertyDescriptors || {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Fixes file names for downloads from jil.org. | |
jil.org delivers downloaded files with file names in e-mail header format. The | |
fix_filename function from this module can decode such file names. | |
When this module is executed as main program, all file names passed as program | |
arguments are renamed properly: |
NewerOlder