(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# 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) |
// 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) { |
function namespace(string, obj) { | |
var current = window, | |
names = string.split('.'), | |
name; | |
while(name = names.shift()) { | |
current[name] = current[name] || {}; | |
current = current[name]; | |
} |
function Gauge(placeholderName, configuration) | |
{ | |
this.placeholderName = placeholderName; | |
var self = this; // for internal d3 functions | |
this.configure = function(configuration) | |
{ | |
this.config = configuration; | |
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(); | |
} |
# Reference Backbone ajax function | |
_ajax = Backbone.ajax | |
requestQueue = [] | |
requestPending = false | |
sendRequest = (options, promise, trigger=true) -> | |
options = _.clone options | |
if trigger | |
requestPending = true |
# 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 |
# 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...) -> |
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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.