Skip to content

Instantly share code, notes, and snippets.

App.FeatureView = SC.View.extend({
classNames: ['feature'],
templateName: 'feature',
createdAt: function () {
return $.timeago.distanceInWords(this.getPath('content.createdAt'));
}.property('createdAt').cacheable()
});
def calculate_total(products)
Array(products).inject(0) { |sum, product| sum + product.price }
end
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
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!
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 = []
def transactions
responses.inject([]) do |transactions, response|
transactions << response.transactions
end.sort_by &:timestamp
end
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}"];
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')
})
#!/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
#!/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