Skip to content

Instantly share code, notes, and snippets.

View fearphage's full-sized avatar
⌨️
Cache rules everything around me.

Phred Lane fearphage

⌨️
Cache rules everything around me.
View GitHub Profile
@fearphage
fearphage / README.md
Last active October 18, 2022 20:19
$.whenAll jQuery extension

$.whenAll is an extension to jQuery's $.when. The main difference is $.when stops when it receives the first rejected promise. This extension treats all successes and failures as progress events. After all the promises have completed, the global promise is resolved if there were no errors. Otherwise the global promise is rejected.

Sameple #1

$.whenAll($.get('http://github.com'), $.get('good luck with this one'))
  .then(
    // success callback
    function(request) {}
    // failure callback - called once at the end
 ,function() {}
@fearphage
fearphage / base.view.js
Created December 7, 2012 22:55
Make Backbone Your Own.
define(function () {
"use strict";
var templates = {};
return Backbone.View.extend({
template: '<div></div>',
_templatize: function () {
if ( !templates[ this.template ] ) {
templates[ this.template ] = _.template( this.template );
@fearphage
fearphage / fabfile.py
Created December 5, 2012 15:43 — forked from kmpm/fabfile.py
Fabric deployment of Node.js on Ubuntu
from __future__ import with_statement
from fabric.api import env
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib.project import upload_project
import ubuntu
import protobuf
@fearphage
fearphage / mp3player.js
Created October 24, 2012 20:39 — forked from TooTallNate/mp3player.js
node.js command line MP3 player in 9 lines of code!
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(process.argv[2])
.pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});
@fearphage
fearphage / README.md
Created September 20, 2012 14:45
Can you make this faster?

The goal is to add N new elements to the DOM as quickly and as painlessly as possible.

I have access to jQuery and found the code below to be faster than the following:

$(parentElement)
  .append(Array(1001).join(template))
;
@fearphage
fearphage / README.md
Created September 19, 2012 23:47 — forked from melanke/README.md
JQuery RedditLoader - smart and customizable reddit content loader

JQuery RedditLoader 2.1.0 Download

About

Load images, Imgur Albuns, Youtube videos, and Articles (beta) of Reddit links, loading only when the previous content was loaded

###Livedemo http://redditmobile.blogspot.com.br

###Dependencies

  • JQuery
@fearphage
fearphage / data.json
Created September 13, 2012 16:53
doT.js template example
{
"settings": {
"foo": "low"
,"bar": "high"
,"baz": "low"
}
}
var ViewFactory = (function() {
function ViewFactory(pubSub) {
this.pubSub = pubSub;
this.registry = {};
this.registry['factory'] = this;
}
ViewFactory.prototype.register = function(key, value) {
return this.registry[key] = value;
@fearphage
fearphage / octocat.svg
Created May 18, 2012 07:02 — forked from johan/octocat.svg
Github octocat avatar, SVG format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fearphage
fearphage / gist:2630780
Created May 7, 2012 22:01
Screenshot selection to Dropbox and copy URL
#!/bin/bash
# Settings
url=http://dl.dropbox.com/u/2400/scrot
dir=~/Dropbox/Public/scrot
filename=selection_$(date +%Y-%m-%d_%H%M%S).png
# End Settings
scrot -s "$dir/$filename"