Hi, I have a list of files and I need to produce a string containing the size of each file, but in human readable format. With that I mean something like what df -h does: make an approximation to the nearest unit (B, KB, MB, GB, etc). Is this already done somewhere? This is what I have now: Find.find(folder) do |file| match = regexp.match(File.basename(file)); if match size = File.stat(file).size
Is it possible to test threads in RSpec? For example (FYI: Jukebox is a module): it "should have a current_song" do thread = Thread.new do Jukebox.play # forks a music process and waits till completion end sleep 0.1 Jukebox.current_song.is_a?(Song) end If RSpec can’t test threaded programs, any suggestions how threaded programs can be tested? Thanks! James On Thursday 01 September 2011 03:45:17 Ja
Hi list, What is the best/easiest way to generate unique filenames ? Couln’t find such method in Ruby On Tue, May 02, 2006 at 01:17:13AM +0900, 13 wrote: What is the best/easiest way to generate unique filenames ? Couln’t find such method in Ruby filename = random_number() while (does_file_exist(filename)) { filename = rand() } print filename " is unique" Cheers, Phil On Tue, 2 May 2006, 13 wrote:
I need to build a Zip-Archive with a unique name that is served by Apache using its X-SendFile mechanism. Tempfile doesn’t appear to be suitable in this case as it unlinks its managed file when the Tempfile object is finalized. In my current, wrong code, I’m using Tempfile and the file is not deleted prematurely, but I take this to be no more than luck. There are two processes involved, the ruby p
In Java, with AOP magic and bytecode manipulation under the covers, you could do something like this: (psuedocode, in real java it would be xml or annotations) For methods that are: public, name matches foo*, members of classes Bar and Boo, intercept and log by calling myLogger then myLogger would get the method object, and be able to log the name, time of call, parameters, etc… I know in Ruby you
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く