Skip to content

Instantly share code, notes, and snippets.

View tgaff's full-sized avatar

tgaff tgaff

View GitHub Profile
@tgaff
tgaff / gist:5094609
Last active October 20, 2016 02:55
become and become_true matchers --- use instead of Capybara's wait_until
# Matchers that will wait for a value to change.
# Ex. expect { email.reload.delivered? }.to become_true
RSpec::Matchers.define :become_true do
match do |block|
begin
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = block.call
value
end
@tgaff
tgaff / sauce.rake
Created August 15, 2013 16:10
sauce labs jasmine rake task
namespace :sauce do
desc "Execute Jasmine tests on Sauce Labs with RSpec results, i.e. `rake sauce:jasmine['Windows 2008',iexplore,9]`"
task :jasmine, [:os, :browser, :browser_version] => 'jasmine:require' do |t, args|
RSpec::Core::RakeTask.new(:jasmine_continuous_integration_runner) do |t|
t.rspec_opts = ["--colour", "--format", "documentation"]
t.verbose = true
t.ruby_opts = ["-r #{File.expand_path(File.join(::Rails.root, 'config', 'environment'))}"]
t.pattern = [File.expand_path(File.join('script', 'jasmine_sauce_runner.rb'))]
end
@tgaff
tgaff / gist:6394903
Created August 30, 2013 22:25
~/.gitconfig
[core]
excludesfile = /Users/VRDeveloper/.gitignore_global
pager = less -FXRS -x2
[alias]
st = status
di = diff
co = checkout
ci = commit
br = branch
sta = stash
@tgaff
tgaff / setup.sh
Last active August 29, 2015 13:56
aws
sudo apt-get -q -y install git phantomjs libxslt-dev libxml2-dev libpq-dev libmagickwand-dev imagemagick nodejs postgresql redis-server
# don't prompt
sudo rm ~/.ssh/config
echo StrictHostKeyChecking=no >> ~/.ssh/config
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
@tgaff
tgaff / gist:e0ddd054f202f9a0ebb2
Last active August 29, 2015 14:21
capybara tricks

Frequently one might want to make an assertion inside a within block, but it's not obvious how to do so.

This doesn't work (within doesn't have block attributes):

within(level_selector) do |this|
  click_button 'edit'
  expect(this).to have_content(header_text) # sadly this = nil
end
@tgaff
tgaff / gist:b0252c1ee8fc4ad17ae1
Created July 2, 2015 20:15
capybara driver for chrome with mods for chromedriver issue 1081 to allow viewing pdf
Capybara.register_driver :chrome_custom do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => {
"excludeSwitches" => [ "test-type", "ignore-certificate-errors" ],
}
)
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => caps)
end
@tgaff
tgaff / music_seeds.rb
Created September 23, 2015 20:35
music seeds for student music apps
a1 = Artist.new(name: 'Jay-z',
description: 'Shawn Corey Carter (born December 4, 1969),[2] known by his stage name Jay Z (formerly Jay-Z),[3][4][5] is an American rapper, record producer, and entrepreneur. He is one of the most financially successful hip hop artists and entrepreneurs in America.',
image_url: 'http://www.loscontroladores.com/wp-content/uploads/2015/08/jay-z-live-2015-700x519.jpg'
)
a1.songs.build(title: "Run This Town",
length: '4:27',
genre: 'rap'
)
@tgaff
tgaff / looping.rb
Last active November 5, 2015 17:55
ruby looping
arr = [ 2, 4, 6, 1, 7, 9]
arr.each do |element|
puts "I'm #{element}."
end
arr.each_with_index do |element, index|
puts "#{element} has index #{index}"
end
@tgaff
tgaff / list.md
Last active March 1, 2016 17:13
ideas for holiday study

racing game X3

freecodecamp.com

  • do Basic JavaScript (5h)
    • you can skip 38-41 (regular expressions) if you want
  • do Object Oriented and Functional Programming (2h)
  • JSON APIs and Ajax
    • 1-2 is up to what we've done now
  • You can do the others as well but they'll introduce a lot of new stuff.
{
filename: "sample/comma.txt",
delimeter: "comma",
headers: [:last_name, :first_name, :gender, :favorite_color, :date_of_birth]
},
{
filename: "sample/pipe.txt",
delimeter: "pipe",
headers: [:last_name, :first_name, :middle_initial, :gender, :favorite_color, :date_of_birth]
},