Skip to content

Instantly share code, notes, and snippets.

View Ebtoulson's full-sized avatar

Eric Toulson Ebtoulson

  • Atlanta, Georgia
View GitHub Profile
!define loag {http://local.apartmentguide.com/apartments/Georgia/Norcross/search/}
#!| script|
!|scenario |User opens advanced search for Norcross GA and checks refinements using|selector|and views the |displayed_name|in the refinements list|
|windowMaximize |
|user opens |${loag} |
|user clicks|css=@selector |
|user waits |3000 |
|user |verifies |that |css=p.refinement_list|shows text |@displayed_name
# If you were curious how to do it with lambdas,
# I think this way makes the method definition look ugly but w/e
def method(arr, fn = ->(e){ "" })
arr[:no_key]
rescue => e
fn.call(e)
end
method([])
# => ""
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
1.9.3-p392 :001 > class Test
1.9.3-p392 :002?> def self.wtf
1.9.3-p392 :003?> "WHAT DA FUCK"
1.9.3-p392 :004?> end
1.9.3-p392 :005?>
1.9.3-p392 :006 > self.singleton_class.send(:alias_method, :wtf_mate, :wtf)
1.9.3-p392 :007?> end
=> #<Class:Test>
1.9.3-p392 :008 > Test.wtf
=> "WHAT DA FUCK"
class HealthCheck
class << self
def check!
status = {
service: service_working?,
db: db_connected?
}
[status.values.all?, status]
rescue e
[false, :exception => e.message]
require 'json'
require 'cgi'
server = "localhost:8098"
bucket = "portal_development_tokens"
request = `curl http://#{server}/buckets/#{bucket}/keys?keys=true`
keys = JSON.parse(request)["keys"]
keys.each do |key|
def char_occurrence str
str.split('').chunk{|x| x}.map do |letter, chunk|
[chunk.count, letter]
end.join
end
#second format
def char_occurrence str
str.split('').chunk{|x| x}.map do |letter, chunk|
chunk.join.capitalize
class House
LYRICS = [
"This is the house that Jack built.",
"This is the malt that lay in the house that Jack built.",
"This is the rat that ate the malt that lay in the house that Jack built.",
"This is the cat that killed the rat that ate the malt that lay in the house that Jack built.",
"This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.",
"This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.",
"This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.",
"This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jac
class Bottles
attr_reader :where, :substance
def initialize(substance='of beer', where='on the wall')
@substance = substance
@where = where
end
def verse bottle_number
next_bottle_number = bottle_number - 1
guard :minitest do
watch(%r{^test/(.*)\/?_test(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[2]}_test.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
end