Tuesday, August 28, 2012

A Roadmap for Learning Web Development

Damien Roche gave some excellent advice (IMHO) to the question, "Which language to learn for Web Development Ruby or Javascript?". His last comment is the most critical: "If you don't enjoy learning new things, you're in the wrong game."

You know some Ruby, start there. Using RoR will have a positive impact on your ability to develop web applications. Although stuff like Compass, SCSS, Coffeescript isn't required, I'd certainly advise you delve into them once you're familiar with the underlying languages.

A good roadmap would be:
  • HTML, HTML5
  • CSS, CSS3
  • Javascript, jQuery
  • Ruby, Rails
  • SQL
Once you are familiar with the above, and if you plan to use RoR, these are essential:
  • RVM
  • Bundler
  • Capistrano
  • Rails console
Along with that, you will most definitely want to be able to use:
  • IDE - Eclipse, Rubymine
  • Git
  • Linux
A web developer who primarily works with Rails and Linux will have been exposed to and know (some more than others) all of the above. It is absolutely critical that you understand how these technologies compliment each other. 1,2,3 are evergreen - they will never 'go out of fashion'. So start there.

Once you've done all that, you might want to move up to the next level and learn:
  • HTML -> Haml or Slim
  • CSS -> SCSS and Compass
  • Javascript -> Coffeescript
  • Rspec and Cucumber
As you can see, there are tonnes of different tools at your fingertips. One skill which surpasses all others: the ability and enthusiasm to educate yourself. If you don't enjoy learning new things, you're in the wrong game.

Friday, August 3, 2012

apt-cyg: command line installer for Cygwin

apt-cyg  is a command-line installer for Cygwin which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get.

Update Ruby from source for Cygwin

Edit: Added LibYAML and OpenSSL extension instructions from http://saltnlight5.blogspot.ca/2011/11/i-like-to-use-ruby-that-comes-with.html

Make sure Cygwin OpenSSL packages are installed.

Run Cygwin console as Administrator if using Windows 7, Cygwin was installed as Administrator and UAC is enabled, install may need admin permissions and Cygwin doesn't have a "sudo" command.

If you get fork errors, try rebasing Cygwin.

If rebasing fails, try deleting C:\cygwin\etc\rebase.*

http://permalink.gmane.org/gmane.os.cygwin/135305

> $ /bin/rebaseall
> /usr/lib/perl5/5.14/i686-cygwin-threads-64int/CORE/cygperl5_14_2.dll: skipped because nonexistent.

And this is caused by a minor perl packaging problem. You can simply
ignore this warning.
I'll fix it with the next perl update.
--



$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [i386-cygwin]
$ cd /tmp
$ wget http://pyyaml.org/wiki/LibYAML
$ tar xvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4/
$ ./configure && make && make install
$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
$ tar xvf ruby-1.9.3-p392.tar.gz
$ cd ruby-1.9.3-p392.tar.gz/ext/openssl
$ ruby extconf.rb
$ make && make install
$ cd ruby-1.9.3-p392/
$ ./configure && make && make install
$ wget http://production.cf.rubygems.org/rubygems/rubygems-2.0.3.tgz
$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [i386-cygwin]







Saturday, July 14, 2012

Finished Rails Tutorial, but I'm still hungry!

Power House below the San Francisco Cable Car Museum - courtesy Christian Mehlführer
After 3 months of part-time slogging I've made it to the end of Michael Hartl's excellent (and free!) Ruby on Rails Tutorial. I really appreciated Hartl's inclusion of the whole Rails workflow, from installation and config, through TDD (test-driven design) and BDD (behaviour-driven design) with RSpec, Capybara and Cucumber, source control with git on Github, and a taste of CSS and Ajax, to actual deployment on Heroku. In fact, you can see the results of all this work at https://furious-cloud-4562.herokuapp.com/.

Along the way I learned a lot, with some side trips into setting up a development environment and finally coming to grips with Vim. It was a bit like I imagine driving a San Francisco cable car - I got where I was going, over lots of hills and curves, in relative ease and comfort, by pulling a few levers (typing in code) at the right time and watching the results roll by. 

But I could tell there was something "under the street" pulling me along, like the power house under the San Francisco Cable Car Museum - lots of big machinery, moving fast, with cables and gears disappearing into dark, unexplained tunnels. I think the next step, now that I've had a ride around on the Rails car, is to step down into the motor room, with conductor David A. Black's book in hand, to get a better understanding of the Ruby engine that drives everything. 

I found the end-of-chapter exercises a bit daunting, especially without an answer key to check against once I'd make my best attempt at it. I found some answers, often for older versions of the tutorial, on StackOverflow and the now-unsupported Get Satisfaction support site for the Rails tutorial.

I really like the BDD testing approach, and I'd like to delve into that next, but I haven't found much online beyond the RSpec documentation (which appears to be generated by rspec tests), a new "gamified" RSpec tutorial at Code School that I haven't tried yet (opinions, anyone?), and a now outdated book from the usually excellent Pragmatic Programmers. Again, I am loathe to spend time and money on a book that was published more than 2 years ago, given the rapid velocity of code changes to the Rails ecosystem. 

Tuesday, June 26, 2012

Online Coding and CS courses

In a comparison of seven (eight, actually) of the current crop of online dev schools, Chris McConnell at DailyTeckk notes the topics available for study (Web dev, programming), languages used (mostly Python and JavaScript) and costs (free to monthly subscription):
Two more notable sites I've found:
Edit: Steampunk Nancy Wu notes a couple of other sites in her survey of the online learning landscape:
If you've come across any other high-quality online learning sites, that you've personally tried and want to recommend, leave a comment here!

Wednesday, May 30, 2012

Friday, May 25, 2012

Ruby one-liner: rename files

I wanted to strip a 20-character prefix, starting with the characters "IP_", from from a dozen XML files in a directory. Each file has a value of a different length following the prefix, e.g. "IP_stuff_foo.xml", "IP_stuff_bargain.xml", etc. I could probably do this by hand, or with a Windows batch file, but seeing as I'm learning Ruby (again), I thought I'd try to get it down as a Ruby one-liner, and here it is:

ruby -e 'Dir.glob("IP*.xml").each { |f| File.rename(f,f[24..-1]) }'
  • ruby -e calls Ruby to -"e"xecute the code in single quotes
  • Dir.glob("IP*").each finds all files in the current working directory that start with the string "IP". The glob() method returns an Array object, e.g. ["IP_foo.xml", "IP_bargain.xml", etc.], so the Array each() method returns "each" element in turn.
  • Each file name is passed in turn into the variable f in the block { ... }, where the File.rename() method does its magic.
  • File.rename takes two parameters, the name of the file to be renamed, and the new name for the file.
  • The new file name is a substring of the characters following the 20 character prefix. The substring is created by returning the remainder of the string after counting backwards, "-1", for "20" characters, f[20..-1].
  • Once File.rename() gets the substringed value, it renames the file.