Category Archives: development

On this page:

Setting up Ruby on Rails on a Redhat Enterprise Linux Rackspace Cloud Server

1. Compile Ruby from source.

First, install all the libraries you’ll need to compile Ruby.

yum install gcc zlib libxml2-devel 
yum install gcc
yum install zlib
yum install zlib-devel
yum install openssl
yum install openssl-devel

My particular application has problems with Ruby 1.9.2, so I compiled Ruby 1.8.7 instead. This can be downloaded from ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz

Unpack the source code for Ruby. Configure and install it with:

./configure
make
make install

Add /usr/local/bin to the beginning of your PATH.

2. Install Ruby Gems.

Downloadcd the latest Ruby Gems package and unpack it. I got mine from http://production.cf.rubygems.org/rubygems/rubygems-1.7.1.tgz . Change to the directory and run:

ruby setup.rb

3. Install Rails and rake

gem install rails rake

If all goes well, you should now have Rails and rake.

Troubleshooting:

*builder-2.1.2 has an invalid value for @cert_chain*

Downgrade Rubygems to version 1.6.2 with the following command.

gem update --system 1.6.2

(Stack Overflow)

sqlite3-ruby only supports sqlite3 versions 3.6.16+, please upgrade!

Compile sqlite from source:

wget http://www.sqlite.org/sqlite-amalgamation-3.7.0.1.tar.gz
tar zxvf sqlite-amalgamation-3.7.0.1.tar.gz
cd sqlite-amalgamation-3.7.0.1
./configure
make
make install
gem install sqlite3

LoadError: no such file to load – openssl

  1. Install openssl and openssl-devel.
    yum install openssl openssl-devel
    
  2. Go to your Ruby source directory and run the following commands:
    cd ext/openssl
    ruby extconf.rb
    make
    make install
    

LoadError: no such file to load – readline

yum install readline-devel

Change to your Ruby source directory and run the following:

cd ext/readline
ruby extconf.rb
make
make install

(Code snippets)

You can’t access port 80 from another computer.

Port 80 (the web server port) is blocked by default on Redhat Enterprise Linux 5.5. Edit /etc/sysconfig/iptables to allow it, adding a line like:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Make sure you put it above the REJECT all line.

Load your changes with

/etc/init.d/iptables restart

(Cyberciti)

2011-04-04 Mon 11:06

Running the Selenium IDE testing plugin with Firefox 4

Selenium is a web testing framework that allows you to test web applications involving HTML and Javascript. The plugin hasn’t been updated to indicate that it works with Firefox 4, so you can’t install it directly.

You can use the Firefox Add-on Compatibility Reporter to install Selenium and other Mozilla Firefox plugins that have not yet been marked as compatible. After you install the compatibility reporter and restart your browser, you should be able to install the official version of the Selenium plugin.

Props to the Mozilla support forum for the tip!

2011-04-01 Fri 12:21

Becoming a faster developer

(NOTE: Becoming a faster developer isn’t necessarily the same as becoming a more productive developer. Becoming a more productive developer is better. Speed isn’t everything!)

Following up on my post about typing speed, QWERTY/Dvorak/alternate layouts, and the idea that your keyboard layout probably has little to do with your performance (although it might have a little to do with your happiness), I wanted to think about what makes a fast programmer. People tell me I’m fast. I know people who can pull programs together even faster. We touch-type, for sure, but that’s the least of it.

A huge part of development speed is experience. If you’re familiar with a programming platform, the error messages, the structure, the way things work and the way things are named, you can learn new concepts and write correct code much faster than a newbie can.

What if you’re faced with a new framework? You’ll still get a speed boost if you can relate the concepts to other things you’ve learned. If you can figure out the control structures you need and the debugging techniques you can use, then it’s mostly a matter of translating to the new framework and picking up any quirks or local idioms.

So let’s break it down further. What are small, specific skills that can help a developer get really fast?

  • Touch-typing: Still practically a given. You need to be able to think about your code, not about typing code. If you aren’t yet a touch-typist, sit down and work on that.
  • Speed-reading: This comes in handy everywhere. Much of programming is reading: reading requirements, reading other people’s code, reading documentation, reading logs and debugging output. This is probably more useful than typing at a gazillion wpm. You need to be able to quickly spot the significant parts. Learn how to skim.
  • Working with complex structures: The better you get at understanding complex structures or logic, the faster you can come up with more effective solutions, and the less time you spend going back and forth. You don’t have to do it all in your head. Find systems that work well for you (notes? mindmaps? diagrams?) and use them.
  • Problem decomposition: Breaking big problems down into smaller testable steps can help you make quick progress and keep things manageable. This is also one of those skills that can give you lots of leverage on time. If you can get really good at spotting the core of the problem and figuring out the key parts of the solution, you can get something into place much faster. It’s also a useful skill for testing code thoroughly.
  • Good development practices: Source code control, testing, and all sorts of other development hygiene practices means less time spent fixing avoidable mistakes.
  • Collaboration: If you can get someone else to do the things you’re really slow at so that you can focus on the things you’re really fast at, the team can get much faster. This also includes documenting your work so that people don’t have to reinvent the wheel.

What would you add to this list?

Learning more about Websphere and web service development

So I finally figured out what was wrong with the way I was trying to generate my web services for Websphere 6.1. I’d been using “Generate Java bean skeleton” from the WSDL file, which worked fine for the 6.0 target, but which didn’t work for 6.1. The correct way to do it is to right-click on the service and choose “Generate – Top-down Service”.

I also spent some time figuring out how to correctly use the XSD the IT architect sent me in order to use it for the data types in the WSDL. This is how:

<xsd:import schemaLocation="....xsd" namespace="...">
</xsd:import>

One of the pieces that was missing for me was dealing with namespaces, but once I got my head around XML again, I added some namespaces and got the referred types working.

So I’ve retwiddled our web services and gotten them to work with the new data structures. My test cases pass again. Progress!

2011-03-21 Mon 20:03

Test-driven development and happiness

Me: Happiness is a test suite that passes.
@philiph: Do you practice test-driven development for your happiness?
Me: Why, yes, actually, I do. It gives me a tangible sense of accomplishment and minimizes my mouse-clicking. =)

Developers find their own balance of how much project structure works with them. Some people like seat-of-their-pants coding. Others want detailed architecture diagrams. Me, I’m getting the hang of agile development practices, and I really enjoy using them.

Test-driven development, for example. Yes, I could just plunge ahead and write Drupal code, and I could test it by clicking on buttons and typing into forms. I don’t particularly like using the mouse or doing repetitive actions, so I write tests for functionality and occasionally for web interaction. Tests also mean that  I can check small pieces of functionality before I have to build a web interface. And when something breaks – not if, but when – tests help me narrow down the error.

It’s so satisfying to see the tests pass, too.

There are tests that exercise functionality, and tests that set up test data just the way we like it so that we can demonstrate features or try things out using the web interface. One of my team members showed me a wonderful technique for repeatable, well-structured test data by using a spreadsheet to generate PHP code. I’ve been extending the pattern for other things.

Drupal + Simpletest is awesome. It can’t handle everything, but it makes my Drupal life better. Happy developers write happy code!

Saving development time through virtual appliances

http://farm4.static.flickr.com/3291/2838195408_cd8f049914.jpg
Photo (c) 2008 JakesDad – Creative Commons Attribution Licence 2.0

I’m beginning to be a big fan of virtual images for development work, because they save me from having to have the setup above. I already bring two laptops – don’t need more!

By downloading and customizing an image of a system that is already configured for typical development tasks, I can save myself a lot of administrative time – and keep development work more cleanly separated from the other files on my computer.

Both VMWare and Virtualbox have many virtual appliances available, and you can start using them with the appropriate player. Both VMWare and Virtualbox are free for personal, non-commercial use. I’ve taken advantage of a VMWare licensing program at work, installing VMWare Workstation so that I could take snapshots of my development environment if necessary.

I picked the Turnkey Drupal 6 distribution, a 175MB download. Installing Apache, MySQL, and PHP on Ubuntu is easy, but it was good to be able to take advantage of Turnkey’s support for https and other niceties. I may still have to install everything onto the production server manually, but at least we can do the setup easily. I changed the passwords from the defaults, of course.

I didn’t think it would be this easy. I had avoided virtualization for a while because it had felt slow and clunky the last time I tried it years ago. With 3GB of memory, this tablet PC can run both Windows 7 and the development server images just fine. Running Linux inside Microsoft Windows (instead of the other way around) might have helped, too. Setting up networking was a breeze, too. I chose bridged networking, which made the virtual machine seem like a new computer on the network.

The only quibble I’d like to fix is definitely a nerdy one – I’m back to QWERTY in the virtual machine, because it ignores the Dvorak keyboard mapping I’ve chosen on the host operating system. It’s an easy matter to change this on Linux (“loadkeys dvorak” at the command-line), but an even easier (and more responsive) way to work with this is to use ssh to connect to the virtual image.

Full speed ahead!