Skip to content

Instantly share code, notes, and snippets.

View jeromeetienne's full-sized avatar

Jerome Etienne jeromeetienne

View GitHub Profile
@jeromeetienne
jeromeetienne / defineQGetterSetter.js
Created May 27, 2012 08:10
queable getter setter
/**
* by default __defineGetter__ support only one function. Same for __defineSetter
* This is a annoying limitation. This little library declares 2 functions
* Object.__defineQGetter__ and Object.__defineQGetter__.
* They behave the same as their native sibling but support multiple functions.
* Those functions are called in the same order they got registered.
*
* (I have no idea of the reasoning behind this limitation to one function. It seems
* useless to me. This remind me of onclick of the DOM instead of a proper .addEventListener)
*/
@jeromeetienne
jeromeetienne / dieassert.js
Created May 10, 2012 08:32
a console.assert which actually stop the execution
/**
* A console.assert which actually stop the exectution.
* default console.assert() is a plain display, such as console.log() or console.error();
* It doesnt stop the execution like assert() is meant to do. This is a little code to
* "workaround this limitation" :) thanks @jensarp
*
* Usage:
* console.assert(foo === bar); // Will throw if not equal
* console.assert(foo === bar, 'Dude, foo does not equal bar'); // Will throw with custom error message
*
@jeromeetienne
jeromeetienne / 1-tablemarkup.html
Created August 1, 2011 02:08 — forked from paulirish/1-tablemarkup.html
whitespace use for html/css readability
<!-- formatting fun #1: tables! -->
<!-- use whitespace to mimic the layout you want. leave off optional end tags for readability -->
<table>
<caption>Selector engines, parse direction</caption>
<thead>
<tr><th>Left to right <th>Right to left
<tbody>
<tr><td>Mootools <td>Sizzle
@jeromeetienne
jeromeetienne / webgl_geometry_cube2.html
Created July 26, 2011 13:15
Basic Example of a Cube with Three.js
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>three.js canvas - geometry - cube</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css">
body {
background-color: #f0f0f0;
margin: 0px;
;(function(exports){
/**
* Insert http://jsconsole.org in the page
*/
exports.jsconsoleInsert = function(id){
if( !!navigator.userAgent.match(/iPod/) || !!navigator.userAgent.match(/iPad/) ){
document.write(unescape("%3Cscript src='http://jsconsole.com/remote.js?"+id+"' type='text/javascript'%3E%3C/script%3E"));
}
}
})(this);
// attempts to get flash/session accessible in any template
// - this middleware function fails and keep producing 'Error: req.flash() requires sessions'
// - this middleware has been place *after* session middleware in the stack
app.use(function(req,res, next){
console.log("flash middleware")
res.locals({
session : req.session,
flash : req.flash()
});
});
@jeromeetienne
jeromeetienne / gist:979055
Created May 18, 2011 17:23 — forked from paulirish/gist:839879
requestAnimFrame() shim.
// see http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// shim layer with setTimeout fallback
(function(){
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
<html>
<body>
<p>
sdfsdf
</p>
</body>
</html>
@jeromeetienne
jeromeetienne / webgl detection
Created April 13, 2011 14:02
how to detect webgl (tested to work in chrome10 and ff4)
try {
var webGlSupport = !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
}catch(e){
var webGlSupport = false;
}
console.log("webglSupport", webGlSupport);