Leopard and Rails
Apple’s latest OSX offering has both Ruby and Ruby on Rails built into the framework. Although, as I’ve discovered, some of the rails gems are rather outdated. To make sure you’re playing with the latest, make sure to execute this:
superbia:~ matt$ sudo gem update rails
This will get RJS among other things from the recent version of Rails working correctly on Leopard.
Website no-nos
Note to self and other website designers: when building your website, please make sure that you don’t refuse access to a site based on the absence of a piece of software. I’m attempting to register with https://bluehealthcarebank.esignfinancial.com to activate an account and because the javascript for the page checks whether or not I have Adobe Acrobat Reader installed I am unable to proceed with my registration. I mean, come on…
I know that a lot of people have Acrobat Reader installed, but it’s hardly fair to assume that everyone that connects to your site has Acrobat Reader installed. On my MacBook Pro, I prefer using Leopard’s Preview.app and on Windows, I much prefer Foxit Reader to that bloated piece of crap called Acrobat Reader… As it stands now, I need to either build up a VM to register with the site, or borrow someone’s computer simply to register and activate.
Self Improvement
“When an archer misses the mark, he turns and looks for the fault within himself. Failure to hit the bull’s-eye is never the fault of the target. To improve your aim — improve yourself.”
–Gilbert Arland
Many people, myself included, often look to blame others when they dont hit their goals. This is a great reminder that we should always look within and seek first to improve ourselves when striving to reach a goal.
Happy Thanksgiving
I would like to wish each of my readers a very safe and happy Thanksgiving day. I hope that each takes some time on Thursday to reflect on the things that they are truly thankful for. I am thankful for many things in my life, but perhaps none more than the servicemen and women who are overseas fighting each and every day to keep us safe. If it was not for these men and women, we would not be able to do the things we do.
My best wishes to all of them, especially you, Sgt. Ambron, my brother from another mother. Stay safe over there.
VS2008 RTM
VS.NET 2008 and .NET 3.5 have been RTM’d and can be downloaded from the MSDN subscriber downloads section.
My download speed is relatively slow, considering that the servers are probably being crushed by everyone downloading. The 3.9GB DVD ISO should be done downloading in about 12 hours or so, given current transfer rates.
Congratulations to the VS.NET team for this milestone. :)
System.Web.MVC and attribute declarations for controllers
I’ve managed to take a look at some of the ASP.NET MVC sample code available on the web. This looks really good, and I am quite excited to see some bits that I can reference to start working this into my own project.
One request (for now)… As it stands, each item that should be available via the controller needs to be decorated with an attribute. Separation of concerns is something that really motivates this MVC framework, and because of this, it should be reasonable to state that all public methods in the class that derives Controller should be methods that are available via a URL.
I much prefer the convention over configuration ideas put forward by the Ruby on Rails group. Not having to place this attribute on each method leans more towards convention and also enforces more separation of concerns.
Phil, what do you think? Are you listening?
Random Images in Rails
A requirement for a client application that I just recently finished was to display groups of client logos on the screen. The logos themselves would be stored on the filesystem of the web server. What I needed was a way to get a random image to my view in such a way that images would not be duplicated. Having the same logo on the screen twice would not have been ok. This is what I came up with.
def random_logo @image_files = %w( .jpg .gif .png ) @files ||= Dir.entries( "#{RAILS_ROOT}/public/images/logos").delete_if { |x| !@image_files.index(x[-4,4]) } file = @files[rand(@files.length)]; @files.delete file return "/images/logos/#{file}" end
The code in the view looks like this:
<%= image_tag random_logo %>
The trickery here is initializing the @files variable. If it has not been initialized, it becomes an array of all of the files that match the specified file types (in the @image_files variable). @files is stored as an instance variable solely for the purpose of removing already used logos from the array. This way, we will not duplicate logos on the same page. We pick a random item from the array, remove it from the array and then return a path to it.
I’m sure there’s better ways to get this done, but I was kind of pleased with this little bit of code.
Theme changes
An observant reader today mentioned to me that my feed had not been updated in his aggregator for almost a month. However, there have been postings to the site. After some digging, I found that some slight errors in my feed (as a result of the theme changes from mid-October) were causing some aggregators to choke. The error stemmed from having a few lines empty lines in front of the xml declaration. This was confirmed by running the atom and rss2 feeds through feedvalidator.org.
What I found was that wordpress sometimes likes to inject empty lines depending on how your theme files are laid out. In my case, I had a few empty lines before and after the php ?> blocks. I took care to go through and remove all of these. I have also just verified that the feeds validate correctly through feedvalidator.org. I apologize for any inconveniences.
My Paperless Office Dream
… is a little closer to reality. My new Fujitsu ScanSnap S510M showed up, and I’ve spent some time getting through my file cabinets and clearing out a bunch of clutter. So far, I’ve managed to scan and shred about 18 inches of paper. My workflow at this time uses DevonThink Pro Office, which offers a seamless integration with the ScanSnap. I load the document into the ScanSnap, push a button, and a few seconds later, I have a fully searchable PDF in my DevonThink database.
The ScanSnap is a little expensive, but knowing what I know now, I only wish I would not have waited this long. It does not get much easier than this.



