»
S
I
D
E
B
A
R
«
Force SSL in Apache
Jan 31st, 2010 by Bill

This is nothing Earth shattering but it seems that this has come up quite a bit lately and I wanted a place to keep the information handy. So here it is:

If you want to force the use of SSL for a specific site, place this configuration in the .htaccess file in the document root.

<IfModule !mod_rewrite.c>
	LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{SERVER_PORT} !^443$
	RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</IfModule>

Care to recommend an alternate solution?

My X is better than your Y – PHP/Ruby Edition, Part XVI
Jul 12th, 2009 by Bill

This post started as a comment to a recent post on KillerPHP.com entitled, “What happened to Ruby? And why PHP is KING of the Web.” The longer my comment became the more I thought I could use a little Google juice myself and why let someone else have all the fun?!

A Twitter post by the normally well-reasoned Cal Evans, Director of the PHP Center for Expertise for Ibuildings lead to my discovery of the KillerPHP.com post that seems to be only the latest in a long line of PHP versus Ruby/Rails rants. I can’t imagine Cal is trolling near as much as it appears the post’s author, Stefan Mischook, but I digress…

I have been a PHP developer since 2001 and founded OINK-PUG in 2005, a month before I discovered Rails and came to enjoy writing Ruby. I prefer Ruby but cannot escape PHP because there is just so much PHP work out there! I am active in both communities locally and would be remiss not to send a shout out to the folks at CART and CincyRB too.

It has been my experience that there is a vast difference in the two communities of developers. Due to PHP’s popularity and low barrier of entry, many developers find it very inviting, especially those with little or no experience. Without much intellectual investment you can produce some rather impressive results, especially using products like Drupal and Wordpress.

Where Ruby shines is when the job calls for something that falls outside of PHP’s sweet spot. Personally, I think it does an equally good job in PHP’s sweet spot but that’s another post. These more challenging cases require more than parochial knowledge of software development; even seemingly simple concepts like a Web UI for SMS can benefit from the skills of a craftsman. That’s where the Ruby community shines and the PHP community falls a bit short.

I suggest that the primary indicator of this is the Ruby community’s embrace of test driven development (TDD) and its relative absence from the PHP community. I would ask those readers who have inherited someone else’s code for both PHP and Ruby projects which they’ve found more maintainable, PHP or Ruby? I always swallow hard when looking at someone else’s PHP code for the first time whereas I know in a minute whether or not a Ruby/Rails project I’ve inherited is going to be trouble. I just look in the “test” directory in the project’s root directory or run rake, created by fellow Cincinnati Rubyist, Jim Weirich by the way!

TDD is only one example of what differentiates the two communities. I can’t count the number of PHP projects I have inherited that were clearly devoid of source control management, or even simple code convention. Excluding the never ending “Spaces vs. Tabs” debate, I’ve never encountered either of these problems with “legacy” Ruby/Rails code. I invite everyone with more than a couple years experience IN BOTH LANGUAGES to add their thoughts about my claims in the comments below. Everyone else, knock yourselves out. Beat me up. Beat on Stephan. You won’t, nor should you expect to change either of our opinions.

Yes, Twitter could have been written in PHP, Wordpress could have been written in Ruby, and Drupal in Python. If that’s all you’ve taken from this post then you’re not “getting it” or more likely, I’ve poorly stated my argument. Nonetheless, clearly Mischook has a bone to pick with Ruby but I find nothing new in his rant and took the bait anyway. I’m overjoyed that he loves PHP so much. I did too, until I found something that “I” like better. I don’t feel the need to justify my decision to others, although I think I just did. Anyone (including me) can write bad Ruby code. Some can write beautiful PHP. In fact, some of the brightest people I know still write PHP but I say, let them eat CakePHP.

Git configuration setting causing Fixture::FormatError in Rails
May 15th, 2009 by Bill

I just spent a few hours banging my head on this one but it appears that my local git configuration was the source of a Fixture::FormatError occurring while running tests in Rails.

The specific error looked like this:

Fixture::FormatError: a YAML error occurred parsing /dev/current/myapp/test/fixtures/blogs.yml.
Please note that YAML must be consistently indented using spaces. Tabs are not allowed.
Please have a look at http://www.yaml.org/faq.html
The exact error was:
  ArgumentError: Anonymous modules have no name to be referenced by

I have not yet pin pointed (and may never pin point) the exact source of the problem but what appears to have been causing it was my local git configuration (~/.gitconfig) which included the following two lines:

[core]
    whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol

The git config file was passed around during a Cincinnati Ruby Brigade meeting and, being a git noob, I installed it dutifully.

Anyway, removing those two lines from the .gitconfig file resolved the issue after I moved the existing clone aside and re-cloned the repository. Feel free to provide details in the comments if you’ve got a clue and/or can shed some light on the exact cause.

Cisco VPN Client ‘Error 51′
Apr 23rd, 2009 by Bill

It seems that a lot of folks are experiencing the “Error 51: Unable to communicate with the VPN subsystem” issue with Cisco’s VPN Client in Mac OS X. After much searching when I encountered the same issue, the solution turned out to be quite simple.

  1. Download and install the client from MacUpdate.
  2. Profit.

There is no annoying middle step.

Apple Key Symbols
Mar 21st, 2009 by Bill

I know that I should have these committed to memory by now but I don’t and I can never find them on the Web. Now I’ll never loose them! (Those sound like famous last words…)

Symbol Command
option
control
shift
caps lock
command
clear
delete
del (erase right)
Symbol Command
return
enter
home
end
page up
page down
tab

Rails on Windows
Mar 15th, 2009 by Bill

During a recent Cincinnati Ruby Brigade meeting a new member who was running Windows would have benefited from a minimalist guide to installing Ruby on Rails on Windows. A few days later I was forced to press my old Windows desktop system into service as an emergency Rails development platform. So I decided to write this post.

Thanks to All About Ruby for providing a starting point for my research for this post.

Nota Bene: These instructions are Windows XP specific. If you’re using another flavor of Windows YMMV. Also, all references to software version numbers are current only at the date of this posting.

Install Ruby

  1. Download the One-Click Ruby Installer for Windows.
  2. Run the installer. I unchecked the option to install the SciTE text editor which saved a whopping 1.5MB of storage.
  3. If you so desire, you can verify that the install succeeded by running ruby -v on the command line:
  4. C:\>ruby -v
    ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
    
  5. Update RubyGems by running gem update –system on the command line:
  6. C:\>gem update --system
    Updating RubyGems...
    Attempting remote update of rubygems-update
    Successfully update rubygems-update-1.3.1
    Updating version of RubyGems to 1.3.1
    Installing RubyGems 1.3.1
    [...]
    RubyGems system software updated
    
  7. Again, verify the install succeeded by running gem -v on the command line:
  8. C:\>gem -v
    1.3.1
    

Install SQLite

  1. From the Precompiled Binaries For Windows section download the command-line program (sqlite_X_Y_Z.zip) and the SQLite library DLL without the TCL bindings (sqlitedll_X_Y_Z.zip) unless you need the TCL bindings.
  2. Copy the contents of both ZIP files into a directory of your choosing. I chose C:\sqlite. Others have chosen to place them in the bin directory under the base directory chosen during the Ruby installation, typically C:\ruby\bin. I chose a separate directory so that future upgrades of Ruby do not break my SQLite installation.
  3. If you chose a separate directory in the previous step, like C:\sqlite, you will want to add that directory to your PATH environment variable.
    1. To do so, navigate Windows Explorer until you can see My Computer. Right click the My Computer icon and select Properties. Select the Advanced tab and then the
      Environment Variables button.
    2. If you have sufficient privilege, I recommend adding the path to the PATH variable under the System variable section so that SQLite is available to all system users. However, if you do not have sufficient privilege OR are certain that the current user is the only user that will require access to SQLite then you are free to add the path to the PATH variable under the User variables section.
    3. To add the path, select the PATH variable and click the Edit button. Add the appropriate path, in my case C:\sqlite, to either the beginning or end of the existing PATH string then click the OK button.

    WARNING! Be careful that you do not corrupt or delete the existing PATH string.

  4. Install the SQLite gem by running gem install sqlite3-ruby on the command line. Select the mswin32 gem when prompted.
  5. C:\>gem install sqlite3-ruby
    Select which gem to install for your platform (i386-mswin32)
     1. sqlite3-ruby 1.2.4 (ruby)
     2. sqlite3-ruby 1.2.3 (x86-mingw32)
     3. sqlite3-ruby 1.2.3 (mswin32)
     4. sqlite3-ruby 1.2.3 (ruby)
     5. Skip this gem
     6. Cancel installation
    > 3
    Successfully installed sqlite3-ruby-1.2.3-mswin32
    Installing ri documentation for sqlite3-ruby-1.2.3-mswin32...
    Installing RDoc documentation for sqlite3-ruby-1.2.3-mswin32...
    

Install Rails

  1. Install the Rails gem by running gem install rails on the command line:
  2. C:\>gem install rails
    Successfully installed rails-2.2.2
    1 gem installed
    
  3. To verify the install run rails -v on the command line:
  4. C:\>rails -v
    Rails 2.2.2
    

Test Everything

Let’s mimic the first couple of minutes of the famous Creating a weblog in 15 minutes video to test things out.

  1. Change into a directory of your choosing and create a Rails project by running rails blog on the command line:
  2. C:\dev>rails blog
    	create
    	create app/controllers
    	create app/helpers
    	create app/models
    	create app/views/layouts
    [...]
    
  3. Change into the newly created project directory, verify that the server starts, and that the app appears at http://localhost:3000:
  4. C:\dev\blog>ruby script\server
    -> Booting WEBrick...
    -> Rails 2.2.2 application started on http://localhost:3000
    -> Ctrl-C to shutdown server; call with --help for options
    [2009-03-14 13:55:45] INFO  WEBrick 1.3.1
    [2009-03-14 13:55:45] INFO  ruby 1.8.6 (2007-03-13) [i386-mswin32]
    [2009-03-14 13:55:45] INFO  WEBrick::HTTPServer#start pid-192 port-3000
    
  5. Run the scaffold generator script:
  6. C:\dev\blog>ruby script\generate scaffold Post title:string body:text
    	exists app/models
    	exists app/controllers
    	exists app/helpers
    	create app/views/posts
    [...]
     dependency model
    	exists	app/models/
    	exists	test/unit/
    	exists	test/fixtures/
    	create	app/models/post.rb
    	create	test/unit/post_test.rb
    	create	test/fixtures/posts.yml
    	create	db/migrate
    	create	db/migrate/20090315055640_create_posts.rb
    
  7. Run rake db:migrate on the command line:
  8. C:\dev\blog>rake db:migrate
    (in C:\dev\blog)
    ==  CreatePosts: migrating ======================================================
    -- create_table(:posts)
       -> 0.0940s
    ==  CreatePosts: migrated (0.0940s) =============================================
    
  9. Start the server again and visit http://localhost:3000/posts, click the New post link, and create a new post.

There you have it. Go ahead and finish the rest of the Creating a weblog in 15 minutes video and leave me a comment if you encounter any trouble.

Coming Soon! Git on Windows.

Trouble dragging Apps between displays in OS X
Apr 23rd, 2008 by Bill

Imagine my joy when the company owner decided (for reasons that I care not to divulge here) to swap his year old MacBook Pro for my nearly two year old Dell X1! I hadn’t been using the Dell since I also had a year old MacBook (white) and although I was giving up 20GB of storage to upgrade from the MB to the MBP I jumped at the offer.

54 minutes after firing up Migration Assistant I was in business and loving the MBP goodness NOTE: I had just upgraded the MBP for the owner from Tiger to Leopard by means of a fresh install. So there wasn’t a lot of cruft on the drive that needed cleaning up once I deleted his user account.

All was well until I got around to hooking the MBP up to my second display. I am in the habit of using my ViewSonic VX715 for my work screen since it sits above my laptop, and leaving social apps like Adium, NatsuLion, and Skype open on the laptop display. However, I was no longer able to drag Safari, TextMate, etc. to the upper display although I could drag all the social apps there. Bizarre!

I posted this “annoyance” on Twitter and then the solution came to me immediately. All my “work” apps were too wide to fit the VX715’s default resolution of 1024X768. DOH! Adjusting the monitor’s resolution via System preferences freed my apps to move wherever I choose. I am a bit annoyed though that OS X apparently does not permit “over-sized” app windows move between displays since it is certainly possible to make an app window wider than any single screen. Nonetheless, mystery solved.

Software Testing
Mar 19th, 2008 by Bill

To many of you this information will come as no surprise, but I’ve searched (perhaps not hard enough) for succinct definitions of the various “types” of software development tests and I recently found these which I have paraphrased. Unfortunately, I do not now recall the source from which I derived these notes. If you believe you are the original author, please contact me and I will add proper attribution if your information appears familiar.

NOTE: I have ordered the tests (I believe) from most granular to least where such adjectives apply.

Software Testing:

  • Unit – Do the smallest “units” of code work?
  • Functional – Do the logical groupings of code work?
  • Integration – Do the all the functional pieces fit together?
  • Acceptance – Does the code do what the customer wants?
  • Regression – Does the code still work?

How I Learned to Stop Worrying and Love my Mac
Mar 19th, 2008 by Bill

As I am want to do, I became involved in an exchange on Twitter with the lovely and talented Cal Evans concerning his thoughts about forsaking his current OS/hardware choice and going Mac instead. While this seemed like a slam dunk to me, one person’s experience seemed to be giving him pause. With Twitter’s 140 character limit, there was no way for me to do justice to a very positive experience I had with Apple customer service. So, I thought I would recount the story here for posterity.

One of my current employers, Amphora Research, purchased me a PowerBook in 2005 which served me faithfully for a couple of years, until the hard drive died. Conditioned as I was to sweat such events by years of Windows and Linux use, I was not looking forward to the road to recovery ahead. I was no “spring chicken” and had been religiously backing up the PB using SuperDuper. Nonetheless, I was apprehensive as I headed to the local Apple Store to see what the geniuses could do for me. We had purchased Apple Care for the PB. So I was hoping for minimal hassle.

Upon arrival at the Genius Bar, without an appointment (you could still do that in 2007), I was greeted by a very knowledgeable genius (redundant as that may sound) who, after listening to my sad story, asked me to be patient while he checked to see what hardware they had available. As it turned out, all they had was an 80GB drive in stock but my PB came with only a 60GB drive installed. Prepared to be disappointed, I was very pleasantly surprised when the the genius asked if I would mind the extra 20GB of storage. When I asked how much the extra 20GB would cost me I was once more pleasantly surprised when he told me there was no additional cost! He asked me if I had all my data backed up which I assured him I did, and he informed me that he would need to keep the bad drive which was no concern to me. Giving Apple one more chance to disappoint me, I asked when the laptop would be ready to pick-up. “Give me a half an hour” he said, and one strawberry smoothie later I was walking out of the Kenwood Towne Centre with a juicy little upgrade but anticipating a day or two of OS and application re-installation.

I recalled the Apple genius telling me restoring the drive would be a snap when I told him I had backed up the drive using SuperDuper. He could not have been more correct. Here is the entire restore process (windows and Linux users may want to turn away at this point!):

  • Attach the SuperDuper back-up volume to the PB.
  • Reboot the system and hold the Option key down during the restart.
  • Select the back-up volume as the boot volume.
  • Launch SuperDuper and copy the contents of the back-up volume to the internal hard drive.
  • Reboot.

No OS re-install. No application re-install. Simply go back to work! It don’t get no better than this.

Shortly thereafter, my boss bought me a new MacBook which required service six months after its purchase that necessitated a week long stay at a local Apple service provider, ComputerDNA. What was I going to do without my Mac for a week? Keep on working! I booted a Mac Mini we used for pair programming from the SuperDuper back-up volume and composed and saved documents to the back-up volume as if it were the internal drive. Once my MB was returned, I restored the back-up copy to the internal drive of MB and all my new work was there waiting for me. There were no hardware issues booting the back-up created on my MacBook on the Mini, or booting the back-up updated on the Mini and restored to the MacBook.

I’ve been using Macs for ten years and as my OS of choice for four years now. When I “need” Windows or Linux I fire up VMware Fusion but I’m always relieved to return to OS X. When was the last time you were pleasantly surprised by your operating system?

PS: Just so you don’t think I’m too much of an Apple/OS X fanboy, FileVault SUCKS!!!

Hello world!
Feb 12th, 2008 by Bill

I will never write an “enterprise” software application; web-based or otherwise. Thus, BIG design makes little sense in my world. I’m a “scratch your own itch” developer. The problems that most interest me are closest at hand and, frankly, “traditional” software design practices would be wasted solving such problems. As the days, weeks, months, and (God willing) years pass, you will find more information here pertaining to the latter and less about the former.

I was first exposed to Agile Software Development when my employer at the time began hosting the monthly Cincinnati eXtreme Programmers (or “XP-Cinci”, now known as the “Agile Round Table”) meetings. Having worked 17 years in various non-IT roles for a large, commercial airline, I had had enough of BIG.

My formative years as a developer were influenced heavily by fellow XP-Cinci members like Jim Weirich, Mark Windholtz, and Joe O’Brien. Each of these guys, and many others, has a wealth of BIG design experience and yet each has found Agile means more productive, rewarding, and, dare I say it, fun to use not only on their own software projects but those, large and small, that they produce for profit.

So sit back, step away from that Gantt chart, and have fun!

»  Substance: WordPress   »  Style: Ahren Ahimsa