Skip to content

Instantly share code, notes, and snippets.

View suweller's full-sized avatar
🕺

Steven Weller suweller

🕺
View GitHub Profile
require "matrix"
#First, you construct an adjacency matrix. An adjacency matrix is just a matrix of what is linking to what.
#[0, 1, 1, 1, 1, 0, 1]
#[1, 0, 0, 0, 0, 0, 0]
#[1, 1, 0, 0, 0, 0, 0]
#[0, 1, 1, 0, 1, 0, 0]
#[1, 0, 1, 1, 0, 1, 0]
#[1, 0, 0, 0, 1, 0, 0]
@thijsc
thijsc / gist:1391107
Created November 24, 2011 11:08
Select item from chosen js select with Capybara and Selenium
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end
@suweller
suweller / data-toggle.coffee
Last active June 29, 2017 18:46
Show or hide elements in a form using data-show or data-hide
class window.DataToggle
get: (str) ->
$("##{str}")
ids: (type, e) ->
$(e).attr("data-#{type}").split(' ')
constructor: ->
_self = @
_self.data_show(_self, $(e).parent()) for e in $('[data-show]')
_self.data_hide(_self, $(e).parent()) for e in $('[data-hide]')
@suweller
suweller / inherit_from_matcher.rb
Created June 26, 2012 13:50
Rspec - Inheritance matcher
RSpec::Matchers.define :inherit_from do |superclass|
match do |klass|
klass.class.ancestors.include? superclass
end
failure_message_for_should do |klass|
"expected #{klass.class.name} to inherit from #{superclass}"
end
failure_message_for_should_not do |klass|