Skip to content

Instantly share code, notes, and snippets.

View HenrikJoreteg's full-sized avatar

Henrik Joreteg HenrikJoreteg

View GitHub Profile
@HenrikJoreteg
HenrikJoreteg / simple_function_queue_runner.js
Created July 7, 2010 18:06
Simple function queue runner. Just pass me an array of functions and I'll execute them one by one at the given interval.
// Simple function queue runner. Just pass me an array of functions and I'll
// execute them one by one at the given interval.
run_queue = function (funcs, step, speed) {
step = step || 0;
speed = speed || 500;
funcs = funcs || [];
if (step < funcs.length) {
// execute function
funcs[step]();
@HenrikJoreteg
HenrikJoreteg / Terrible yo mama jokes, nerdified
Created July 28, 2010 04:28
A collection of nerdified, yo mama jokes. Please contribute ;)
Your mama's so fat that all her shell commands run in verbose mode. - @HenrikJoreteg
Your momma's so fat she returns an http 413 error: Request entity too large! - @boringgeek
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
@HenrikJoreteg
HenrikJoreteg / afterMyPatch.js
Created November 6, 2010 15:53
Demonstrating the point of my recent pull request to backbone: https://github.com/documentcloud/backbone/pull/59
var View = Backbone.View.extend({
initialize: function () {
this.handleBindings();
},
contentBindings: {
title: '.title'
},
classBindings: {
@HenrikJoreteg
HenrikJoreteg / Unselectable.html
Created December 7, 2010 16:53
For single page apps with lots of dnd, disable selectable, turn on for exceptions.
<!DOCTYPE html>
<html>
<head>
<title>Some single page app</title>
<style>
/*
Here's the magic, we take the unselectable attribute and make it more powerful
in browsers that support it see here for more:
http://help.dottoro.com/lcrlukea.php#-webkit-user-select
*/
@HenrikJoreteg
HenrikJoreteg / straight_include.py
Created December 15, 2010 16:06
A Django Template tag for including files that you don't want to parse as templates
"""
Straight Include template tag by @HenrikJoreteg
Django templates don't give us any way to escape template tags.
So if you ever need to include client side templates for ICanHaz.js (or anything else that
may confuse django's templating engine) You can is this little snippet.
Just use it as you would a normal {% include %} tag. It just won't process the included text.
@HenrikJoreteg
HenrikJoreteg / serverAndBrowserModule.js
Created February 18, 2011 19:47
Another approach to doing re-usable backbone models
if (typeof require == 'undefined') {
var exports = window,
server = false;
} else {
var Backbone = require('./backbone'),
_ = require('underscore')._,
server = true;
}
exports.TeamModel = Backbone.Model.extend()
=text_shadow($color, $x, $y, $blur)
:text-shadow = $color $x $y #{$blur}px
=box_shadow($color, $x, $y, $blur)
:-webkit-box-shadow = $color $x $y #{$blur}px
:-moz-box-shadow = $color $x $y #{$blur}px
:box-shadow = $color $x $y #{$blur}px
=inner_shadow($color, $x, $y, $blur)
:box-shadow = inset $color $x $y #{$blur}px
@HenrikJoreteg
HenrikJoreteg / postageApp.js
Created April 28, 2011 16:23
Example of using sending mail with PostageApp using fermata in node.js
var fermata = require('fermata'),
uuid = require('node-uuid');
var apiKey = 'YOUR_API_KEY'; // should probably be imported from an external keys file
var site = fermata.api({url: 'https://api.postageapp.com/v.1.0'});
exports.send = function (details, cb) {
site['send_message.json'].post(details, cb);
};
@HenrikJoreteg
HenrikJoreteg / nodeconf_2011.md
Created May 6, 2011 18:50 — forked from guybrush/nodeconf_2011.md
a list of slides from nodeconf 2011