Last active
January 4, 2016 01:39
-
-
Save domgetter/8549605 to your computer and use it in GitHub Desktop.
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
# reads file backwards by byte | |
File.open("some_file.txt", "r") do |file| | |
file.size.downto(0) do |byte| | |
file.pos = byte | |
char = file.read(1) | |
puts char unless char =~ /\r/ | |
end | |
end | |
9 | |
8 | |
7 | |
6 | |
5 | |
4 | |
3 | |
2 | |
8 | |
7 | |
6 | |
5 | |
4 | |
3 | |
2 | |
1 | |
=> 24 |
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
1234 | |
5678 | |
2345 | |
6789 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment