application.scss.erb - use <%= asset_path 'background.jpg' %>
on config/environments/production.rb
/* | |
natcompare.js -- Perform 'natural order' comparisons of strings in JavaScript. | |
Copyright (C) 2005 by SCK-CEN (Belgian Nucleair Research Centre) | |
Written by Kristof Coomans <kristof[dot]coomans[at]sckcen[dot]be> | |
Based on the Java version by Pierre-Luc Paour, of which this is more or less a straight conversion. | |
Copyright (C) 2003 by Pierre-Luc Paour <natorder@paour.com> | |
The Java version was based on the C version by Martin Pool. | |
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au> |
# | |
# Calls a function that is defined as a String | |
# | |
# 'ws.extranett.subdomain_for'.call('argument1', 'argument2') | |
# | |
# Will call the function subdomain_for bound on the object extranett | |
# with arguments 'argument1' and 'argument2' | |
# | |
String::call = (args...) -> |
h1 = {:key => {a: 1, b: 2, c: {a: 1, b: 2}}} | |
h2 = {:key => {c: {a:'a', c: 'c'}, d: 4}} | |
recursive_merge = lambda do |k, old, new| | |
(new.respond_to?(:merge) && old.respond_to?(:merge)) ? new.merge(old, &recursive_merge) : new | |
end | |
puts h1.merge(h2, &recursive_merge) | |
# => {:key=>{:a=>1, :b=>2, :c=>{:a=>"a", :b=>2, :c=>"c"}, :d=>4}} |
module RuleBook | |
def RuleBook.add_rules(object, instance_or_class, rules) | |
instance_or_class = instance_or_class.to_s.downcase.strip.to_sym | |
raise(ArgumentError, "'instance_or_class' must equal :instance or :class") unless [:instance, :class].include?(instance_or_class) | |
raise(ArgumentError, "'rules' must be a Hash") unless rules.is_a?(Hash) | |
unless object.instance_variable_get(:@_rulebook_initiated) # Class instance variable. Not class variable. Not instance variable. Is confusing. | |
object.instance_variable_set(:@_rulebook_initiated, true) | |
object.instance_variable_set(:@_rulebook, {:instance=>{}, :class=>{}}) # @_rulebook is actually two rulebooks, instance and class | |
end |
# put this file in spec/javascripts/support directory | |
require 'barista' | |
require 'logger' | |
require File.join(Rails.root, 'config/initializers/barista_config') | |
Barista.configure do |c| | |
c.env = 'test' | |
c.logger = Logger.new(STDOUT) | |
c.logger.level = Logger::INFO |
#!/bin/bash | |
# created by Josh Frye | joshfng@gmail.com | |
# Check if the user has sudo privileges. | |
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; } | |
# Update the system before going any further | |
echo "Updating system..." | |
sudo apt-get update >> install.log && sudo apt-get -y upgrade >> ~/install.log | |
echo "done.." |
// Use the animate.css animations | |
function animate(element, effect, delay, callback) { | |
// Set a delay if needed | |
var animation = setTimeout(function () { | |
// Add the animation effect with classes | |
$(element).addClass('animate ' + effect); | |
// Check if the elemenr has been hidden to start with to prevent FOUC | |
if ($(element).css('visibility') == 'hidden') { | |
// If it has, show it (after the class has been added) |
framework 'Cocoa' | |
class NSColor | |
def toCGColor | |
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace) | |
## approach #1 | |
# components = Array.new(4){Pointer.new(:double)} | |
# color_RGB.getRed(components[0], | |
# green: components[1], | |
# blue: components[2], |
How to test Backbone Model and Collections webapp using nodeJs and vows.
I used the Todos exemple of Backbone + RequireJS : https://github.com/addyosmani/todomvc/tree/master/todo-example/backbone+require
I added on each requireJs module an amdefine definition : https://github.com/jrburke/amdefine
In fact it's just one line to add before define([...], function(){...});
if (typeof define !== 'function') { var define = (require('amdefine'))(module); }