-
I love treating primitives as objects #ruby
#script to generate a .csv testing results file puts “Day,User ID,Action,Start Time,End Time” (1..28).each{ |day| puts “#{day},system,1. Load Step,hh:mm:ss,hh:mm:ss” puts “#{day},system,1a. Raw Data Load,hh:mm:ss,hh:mm:ss” puts “#{day},system,1b. Cube Build,hh:mm:ss,hh:mm:ss” (1..8).each { |user| (1..15).each { |report| puts “#{day},#{user},2. Report #{report},hh:mm:ss,hh:mm:ss” } } (1..5).each { |user| puts “#{day},#{user},3. Query,hh:mm:ss,hh:mm:ss” } }
-
rush: the ruby shell
rush. rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax. Grep through files, find and kill processes, copy files – everything you do in the shell, now in Ruby. Install rush If you’re running windows and have Ruby installed, go to Start->Ruby-{version}->RubyGems->RubyGems Package manager and type in “gem…
-
Have I appropriately professed my love for Ruby yet?
I used to play around with Ruby a lot. Here’s another script, where I was downloading fedora ISOs and giving myself feedback as to the progress of the operation (yes, I was in cygwin also). #!/usr/bin/rubyrequire ‘net/ftp’require ‘fileutils’ftp=Net::FTP.new("ftp.linux.ncsu.edu")ftp.login("anonymous", "me@email.com")FileUtils.chdir("/cygdrive/c/downloads/fedora")files=ftp.chdir("pub/fedora/linux/core/3/i386/iso")def mecallback() print ‘filename: ‘, (File.size($fileName) * 100.0 / $fileSize), "%n"end$fileName="FC3-i386-disc3.iso"$fileSize=ftp.size($fileName)print ‘filename: ‘, $fileName, "n"ftp.getbinaryfile($fileName, $fileName, 2**20)…