Skip to content

Instantly share code, notes, and snippets.

@nahi
Created May 6, 2012 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/2617669 to your computer and use it in GitHub Desktop.
Save nahi/2617669 to your computer and use it in GitHub Desktop.
23 is the magic number :)
# Run this with trunk (Tested with ae4fa795)
1.upto(24).each do |size|
p size
File.open(IO::NULL, "w") do |w|
File.open(__FILE__) do |r|
buf = ''
while !r.read(size, buf).nil?
w << buf # It works when you remove this line.
end
end
end
end
@nahi
Copy link
Author

nahi commented May 6, 2012

% wget https://raw.github.com/gist/2617669/7551567db8a4933bb79d0c0f4e244b72fe8e3240/gistfile1.txt
--2012-05-06 14:46:10--  https://raw.github.com/gist/2617669/7551567db8a4933bb79d0c0f4e244b72fe8e3240/gistfile1.txt
Resolving raw.github.com (raw.github.com)... 207.97.227.243
Connecting to raw.github.com (raw.github.com)|207.97.227.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 278 [text/plain]
Saving to: `gistfile1.txt'

100%[==============================================================================================================>] 278         --.-K/s   in 0s      

2012-05-06 14:46:11 (51.0 MB/s) - `gistfile1.txt' saved [278/278]

% ruby -v gistfile1.txt
ruby 2.0.0dev (2012-05-05 trunk 35544) [x86_64-linux]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
gistfile1.txt:7:in `read': can't set length of shared string (RuntimeError)
    from gistfile1.txt:7:in `block (3 levels) in <main>'
    from gistfile1.txt:5:in `open'
    from gistfile1.txt:5:in `block (2 levels) in <main>'
    from gistfile1.txt:4:in `open'
    from gistfile1.txt:4:in `block in <main>'
    from gistfile1.txt:2:in `upto'
    from gistfile1.txt:2:in `each'
    from gistfile1.txt:2:in `<main>'
zsh: exit 1     ruby -v gistfile1.txt
% 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment