Skip to content

Instantly share code, notes, and snippets.

def calculate_rank_for(target, query)
rank = nil
each_google_result_page(query, 6) do |page, page_index|
each_google_result(page) do |result, result_index|
return ((page_index * 10) + result_index) if result.text.include?(target)
end
end
end
def show_rank_for(target, query)
#!/usr/bin/env ruby
directory = "/Users/omarqureshi/test/"
files = Dir.glob("#{directory}**/*")
out = files.inject({}) do |mem, file|
mem[directory] ||= []
remainder = file.gsub(directory, "")
after_split = remainder.split("/")
if after_split.size == 1
# Description:
# Spits out Look my strong gif
#
# Commands:
# look my strong
module.exports = (robot) ->
robot.hear /look my strong/i, (msg) ->
msg.send "http://cdn.gifbay.com/2013/09/look_my_strong-86403.gif"
1.9.3p448 :009 > h = Hash.new(3)
=> {}
1.9.3p448 :010 > h['a']
=> 3
➜ ~ irb
1.9.3p448 :001 > herp = 'a'
=> "a"
1.9.3p448 :002 > derp = 'b'
=> "b"
1.9.3p448 :003 > {herp: 'bar', derp: 'baz'}
=> {:herp=>"bar", :derp=>"baz"}
1.9.3p448 :004 > {herp.to_sym => 'bar', derp.to_sym => 'baz'}
=> {:a=>"bar", :b=>"baz"}
➜ ~ irb
2.0.0p247 :001 > $:
=> ["/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-darwin12.3.0", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0/x86_64-darwin12.3.0", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0", "/Users/omarqureshi/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.3.0"]
<!--[if lte IE 8]>
<div class="completed-session" ng-switch-when="session">
<![endif]-->
<!--[if gt IE 8]><!-->
<article class="completed-session" ng-switch-when="session">
<!--<![endif]-->
function anonymous(s, k) {
var l, fn, p;
if(s === null || s === undefined) return s;
l=s;
s=((k&&k.hasOwnProperty("user"))?k:s)["user"];
if (s && s.then) {
if (!("$$v" in s)) {
p=s;
p.$$v = undefined;
p.then(function(v) {p.$$v=v;});
1.9.3p448 :001 > require 'bigdecimal'
=> true
1.9.3p448 :002 > BigDecimal.new('1') / 0
=> #<BigDecimal:7fdc5c0a8350,'Infinity',9(36)>
1.9.3p448 :003 > BigDecimal.new('-1') / 0
=> #<BigDecimal:7fdc5c0b47b8,'-Infinity',9(36)>
redis 127.0.0.1:6379> SET foo baz
OK
omarqureshi=# select * from redis_db0;
key | value
-----+-------
foo | baz
(1 row)