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 get_memory_usage | |
>> `ps -o rss= -p #{Process.pid}`.to_i | |
>> end | |
=> nil | |
>> | |
?> before = get_memory_usage | |
=> 20296 | |
>> | |
?> n.times {MethodRegexObject.new} |
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 PercentileFinder | |
attr_accessor :action, :controller, :limit, :calls, :dataset | |
def initialize(action, controller, limit = 1000) | |
self.action = action | |
self.controller = controller | |
self.limit = limit | |
end | |
def find(percentile_looking_for = 0.95) |
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 'rspec/autorun' | |
require 'benchmark' | |
describe "polish notation" do | |
it "do a trivial case" do | |
polish_parser(:+, 1, 1).first.should == 2 | |
reverse_stack_polish_parser(:+, 1, 1).first.should == 2 | |
pm_polish_parser(:+, 1, 1).first.should == 2 | |
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
require 'test_helper' | |
class MerchantAccountTest < ActiveSupport::TestCase | |
setup do | |
@merchant_account = FactoryGirl.create(:merchant_account) | |
end | |
should "fetch authorized orders" do | |
@order = FactoryGirl.create(:order, venue: @merchant_account.venue) | |
credit_card_hash = { |
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 SpeakersController < ApplicationController | |
load_and_authorize_resource :event | |
load_and_authorize_resource :speaker, through: [:event], shallow: true #the array here could only be the single symbol but since i almost always wind up adding more, i just start with it | |
before_filter :new_speaker, :only => [:new, :create] | |
respond_to :html | |
def index | |
end | |
def show |
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
source 'https://rubygems.org' | |
ruby "2.0.0" | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
... |
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.Router.map(function() { | |
this.resource('tables', function() { | |
this.resource('table', {path: ':table_id'}); | |
}); | |
}); |
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
$("#my_button_id").click(function () { | |
call_my_other_js; | |
});) | |
$("#my_button_id").click(function () { | |
$("form#formID").submit(); | |
});) | |
$("#my_button_id").click(function () { | |
do_thing_3_for_kicks; | |
});) |
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 "xpath" # XPath is a separate gem now | |
module Cucumber | |
module Rails | |
module CapybaraSelectDatesAndTimes | |
def select_date (date, options = {}) | |
date = Date.parse(date) | |
# lookup id prefix by label | |
id_prefix = id_prefix_for(options[:label]) |
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 EquipmentItem | |
attr_accessor :task_items, equipment_hauls | |
def current_location | |
last_task = task_items.sort_by{|a| a.end_time }.last | |
last_haul = equipment_hauls.last | |
if last_task && last_haul | |
if last_task.end_time > last_haul.performed_at | |
last_task.timesheet.job | |
else |