View fruits-components.html
<dom-module id="fruit-component">
<p>color: {{color}}</p>
<button on-tap="setColor">set color in light dom</button>
is: 'fruit-component',
View config--initializers--rails4_to_rails3_downgradability.rb
# Without this fix, downgrading from Rails 4 to Rails 3 causes session cookies to blow up.
# The way the flash is stored in the session changed in a backwards-incompatible way.
if Rails::VERSION::MAJOR == 3
module ActionDispatch
class Flash
def call(env)
if (session = env['rack.session']) && (flash = session['flash'])
View whoami.rb'/home/whoami.txt', 'w') {|file| file.write(`whoami`)}
View add_attrs_to_obj.rb
def add_attrs(obj, attrs)
attrs.each do |k,v|
obj.send("#{k}=", v)
return obj
View suppress_ruby_output.rb
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen('/dev/null', 'w'))
View braintree.rb
if Rails.env.production?
Braintree::Configuration.environment = Rails.env.staging? ? :sandbox : :production
Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"]
Braintree::Configuration.public_key = ENV["braintree_public_key"]
Braintree::Configuration.private_key = ENV["braintree_private_key"]
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = "<super secret>"
Braintree::Configuration.public_key = "<super secret>"
Braintree::Configuration.private_key = "<super secret>"
View titleize.rb
def titleize(str) {|s| (x = s.strip.downcase)[0].upcase + x[1..-1]}.join(' ')
View rails_route_recognizer.rb
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# ``
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize
View deserialize.js
function deserialize(string) {
var array = string.split('&');
var hash = {};
$.each(array, function(i, val) {
var data = val.split('=');
hash[data[0]] = decodeURIComponent(data[1]);
return hash;

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.


This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.