Skip to content

Instantly share code, notes, and snippets.

View milosdakic's full-sized avatar

Milos Dakic milosdakic

View GitHub Profile
# An example Jekyll Liquid tag. Utilizes the new plugin system.
#
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there.
# 2. In anyone of your pages, you can use the 'render_time' liquid tag like so:
# {% render_time Page generated at: %}
module Jekyll
class RenderTimeTag < Liquid::Tag
def initialize(tag_name, text, tokens)
@naholyr
naholyr / enableMultipleViewRoots.js
Created May 27, 2011 15:23
Allow multiple views roots in Express.js
// Usage:
// var express = require('express')
// require('enableMultipleViewRoots')(express)
module.exports = function(express) {
var old = express.view.lookup;
function lookup(view, options) {
// If root is an array of paths, let's try each path until we find the view
if (options.root instanceof Array) {
@milosdakic
milosdakic / namespace.js
Created December 12, 2011 03:54
JavaScript namespacing with Underscore
function namespace(string, obj) {
var current = window,
names = string.split('.'),
name;
while(name = names.shift()) {
current[name] = current[name] || {};
current = current[name];
}
@tomerd
tomerd / gauge.js
Last active April 21, 2024 21:08
google style gauges using javascript d3.js
function Gauge(placeholderName, configuration)
{
this.placeholderName = placeholderName;
var self = this; // for internal d3 functions
this.configure = function(configuration)
{
this.config = configuration;
@jwchang0206
jwchang0206 / server.js
Created February 8, 2012 12:33 — forked from ageldama/server.js
node v0.6 cluster + express.js
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
@bruth
bruth / gist:2865951
Last active November 19, 2017 20:11
Backbone Sync Queue
# Reference Backbone ajax function
_ajax = Backbone.ajax
requestQueue = []
requestPending = false
sendRequest = (options, promise, trigger=true) ->
options = _.clone options
if trigger
requestPending = true
@webfella
webfella / bootyshaker.coffee
Created August 21, 2012 12:14
Wobble function
# small function to use with jquery to shake an element.
shakeThatBooty = (e, amount, counter) ->
speed = 50
if (counter == 0) then return
e.animate
right: amount
, speed, ->
e.animate
right: -amount
@juliocesar
juliocesar / gist:4108378
Created November 19, 2012 00:45
Backbone.Model in localStorage
# Storing a Backbone.Model in localStorage
# ========================================
#
# You can then use localStorage as a collection. For an usage example, see
# https://github.com/juliocesar/factory/blob/master/coffeescripts/factory.coffee#L149
# This largely Just Worked™ for my needs. YMMV!
class MyModel extends Backbone.Model
sync: (method, model, rest...) ->
@paulinm
paulinm / gauge.js
Last active August 21, 2019 07:30 — forked from tomerd/gauge.js
A Google-style Gauge Implemented using D3 with Optional Min, Max, and Running Average Tracking
function Gauge(placeholderName, configuration)
{
this.placeholderName = placeholderName;
var minValue = null;
var maxValue = null;
var avgValue = null;
var avgCounter = 0;
var self = this; // for internal d3 functions
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing