It's so easy with Ruby to get a list of files in the current directory that I hesitate to write this, but hey, this blog is for me and my bad memory, so here's a quick note on how to use Ruby to get a list of files of a certain type in a directory.
To have a little fun with this, I'll use
irb (the interactive Ruby shell environment) to show how to do this.
Here's some sample Ruby source code that shows how to do something with every file in a directory, where you only work on filenames that match a pattern you're interested in. For example, in my case I'm only interested in processing files that end with the filename extension
WMA, so this first snippet of Ruby code shows how to print out the name of each file in a directory with the
An interesting thing about developing software to work with an FTP server is that for some tests you need files to be uploaded to the FTP server very slowly. Usually you want software to run as fast as possible, but in my case I needed to be able to throttle the FTP upload speed to test portions of my code. (Specifically, I'm writing code to listen to Proftpd FTP server events, and I needed this to make sure all the STOR, DELE, RNFR, and RNTO events work as advertised (making sure the event notifications aren't sent until the event is complete.)
In previous blog posts I showed how I created a Java web service and client using Apache Axis2. In those examples I showed how to read from web service methods that return a single object, and also an array or list of objects. In this post I'll show several sample Ruby programs that also read from those same Java web services.
Here's a quick example of using Ruby ActiveRecord outside of Rails. In this case I'm saving a new record to an
employees table in a MySQL database.
For a little while yesterday I sat at a book store and flipped through several books on Ruby and Rails. I'm not the most passionate Ruby developer in the world, but I really do like the language, and prefer it at every opportunity.
In the latest release of Dr. Dobbs, Michael Swaine reports that "after two years trying to make Ruby on Rails do what he wanted, Derek Sivers went back to PHP and finished the job in two months." Actually, here's a direct link to Derek Sivers' post, including his seven reasons he switched back from Rails to PHP, and what he learned from Rails.
I just found the RubySearch dashboard widget for Mac OS X, and I like it. It offers a simple interface to your local ri/rdoc repository, with hyperlinking between classes, methods, superclasses, etc. It may be a lot better than going back and forth between a Terminal window and typing
Here's a simple Ruby program that opens a text file, then uses a series of simple algorithms to look for hidden words in the text. For instance, it looks at only odd words, only even words, then looks at Nth characters, Nth words, and also Fibonacci words and characters.