Skip to content

Instantly share code, notes, and snippets.

@uhop
uhop / minified.js
Last active December 15, 2015 18:19
UMD header
/* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))})
(["module", "../main"], function(module, unit){
// module's code
});
/* UMD.require */ (typeof define=="function"&&require||function(d,f,m){m={module:module,require:require};f.apply(null,d.map(function(n){return m[n]||require(n)}))})
(["module", "../main"], function(module, unit){
// module's code
});
@uhop
uhop / gist:3351030
Created August 14, 2012 17:29 — forked from idan/gist:3135754
A Sample Post

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a major heading

If you peek at it with a web inspector, you'll see that it is a second-level heading. You can use first level headings, but they'll look just like the second level ones, and the gods of the HTML5 outlining algorithm will frown upon you.

@uhop
uhop / perf.js
Created August 14, 2012 15:48
Benchmarking creating an object
// Creating different objects.
var z = 5;
this.group(
"Primitives",
function Nothing(x) { return; },
function Null(x) { return null; },
function Boolean(x) { return true; },
function Number(x) { return 1; },
@uhop
uhop / gist:3259255
Created August 4, 2012 18:41
Bezier Shaders & Vector openGL rendering
@uhop
uhop / perf.js
Created August 12, 2011 09:01
dojo/array.js: indexOf
// dojo/array.js: forEach
/*
LEGEND:
old --- the previous implementation from Dojo trunk.
nnn --- the new implementation.
ech --- https://github.com/kriszyp/each
NOTES:
All functions are copied below together with all necessary utility functions.
*/
@uhop
uhop / perf.js
Created August 12, 2011 07:35
dojo/array.js: forEach
// dojo/array.js: forEach
/*
LEGEND:
old --- the previous implementation from Dojo trunk.
nnn --- the new implementation.
ech --- https://github.com/kriszyp/each
NOTES:
All functions are copied below together with all necessary utility functions.
All tests are performed with and without the context (thisObject).
@uhop
uhop / perf.js
Created August 12, 2011 00:44
Compare +=, -=, = +, and = -, with 9.
// Compare +=, -=, = +, and = -, with 9.
var a = 1, p9 = 9, m9 = -9;
this.group(
"inc/dec by 9 (var)",
function eq_minus_v9() { a = a - m9; return a; },
function eq_plus_v9() { a = a + p9; return a; },
function minus_eq_v9() { a -= m9; return a; },
function plus_eq_v9() { a += p9; return a; }
@uhop
uhop / perf.js
Created August 12, 2011 00:28
Compare ++, --, +=, -=, = +, and = -, with different values.
// Compare ++, --, +=, -=, = +, and = -, with different values.
var a = 1, p1 = 1, m1 = -1, p9 = 9, m9 = -9;
this.group(
"inc/dec by 1",
function baseline() { return a; },
function prefix_plus_plus() { ++a; return a; },
function postfix_plus_plus() { a++; return a; },
function prefix_minus_minus() { --a; return a; },
@uhop
uhop / perf.js
Created August 11, 2011 23:33
What's faster: ?:, Math.min(), or Math.max()?
// What's faster: "if", ?:, Math.min(), or Math.max()?
this.group(
"Min/max comparison",
function baseline(){
// this one does nothing, it is here only for comparison
var a = Math.random(), b = Math.random(),
c = a;
},
function if_stmt(){
@uhop
uhop / admin.py
Created March 14, 2011 00:31
Adding Dojo's rich editor to Django's Admin.
# Example how to add rich editor capabilities to your models in admin.
from django.contrib.admin import site, ModelAdmin
import models
# we define our resources to add to admin pages
class CommonMedia:
js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',