This file contains hidden or 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
| I18n.backend.class.send(:include, I18n::Backend::Fallbacks) | |
| I18n.default_locale = :au | |
| I18n.fallbacks[:au] = [:au, :en] | |
| I18n.fallbacks[:gb] = [:gb, :au, :en] | |
| Time.zone_default = Time.send(:get_zone, 'Sydney') |
This file contains hidden or 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
| ["2011-10-20 23:23:59 +1000", "2011-10-20 23:23:59 -1000", "2010-08-14 05:17:01 +1000", "2011-11-18 11:29:30 +1100", "2011-09-25 16:17:44 +1000"].sort # => ["2010-08-14 05:17:01 +1000", "2011-09-25 16:17:44 +1000", "2011-10-20 23:23:59 +1000", "2011-10-20 23:23:59 -1000", "2011-11-18 11:29:30 +1100"] |
This file contains hidden or 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
| attr_accessor :cat, :dog | |
| attr_accessor :banana, :apple | |
| attr_encrypted :cat, :dog | |
| attr_encrypted :banana |
This file contains hidden or 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
| var api = new EverydayHero({event: '3284'}); | |
| api.top_ten('individual', callback); | |
| api.top_ten('team', callback); | |
| api.total(callback); |
This file contains hidden or 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
| (function($) { | |
| var ItemView = function(fundraiser) { | |
| this.fundraiser = fundraiser; | |
| this.template = _.template(document.getElementById('widget-item').innerHTML); | |
| this.render = function() { | |
| return this.template(this.fundraiser); | |
| } | |
| return this; |
This file contains hidden or 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
| curl -H 'Content-Type: application/soap+xml;charset=UTF-8;' -d '<?xml version="1.0" encoding="UTF-8"?> | |
| <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
| <soapenv:Header> | |
| <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext"> | |
| <wsse:UsernameToken> | |
| <wsse:Username>temandotest</wsse:Username> | |
| <wsse:Password>password</wsse:Password> | |
| </wsse:UsernameToken> | |
| </wsse:Security> | |
| </soapenv:Header> <soapenv:Body> |
This file contains hidden or 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
| user system total real | |
| mocha: 0.000000 0.000000 0.000000 (0.000277) | |
| simple_delegator: 0.000000 0.000000 0.000000 (0.000024) |
This file contains hidden or 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 OrdersController < ApplicationController | |
| respond_to :json | |
| attr_accessor :order, :model | |
| helper_method :order | |
| protected :order | |
| def create | |
| @order = model.create params[:order] | |
| respond_with @order |
This file contains hidden or 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
| # Inspired by "Mocking with MiniTest::Mock and SimpleDelegator" it would be | |
| # great to have a library with no dependancies that gives you the behaviour | |
| # talked about in the blog post without learning a new API. | |
| # http://tatey.com/2012/02/07/mocking-with-minitest-mock-and-simple-delegator/ | |
| # Without an argument, SimpleMock behaves identically to MiniTest::Mock.new | |
| mock = SimpleMock.new | |
| mock.expect :valid?, false | |
| mock.valid? # => false | |
| mock.save # => NoMethodError |
This file contains hidden or 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 'benchmark' | |
| require 'delegate' | |
| require 'mocha' | |
| require 'simple_mock' | |
| Benchmark.bm(10000) do |x| | |
| x.report :mocha do | |
| array = [1] | |
| array.expects(:push).with(2).returns([1, 2]) | |
| array.push(2) |