This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.FeatureView = SC.View.extend({ | |
classNames: ['feature'], | |
templateName: 'feature', | |
createdAt: function () { | |
return $.timeago.distanceInWords(this.getPath('content.createdAt')); | |
}.property('createdAt').cacheable() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_total(products) | |
Array(products).inject(0) { |sum, product| sum + product.price } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def flash_messages | |
flash.inject([]) do |array, (level, message)| | |
array << content_tag(:div, flash_content(message), class: "alert-message #{level} fade in", data: {alert: 'alert'}) | |
end.join.html_safe | |
end | |
private | |
def flash_content message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HeroPage < AR::Base | |
def online_total! | |
save! | |
end | |
end | |
class HeroPageTest < ActiveSupport::TestCase | |
test "#total_in_aud includes the registration total" do | |
mock_hero_page = Class.new SimpleDelegator do | |
def save! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class PayPalExpress::TransactionSearchTest < ActiveSupport::TestCase | |
test "#search returns a collection of transactions" do | |
account = MiniTest::Mock.new | |
period = MiniTest::Mock.new | |
requester = MiniTest::Mock.new | |
params = {} | |
params['ACK'] = 'Success' | |
params.default = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transactions | |
responses.inject([]) do |transactions, response| | |
transactions << response.transactions | |
end.sort_by &:timestamp | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define nodejs::version($version) { | |
exec { | |
"Donwload ${version}": | |
command => "wget http://nodejs.org/dist/v${version}/node-v${version}.tar | |
cwd => "/tmp", | |
require => Package['curl']; | |
"Untar ${version}": | |
command => "tar -zxf node-v${version}", | |
cwd => "/tmp" | |
require => Exec["Download ${version}"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember.Application.create() | |
App.store = DS.Store.create({ | |
revision: 4, | |
adapter: DS.RESTAdapter.create({bulkCommit: false}) | |
}); | |
App.User = DS.Model.extend({ | |
name: DS.attr('string'), | |
email: DS.attr('string') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if ! [ `which brew` > /dev/null ]; then | |
echo "Installing Homebrew" >&2 | |
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" | |
fi | |
PACKAGES=( redis memcached rabbitmq mysql imagemagick ) | |
for PACKAGE in ${PACKAGES[@]} | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
fork do | |
Process.setsid | |
exit if fork | |
if File.exists?('/path/to/pid.pid') | |
puts 'Pidfile already exists, not starting.' | |
exit 1 | |
end |