Travis Roberts travisr

View user_spec.rb
1 2 3 4 5 6 7
describe 'it should regenerate the guid if one already exists' do
FactoryGirl.create(:user, guid: '123456')
SecureRandom.stub(:hex).and_return('123456', '456789')
user = User.new(email: 'john@email.com', total_budget: 250.00)
user.save
expect(user.reload.guid).to eq(6)
end
View 1_model.rb
1 2 3 4 5 6 7 8
class Account < ActiveRecord::Base
attr_accessible :text_amount
attr_accessor :text_amount
 
before_validation do
self.amount = text_amount.gsub(/[^\d\.]/, '').to_f
end
end
View gist:6441348
1 2 3 4 5 6 7 8 9 10
tell application "Safari"
activate
delay 2
tell application "System Events"
tell process "Safari"
set frontmost to true
click menu item 2 of menu 1 of menu item "iPad Simulator" of menu 1 of menu bar item "Develop" of menu bar 1
end tell
end tell
end tell
View gist:5879661
1 2 3 4 5 6 7 8 9 10
$.fn.serializeObject = ->
o = {}
a = @serializeArray()
$.each a, ->
if (o[this.name])
if (!o[this.name].push)
o[this.name] = [o[this.name]]
 
o[this.name].push(this.value || '')
else
View gist:5685549
1 2 3 4 5 6 7 8 9 10
Processing AccountController#index (for 70.88.5.237 at 2013-05-31 07:09:51) [GET]
 
ApiException (Bad Gateway (502): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Bad Gateway</title>
</head><body>
<h1>Bad Gateway</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
</p>
View problem11.rb
1 2 3 4 5 6 7 8 9 10
numbers = [
['08', '02', '22', '97', '38', '15', '00', '40', '00', '75', '04', '05', '07', '78', '52', '12', '50', '77', '91', '08'],
['49', '49', '99', '40', '17', '81', '18', '57', '60', '87', '17', '40', '98', '43', '69', '48', '04', '56', '62', '00'],
['81', '49', '31', '73', '55', '79', '14', '29', '93', '71', '40', '67', '53', '88', '30', '03', '49', '13', '36', '65'],
['52', '70', '95', '23', '04', '60', '11', '42', '69', '24', '68', '56', '01', '32', '56', '71', '37', '02', '36', '91'],
['22', '31', '16', '71', '51', '67', '63', '89', '41', '92', '36', '54', '22', '40', '40', '28', '66', '33', '13', '80'],
['24', '47', '32', '60', '99', '03', '45', '02', '44', '75', '33', '53', '78', '36', '84', '20', '35', '17', '12', '50'],
['32', '98', '81', '28', '64', '23', '67', '10', '26', '38', '40', '67', '59', '54', '70', '66', '18', '38', '64', '70'],
['67', '26', '20', '68', '02', '62', '12', '20', '95', '63', '94', '39', '63', '08', '40', '91', '66', '49', '94', '21'],
['24', '55', '58',
View gist:4947593
1 2 3
User.stub(:find).and_return(user)
# OR #
User.stub(:find => user)
View rake.rb
1 2 3 4 5 6 7 8 9 10
require "rake"
 
shared_context "rake" do
let(:rake) { Rake::Application.new }
let(:task_name) { self.class.top_level_description }
let(:task_path) { "lib/tasks/#{task_name.split(":").first}" }
subject { rake[task_name] }
 
def loaded_files_excluding_current_rake_file
$".reject {|file| file == Rails.root.join("#{task_path}.rake").to_s }
View ship.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
TARGET=$1
: ${TARGET:="master"}
 
echo "=> git checkout ${TARGET}"
git checkout ${TARGET}
 
echo "=> git merge ${CURRENT}"
View hack.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
TARGET=$1
: ${TARGET:="master"}
 
echo "=> git checkout ${TARGET}"
git checkout ${TARGET}
 
echo "=> git pull origin ${TARGET}"
Something went wrong with that request. Please try again.