BibleGateway.com Verse Of The Day

Thursday, September 27, 2007

Rhythm's Gonna Get You

Last night was Raina's big 4th birthday, so we went to Chuck E. Cheese. On the way home, our Sirius radio was, of course, tuned to "Kid's Stuff", and annoying little Dora The Explorer was singing some cheesy 80's song, Rhythm's Gonna Get You. The song was bad enough the first time around, did we really need Dora to "sing" it for us?

Anyway, that's not even the point. Half way through the song, Raina asked us if Rhythm is a bad guy? Took us a few seconds to realize what she was getting at. In the Disney movies they've seen, the bad guys "get you", so Rhythm must be a bad guy since it is trying to "get you". It was funny, and also kind of scary. As adults, we see or hear things but don't notice anything odd, but the kids are processing it and picking it apart, not missing a single thing.

Word, Character, Line Counter Ruby Script

I've been on a few projects lately that involve loading data files that I get from other teams. When I get a file, it's nice to see how big it is to get an idea of how long it will take. Opening the file in a text editor and going to end of file to see the row number can be a pain, especially for big files. Also, I'm on a Windows desktop, so tools like "wc" aren't built-in, and launching Cygwin and getting to the right directory can be a pain in itself (cd /cygdrive/c/Documents\ and\ Settings/ran488/Desktop), so I whipped up this quick Ruby script to give me all the file info I want.

Here's the Ruby script (fileinfo.rb) to get the count of lines, characters, and words in a text file. It also spits out the min and max line size as well. The source can be downloaded at http://www.frontiernet.net/~nicholson150/fileinfo.rb.


#!/usr/bin/env ruby

if __FILE__ == $0
if ARGV.length < 1 then
puts "Usage: #{$0} filename"
exit
end

results = []
words = 0
chars = 0
minline = 0
maxline = 0

filename = ARGV.first
File.new(filename, "r").each { |line| results << line }

puts "#{filename} has..."
puts " -> #{results.size} lines."


results.each do |line|
chars += line.length
words += line.split.length

if line.length > maxline then
maxline = line.length
elsif line.length < minline then
minline = line.length
end

end
puts " -> #{words} words."
puts " -> #{chars} characters."
puts " -> #{minline} character shortest line length."
puts " -> #{maxline} characters longest line length."

end


Here's an example of the output....





C:\cvs\MqThrottler>fileinfo.rb PA_CSS_Test_Load_0911.txt
PA_CSS_Test_Load_0911.txt has...
-> 10008 lines.
-> 58021 words.
-> 4356721 characters.
-> 0 character shortest line length.
-> 489 characters longest line length.

Monday, September 17, 2007

Lexi


Here's an updated picture of Lexi the Wheaten Terrier. She is about 7 months old here, mostly white and wheat color with just hte black face remaining.

Thursday, September 06, 2007

PDFCreator

Apps like OpenOffice.org have built-in PDF export functions, and Mac OS X has a built in PDF export in the print dialog.

But if you're running apps on Windows that don't have this feature, you can download and install PDF Creator. It installs itself as a "printer" on your PC. When you choose to print from any application, choose this printer instead of your normal printer.

Bulk File Renamer in Ruby - file_rename.rb

My updated bulk file renamer script is listed here. (http://www.frontiernet.net/~nicholson150/file_rename.html) along with the Ruby source code.

I first started messing with this concept in this post, but have refined it a bit since.

Along with the Ruby compiler I mentioned yesterday, this could be compiled and dropped in your PATH somewhere (e.g. Windows dir), and then you could run it anywhere as if it were a native Windows/DOS command. I may end up doing that on my home PC to help rename the imported digital photos-- "DCP_05483.JPG" just isn't as descriptive as "Jeep Camping Trip 2007 - 012.jpg"

Tuesday, September 04, 2007

RubyScript2Exe - The Ruby Compiler

I've been playing with RubyScript2Exe (http://www.erikveenstra.nl/rubyscript2exe/index.html) lately, and it's pretty sweet. It's a Ruby "compiler" to generate executables from your Ruby scripts. Since it embeds the Ruby runtime and any libraries in the executable, even simple scripts can "bloat" up to bigger sizes than you might expect, but if distribution is your thing, so what?

Maybe you want to share some of your cool scripts and development tools you've created, but can't count on your intended audience having Ruby installed (what's wrong with them, anyways?), or maybe it would take too long to explain what Ruby is and how to run the scripts. Or maybe you just don't want people screwing with your perfect source code. Or perhaps, you are ashamed of your trashy, hack-n-whack coding?

Whatever the reason, this thing is the nuts. Just download a single rubyscript2exe.rb script and run it against your app. I've only tried it on single files on Windows so far, but it is supposed to create Linux executables as well, and will allegedly work on more complex, multi-*.rb-file apps.