Skip to content

Instantly share code, notes, and snippets.

View apangeajwrubel's full-sized avatar

Jim Wrubel apangeajwrubel

View GitHub Profile
@apangeajwrubel
apangeajwrubel / gist:3398045
Created August 19, 2012 22:03
fixing students with orphaned attempts
# first one
item_step = Item.find(829).item_steps.first
bad_item_step_id = 829
Attempt.where("attemptable_type = 'ItemStep' and attemptable_id = ?", bad_item_step_id).each do |a|
a.attemptable_id = item_step.id
if a.correct
a.response_id = item_step.correct_responses.first.id
else
a.response_id = item_step.incorrect_responses.first.id
end
@jwrubel
jwrubel / gist:1986681
Created March 6, 2012 14:57
swf_tag syntax in slim (should work for haml too)
= swf_tag "name_of_swf", \
options={:dom_id => "dom_element", \
:size => "320x240", :version => "10.1", \
:flashvars => {"a" => "test"}, \
:params => {"menu" => "false", "wmode" => "direct"}, \
:attributes => { "align" => "left", "class" => "flash_css_class" }}
div(id="dom_element")
@metaskills
metaskills / wait_until.rb
Last active October 20, 2023 13:08
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@d2s
d2s / content.html
Created January 5, 2011 20:29
Clickable div overlay
<div class="project img_project1">
<div class="link-div">
<object type="img/gif">
<a class="lightbox" href="http://example.com/">
<img src="/images/spacer.gif" alt="" width="100%" height="100%" />
</a>
</object>
</div>
<h5>Project 1</h5>
<p>Description of the project.</p>
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')