Skip to content

Instantly share code, notes, and snippets.

Julian Aubourg jaubourg

Block or report user

Report or block jaubourg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jaubourg
jaubourg / InlineWorker.js
Last active Oct 13, 2015
Create a Web Worker from a function, not a file
View InlineWorker.js
// Web Workers can be built from data URLs!
// See http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dom-worker
// Chrome doesn't seem to support this yet but FF does
// So how about a helper to create a Web Worker from a function
var InlineWorker = (function() {
var r_func = /^\s*function\s*\(.*?\)\s*\{|\}\s*$/g;
@jaubourg
jaubourg / Events.js
Created Nov 23, 2011 — forked from DaveStein/Events.js
Singleton wrapper around $.Callbacks to emulate Backbone events
View Events.js
var Event = (function( $ ) {
var cache = {},
slice = [].slice,
fake = {
remove: $.noop,
fireWith: $.noop
};
function get( ev, createIfNeeded ) {
@jaubourg
jaubourg / gist:1138463
Created Aug 10, 2011
jQuery boilerplate suggestion
View gist:1138463
// remember to change every instance of "pluginName" to the name of your plugin!
// the semicolon at the beginning is there on purpose in order to protect the integrity of your scripts when
// mixed with incomplete objects, arrays, etc.
;(function( $ ) {
// plugin's default options
// this is private property and is accessible only from inside the plugin
var defaults = {
propertyName : 'value'
};
@jaubourg
jaubourg / gist:948434
Created Apr 29, 2011 — forked from danheberden/gist:948429
making $.when() always report one arg
View gist:948434
var getName = (function() {
var cache; // private cache
// gets assigned to getName
return function() {
// return the cache if it's valid or
return cache || $.ajax({
url: 'srv/echo',
View gist:947722
// Create type-related methods:
// isArray, isBoolean, isDate, isFunction, isObject, isNumber, isRegExp, isString and type
jQuery.isFunction = jQuery.noop;
jQuery.each( "Array Boolean Date Function Object Number RegExp String ".split(" "), function( lName, name ) {
lName = class2type[ "[object " + name + "]" ] = name.toLowerCase();
jQuery[ name ? ( "is" + name ) : "type" ] = nativeTypeTests[ name ] || function( value ) {
value = value == null ?
String( value ) :
class2type[ toString.call( value ) ] || "object";
return name ? ( value === lName ) : value;
View php-json-heredoc.php
<?php
## Nav data, as a JSON heredoc. Much less verbose than PHP arrays!
$navs = json_decode(<<<JSON
{
"mlb": {
"title_link": "http://stats.boston.com/mlb/scoreboard.asp",
"nav": [
{ "title": "Full Schedule", "url": "http://stats.boston.com/mlb/teamreports.asp?tm=02&report=schedule" },
{ "title": "Statistics", "url": "http://stats.boston.com/mlb/teamreports.asp?yr=2009&tm=2&btnGo=Go&report=stats" },
View typeOf.js
(function($){
var toString = Object.prototype.toString;
var class2type = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
"[object Array]": "array",
You can’t perform that action at this time.