Skip to content
Browse files

Fixed script for ruby 1.9

  • Loading branch information...
1 parent 78578b0 commit 67b5de7ab93e64403df816dd867795d71dd71f19 @kristopolous committed Feb 27, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 piggyunpack.rb
View
14 piggyunpack.rb
@@ -1,15 +1,15 @@
#!/usr/bin/env ruby
name='9bEZg'
`curl http://i.imgur.com/#{name}.png | convert - -compress none #{name}.ppm`
-handle = File.open("#{name}.ppm", "r")
-3.times do handle.readline;end
-enc = handle.read.split(' ').map { | x | x.to_i }
+ppm = File.open("#{name}.ppm")
+3.times { ppm.readline }
+enc = ppm.read.split(' ').map { | x | x.to_i }
bytes = 0.upto(enc.length / 3 - 1).map { | x |
- (enc.shift & 0x7) << 5\
- | (enc.shift & 0x3) << 3\
- | (enc.shift & 0x7)
+ (enc.shift & 7) << 5\
+ | (enc.shift & 3) << 3\
+ | enc.shift & 7
}.pack('C*')
-name = bytes.slice!(0, bytes.slice!(0,1)[0])
+name = bytes.slice!(0, bytes.slice!(0, 1).unpack('C')[0])
out = File.open("/tmp/#{name}", "w")
out << bytes[0, bytes.slice!(0, 8).unpack('q')[0]]
`mplayer /tmp/#{name}`

0 comments on commit 67b5de7

Please sign in to comment.
Something went wrong with that request. Please try again.