Skip to content

Instantly share code, notes, and snippets.

/**
* Simple localStorage with Cookie Fallback
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
* store('my_key');
@qustosh
qustosh / backbone.super.js
Created February 21, 2013 18:13
backbone extend with super
// Extend Backbone Classes with a 'super' function to execute a method of an instance's superclass
_.each(['Collection', 'Model', 'View', 'Router'], function(className) {
Backbone[className].prototype.super = function(funcName) {
var parentPrototype = this.constructor.__super__;
if (parentPrototype && typeof parentPrototype[funcName] === 'function') {
return this.constructor.__super__[funcName].apply(this, _.rest(arguments));
}
};
});
@qustosh
qustosh / gist:5294401
Created April 2, 2013 17:42 — forked from mkuklis/gist:5294248
auto curry in JavaScript
function toArray(args) {
return [].slice.call(args);
}
function autocurry(fn) {
var len = fn.length;
var args = [];
return function next() {
args = args.concat(toArray(arguments));
return (args.length >= len) ?
@qustosh
qustosh / ipNumericValue.scala
Created April 2, 2013 17:46 — forked from berngp/ipNumericValue.scala
IPv4 to Numeric Value
"192.168.1.1".split('.').reverse.map(_.toLong).zipWithIndex.map(t => (t._1 << (t._2 * 8L))).reduce(_ | _)
@qustosh
qustosh / src#bar.js
Created April 2, 2013 17:47 — forked from jbuck/src#bar.js
RequireJS example code
define(["util/baz"], function(Baz) {
return { baz: new Baz() };
});
@qustosh
qustosh / gist:5294461
Created April 2, 2013 17:47
HTML: starter
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/main.css">
<title></title>
@qustosh
qustosh / .htaccess
Created April 2, 2013 17:49
Better .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.(gif|jpe?g|png|js|css|ico))
RewriteRule ^(.*)$ /index.php/$1 [L]
function withDelay(delay, tasks){
var iterator = -1;
setTimeout( function(){
Iterator++;
tasks[iterator]();
@qustosh
qustosh / Laravel
Created January 6, 2014 16:24 — forked from kbirmhrjn/Laravel Resources
List of Laravel Resources:
1. laravel.com/docs
2. laravel.io
3. laravel-tricks.com
4. laracasts.com
5. laravel-recipes.com
6. cheats.jesse-obrien.ca
7. laravelweekly.com
8. http://fideloper.com
9. http://jasonlewis.me
10. http://culttt.com/search/?q=laravel
@qustosh
qustosh / gist:8451755
Created January 16, 2014 08:51 — forked from ElmahdiMahmoud/gist:8451662
js: hide a DIV when the user clicks outside of it
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});