This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
******************************************************************************** | |
Using script: | |
require 'rubygems' | |
require 'selenium-webdriver' | |
$DEBUG = true | |
Selenium::WebDriver.for(:firefox).quit | |
Results below: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Schema.define(:version => 20110613211706) do | |
create_table "answers", :force => true do |t| | |
t.text "answer" | |
t.integer "question_id" | |
end | |
create_table "questions", :force => true do |t| | |
t.string "question" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%a.btn-sec.offer-button{:href => "#", :class => [offers_enabled_class, (is_linked && "linked" || "unlinked")], 'attr-deal_id' => deal.id, 'attr-logged_in' => "#{logged_in?}", 'attr-title' => deal.title, 'attr-merchant' => deal.merchant.name, 'attr-expires' => deal.end_at.strftime('%b %-d, %Y'), 'attr-image_url' => ugasset_url(deal.image)} | |
= (is_linked ? 'Unlink from Card' : 'Link to Card') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest' | |
require 'murmurhash3' #gem install murmurhash3 | |
require 'trollop' | |
class BloomFilter | |
def initialize(size) | |
@size = size.to_i || 2_000_000 | |
@num_inputs = 0 | |
@bloom_filter = Array.new(size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path(File.join(File.dirname(__FILE__), "bloom.rb")) | |
class String | |
def each_char_with_index | |
0.upto(size - 1) do |index| | |
yield(self[index..index], index) | |
end | |
end | |
def remove_char_at(index) | |
return self[1..-1] if index == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-debug' | |
def multi_split(str, tokens) | |
results = [] | |
buffer = "" | |
maybe_token = false | |
temp_str = "" | |
str.each_char do |c| | |
if maybe_token | |
if is_token?(temp_str + c, tokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multi_split2(str, delims) | |
multi(str, delims, []) | |
end | |
def multi(str, delims, sum) | |
return sum if str.empty? | |
temp, token = "", "" | |
while !is_token_prefix? str[0], delims | |
token << str[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_token_prefix?(prefix, tokens) | |
tokens.each { |token| return true if token.start_with?(prefix) } | |
false | |
end | |
def is_token?(str, tokens) | |
tokens.each { |token| return true if token == str } | |
false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-debug' | |
class LineCounter | |
def initialize | |
@count = 0 | |
@commenting = false | |
end | |
def lines_of_code(file) | |
@count = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_in_hash(hash, target, args={}, keys='ROOT') | |
find_key = (args[:find_key] == true) | |
hash.each do |key, value| | |
find_target = find_key ? key.to_s : value | |
if find_target == target | |
keys = "#{keys} -> '#{key}' => #{target}" | |
puts keys | |
keys = "" | |
end |
OlderNewer