I hereby claim:
- I am alexgenco on github.
- I am alexgenco (https://keybase.io/alexgenco) on keybase.
- I have a public key ASB8GXLy-bCW-DmcFzHdkoW-IYU8euAZp-IKbeYSDEAFtQo
To claim this, I am signing this object:
| -r spec_helper | |
| --default-path . |
I hereby claim:
To claim this, I am signing this object:
| json1 = {:one => nil}.as_json # => {"one"=>"null"} | |
| json2 = {"one" => "null"} # => {"one"=>"null"} | |
| json1 == json2 # => true | |
| Yajl::Encoder.encode(json1) # => "{\"one\":\"null\"}" | |
| Yajl::Encoder.encode(json2) # => "{\"one\":\"null\"}" | |
| ActiveSupport::JSON.encode(json2) # => "{\"one\":\"null\"}" | |
| ActiveSupport::JSON.encode(json1) # => "{\"one\":null}" |
| #!/usr/bin/env ruby | |
| print "this will rescursively rearrange all these directories. u sure? [Yn] " | |
| response = gets.strip | |
| abort("k.") unless response =~ /y/i | |
| require 'fileutils' | |
| $in_dirs = Dir["./*/"] |
| #!/usr/bin/env ruby | |
| # Project Euler 36 | |
| # | |
| # The problems asks for the sum of all numbers below a million that | |
| # are palindromes in base 10 and base 2. I solved it by opening up | |
| # the Fixnum class and adding palindrome methods. | |
| # | |
| # pnext returns the next palindrome: | |
| # 121.pnext # => 131 |
| # the problem asks for the largest product of 5 consecutive numbers in a 1000 digit number. | |
| # something tells me this could be even more succinct, maybe with just one list comprehension | |
| number = [ int(x) for x in list("73167 ... 63450") ] | |
| print max([ number[i] * number[i+1] * number[i+2] * number[i+3] * number[i+4] for i in range(len(number)-4) ]) |