Skip to content

Instantly share code, notes, and snippets.

View subtleGradient's full-sized avatar
👋

Tom Aylott subtleGradient

👋
View GitHub Profile
/**
* by Dmitry A. Soshnikov
*/
Object.defineProperty(Object, "essence", {
value: function objectEssence(value) {
var essence = {kind: Object.prototype.toString.call(value).slice(8, -1)};
// use Object(value) just for shortness, it's less effective
// than typeof value == "object" && value !== null || typeof value == "function"
essence[value === Object(value) ? "object" : "primitive"] = true;
var playhead, art, keyframe1, keyframe2;
addEvent('load', function(){
art = new ART(400, 400).inject(document.body);
playhead = new ART.Rectangle(200, 200)
.inject(art)
.fill('#00F');
//media as attribute
%script{:src => "/Theme/HUD/screen.css", :media => "screen and (lsd-theme: HUD)"}
//media to deliver combined stylesheet
button
+inline-block
@media (lsd-theme: HUD)
button
&:icon
/**
* This library defines a new style ES objects
* which support delegation based mixins. A mixin
* chain is stored in the internal [[Mixin]] property.
*
* Used features: Harmony (ES6) proxies.
*
* Tested in FF4 beta.
*
* @author Dmitry A. Soshnikov <[email protected]>
/*
asynctask.m -- sample code that shows how to implement asynchronous stdin, stdout & stderr streams for processing data with NSTask
compile with:
gcc -Wall -O3 -x objective-c -fobjc-exceptions -framework Foundation -o asynctask asynctask.m
./asynctask
./asynctask > asynctask-output.txt 2>&1
@bryanforbes
bryanforbes / gist:663298
Created November 4, 2010 22:06
This is an attempt to explain what is happening behind the scenes with event handlers in ES3 and why IE leaks in one case and not another.
// Global Object
// (§10.2.1)
// GO.scope_chain = [GO]
// GO._cache = _cache
var _cache = {};
// Declaration (§13.2):
// CWanonfunc.[[Scope]] = GO.scope_chain.slice(0) (§13.2 step 7)
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@sstephenson
sstephenson / back_forward.js
Created December 13, 2010 21:55
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@subtleGradient
subtleGradient / Declarative Component Mapping Syntax Options.textile
Created December 30, 2010 01:36
What is the best syntax to use for declarative markup in HTML5?

Declarative Component Mapping Syntax Options

Language / Prior Art ‘Valid’ HTML HTML Mapping Example Example with Args
‘Valid’ CSS Selectable CSS Mapping CSS Select CSS Selector w Args
JavaScript MooTools Multiple instance Separate Args new Foo(element); new Bar(element) new Foo(element, {a:"a", bB:"b B", c:{c:1}}); new Bar(element, {d:"d"})
HTML attr Dojo <1.6 NO
1 Element per instance
JSON.stringify(SheetParser.CSS.translate("a a(b), 1px 3em, gradient(from(rgba(1, 1, 1, 3)), to(#ccc)"))
"[["a",{"a":"b"}],[{"unit":"px","number":"1"},{"unit":"em","number":"3"}],"gradient",{"from":{"rgba":["1","1","1","3"]}},{"to":"#ccc"}]"