This file contains hidden or 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 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) |
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
# 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" |
This file contains hidden or 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
1.9.3p448 :009 > h = Hash.new(3) | |
=> {} | |
1.9.3p448 :010 > h['a'] | |
=> 3 |
This file contains hidden or 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
➜ ~ 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"} |
This file contains hidden or 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
➜ ~ 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"] |
This file contains hidden or 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
<!--[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]--> |
This file contains hidden or 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
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;}); |
This file contains hidden or 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
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)> |
This file contains hidden or 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
redis 127.0.0.1:6379> SET foo baz | |
OK | |
omarqureshi=# select * from redis_db0; | |
key | value | |
-----+------- | |
foo | baz | |
(1 row) |