Skip to content

Instantly share code, notes, and snippets.

@joncooper
joncooper / gist:1043829
Created June 23, 2011 22:56
Strange behavior with JRuby IO#rewind when backed by a ByteArrayInputStream
# https://github.com/jruby/jruby/blob/master/src/org/jruby/RubyIO.java
#
# public RubyFixnum rewind (...) {
# calls OpenFile#getMainStreamSafe#lseek(0L, Stream.SEEK_SET)
#
# https://github.com/jruby/jruby/blob/master/src/org/jruby/util/io/ChannelStream.java
#
# public synchronized void lseek (...) {
# checks if the fd is seekable
# checks if the fd is a SelectableChannel
ultramarine:China jdc$ git remote -v
origin git@github.com:golocal/China.git (fetch)
origin git@github.com:golocal/China.git (push)
production git@heroku.jdc:giftly.git (fetch)
production git@heroku.jdc:giftly.git (push)
staging git@heroku.jdc:giftly-staging.git (fetch)
staging git@heroku.jdc:giftly-staging.git (push)
ultramarine:China jdc$ git config heroku.remote
giftly-staging
“At 24 years of age,” says a striking footnote on page one of the Army’s suicide reports, “a Soldier, on average, has moved from home, family, and friends and resided in two other states; has traveled the world (deployed); been promoted four times; bought a car and wrecked it; married and had children; has had relationship and financial problems; seen death; is responsible for dozens of Soldiers; maintains millions of dollars’ worth of equipment; and gets paid less than $40,000 a year.” Now consider what happens when this cycle repeats itself for a decade. “Moving, divorce, death, financial turmoil,” says Lily Burana, author of the memoir I Love a Man in Uniform. “Those are the top stressors in a life. And this is what you get every freaking year in the Army.”
# PE#30
#
# Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
#
# 1634 = 1**4 + 6**4 + 3**4 + 4**4
# 8208 = 8**4 + 2**4 + 0**4 + 8**4
# 9474 = 9**4 + 4**4 + 7**4 + 4**4
# As 1 = 1**4 is not a sum it is not included.
#
# The sum of these numbers is 1634 + 8208 + 9474 = 19316.
# PE#30
#
# Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
#
# 1634 = 1**4 + 6**4 + 3**4 + 4**4
# 8208 = 8**4 + 2**4 + 0**4 + 8**4
# 9474 = 9**4 + 4**4 + 7**4 + 4**4
# As 1 = 1**4 is not a sum it is not included.
#
# The sum of these numbers is 1634 + 8208 + 9474 = 19316.
# PE#34
#
# 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
#
# Find the sum of all numbers which are equal to the sum of the factorial of their digits.
#
# Note: as 1! = 1 and 2! = 2 are not sums they are not included.
require 'pe-library'
require 'benchmark'
# PE#34
#
# 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
#
# Find the sum of all numbers which are equal to the sum of the factorial of their digits.
#
# Note: as 1! = 1 and 2! = 2 are not sums they are not included.
require 'pe-library'
require 'benchmark'