Skip to content

Instantly share code, notes, and snippets.

View xnzacc's full-sized avatar

Zac Z. xnzacc

  • UK
View GitHub Profile
@xnzacc
xnzacc / gist:1229941
Created September 20, 2011 18:47
R function for calculating A/B testing sample size from Ian Clarke(of 37signals)'s
# ref: http://37signals.com/svn/posts/3004-ab-testing-tech-note-determining-sample-size
#
# p1 = Variable A results. e.g. conversion rate from test A
# p2 = Variable B results
# power = chance of false negative (A power of 0.80 means that there is an 80% chance that if there was an effect, we would detect it )
# sig.level = chance of false positive (0.05 = 5%)
power.prop.test(p1=0.1, p2=0.11, power=0.8, alternative='two.sided', sig.level=0.05)
# Output will be a number signifying minimal sample size that meets the above criteria
@xnzacc
xnzacc / Guardfile
Created August 29, 2011 20:16
Guard file for running test unit / spec files
# More info at https://github.com/guard/guard#readme
# Instructions:
# 1) gem install guard guard-shell
# 2) run guard in root
# run test with 'redgreen' gem(for colour) if available otherwise with plain ruby
guard "shell" do
watch(%r{^(.+)/.+\.rb$}) do |m|
if File.exists?("#{m[1]}/#{m[1]}_test.rb")
def within_list(css_class)
css_selector = css_class.gsub(/ /, '.') #stack the css classes for selection
list = current_dom.at("ol.#{css_selector}") || current_dom.at("ul.#{css_selector}") # Could add an opt param to the method to make this explicit - for now we don't care
assert_not_nil(list, "Expected to find a ul or li tag matching the css class '#{css_class}'")
yield list
end
Then /^I should see the text "(.*)" in the "(.*)" list$/ do |text, css_class| #"
within_list(css_class) do |list|
matching_list_items = list.search("li").select{ |li| strip_html_tags_from(li.inner_html) =~ escape_text_for_regexp(text) }