Skip to content

Instantly share code, notes, and snippets.

@nambrot
Created February 10, 2012 22:21
Show Gist options
  • Save nambrot/1793544 to your computer and use it in GitHub Desktop.
Save nambrot/1793544 to your computer and use it in GitHub Desktop.
IRB session history
[ [ 0] "foo = lambda {|n| n.to_s.split('').map { |digit| digit.to_i }.inject(0){|a,b| a+b}}", [ 1] "foo.call(1)", [ 2] "foo.call(2)", [ 3] "foo.call(20)", [ 4] "foo.call(21)", [ 5] "foo.call(i)", [ 6] "puts foo.call(i)", [ 7] "def fact", [ 8] "def fact(n)", [ 9] "n==0 ? 1 : fact(n-1) * n", [ 10] "for i in 1..20", [ 11] "puts foo.call(fact(i))", [ 12] "fact(2)", [ 13] "fact(6)", [ 14] "i = 0", [ 15] "while foo.call(fact(i)) != 8001", [ 16] "i++", [ 17] "while foo.call(fact(i)) != 8001 do", [ 18] "i += 1", [ 19] "end", [ 20] "i",
[ 21] "fact(787)",
[ 22] "foo.call(fact(787))",
[ 23] "require 'nogokiri'",
[ 24] "require 'net/http'",
[ 25] "Net::Http",
[ 26] "Net",
[ 27] "Net::HTTP.new(\"http://apply.embed.ly/static/data/2.html",
[ 28] "re:",
[ 29] ":",
[ 30] "\"'",
[ 31] "'",
[ 32] "\"\"",
[ 33] "\"",
[ 34] "sds",
[ 35] "require 'uri'",
[ 36] "exit",
[ 37] "require 'uri'",
[ 38] "require 'net/http'",
[ 39] "uri = URI.parse(\"http://apply.embed.ly/static/data/2.html\")",
[ 40] "response = Net::HTTP.get_response(uri)",
[ 41] "response.body",
[ 42] "doc = Nokogiri::HTML(response.body)",
[ 43] "require 'nokogiri'",
[ 44] "doc = Nokogiri::HTML(response.body)",
[ 45] "doc.css('article')",
[ 46] "doc.css('article'); 0;",
[ 47] ";",
[ 48] "end",
[ 49] "doc.css('article > p')",
[ 50] "doc.css('article > p').map{|d| d.depth}",
[ 51] "doc.css('article > p').map{|d| d.ancestors.length}",
[ 52] "ps = doc.css('article > p')",
[ 53] "ps.first",
[ 54] "ps.first.ancestors",
[ 55] "ps.first.ancestors.length",
[ 56] "doc.css('article p').map{|d| d.ancestors.length}",
[ 57] "article = doc.css('article')",
[ 58] "article = doc.css('article').ancestors.length",
[ 59] "article = doc.css('article').length",
[ 60] "article = doc.css('article').first.ancestors.length",
[ 61] "doc.css('article p').map{|d| d.ancestors.length - article}",
[ 62] "doc.css('article p').map{|d| d.ancestors.length - article}.inject(0){|a,b| a+b}",
[ 63] "doc.css('article p').map{|d| d.ancestors.length - article}.length",
[ 64] "avg = 85 / 39",
[ 65] "avg = 85 / 39.0",
[ 66] "doc.css('article p').map{|d| d.ancestors.length - article}.map{|d| (d-avg)**2}",
[ 67] "doc.css('article p').map{|d| d.ancestors.length - article}.map{|d| (d-avg)**2}.inject(0){|a,b| a+b}",
[ 68] "doc.css('article p').map{|d| d.ancestors.length - article}.map{|d| (d-avg)**2}.inject(0){|a,b| a+b} / 39.0",
[ 69] "sqrt(_)",
[ 70] "doc.css('article p').map{|d| d.ancestors.length - article}.map{|d| (d-avg)**2}.inject(0){|a,b| a+b} / 39.0",
[ 71] "Math.sqrt(_)",
[ 72] "[1..900]",
[ 73] "1..900",
[ 74] "1..900.length",
[ 75] "[1..900].length",
[ 76] "1 .. 900",
[ 77] "_.class",
[ 78] "1 .. 900",
[ 79] "_.to_a",
[ 80] "a = _",
[ 81] "a = _.map{|d| 1/d}",
[ 82] "a = _.map{|d| 1.0/d}",
[ 83] "1 .. 900",
[ 84] "a = _.map{|d| 1/d}",
[ 85] "_.to_a",
[ 86] "1 .. 900",
[ 87] "_.to_a",
[ 88] "a = _",
[ 89] "a.map{|d| 1/d}",
[ 90] "a.map{|d| 1.0/d}",
[ 91] "b = _",
[ 92] "b.inject(0){|a,b| a+b}",
[ 93] "b.inject(0){|a,b| a+b} / 2",
[ 94] "c = _",
[ 95] "d = b",
[ 96] "c",
[ 97] "while d.inject(0){|a,b| a+b} > c do",
[ 98] "d.delete_at(-1)",
[ 99] "end",
[100] "d.length"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment