Thursday, November 27, 2008

Typing? I'm a programmer not a secretary.

This last week has seen a few posts on the necessity, or lack thereof, for good touch typing skills.



I originally was going to say something along the lines of "I think it depends on how you view programming."  I was then going to differentiate between whether you just view programming as a job (where you are looking to scrape by with minimum investment), or a skill/craft/art to be cultivated.

But in the process of assembling my ideas, I thought back to how I learned to touch type.  I wanted a job that at the time seemed to pay pretty decent.  However, the job required a minimum typing speed of 40WPM.  I was a 2 finger typist up till that point, which wasn't going to cut it.  Since I wanted the job I put forth some effort.  In about 1 month, using some free typing tutor programs, I learned to touch type sufficiently to pass the test and get the job.  Once on the job further increases in speed and accuracy came.  

The glorious job that prompted this investment of effort was data entry.  It was boring as could be.  Really.  If you have never done data entry yourself it would be hard to imagine the level of boredom involved.  There was no craft or art to it, just glossy eyes and sore wrists.

Now programming is not "just typing".  It's not just entering characters into a buffer.  Believe me, I speak from experience, it is not just data entry.  So a 10x improvement in your typing speed will not equate to a 10x increase in your productivity.  Hopefully between all that typing, programming requires you to stop and think.

Nevertheless, whether you use some auto-complete super-fancy intellisensical snippet-fu brain scanning IDE or a bare bones text editor, you most likely use a keyboard as your central physical tool to transfer your thoughts from your brain into the computer.  If that is the case, even if programming is just your "job", you owe it to yourself to put forth a little bit of effort and learn to touch type. 

It really is worth the effort, and the initial awkwardness.  If you don't know how to touch type you won't understand until you do.  There is something, well, just "cool" about being able to see words appear on the screen as you think them without giving any conscious thought to directing the individual fingers and keystrokes.  

If you are going to use a tool on a daily basis, I can't imagine any reasonable argument against taking the time to learn to use it well.

Saturday, November 8, 2008

Knowing Your Languages

You may only speak one language, but how well do you know your tools?  There are likely many similarities between learning a language and learning the tools you use daily.

Today I was thinking about the difference between someone who is just learning a spoken language and someone who knows it well, and how this may at times be seen by their knowledge of it's vocabulary.  For example, imagine someone explaining "I need a tool that you use to hit those little metal things that connect two pieces of wood together.  It has a wooden handle about 12" long and has a metal part on top.  You know?  The tool that people who build houses use."

Do you know what tool they are talking about?  Probably.  When I was learning Spanish, this is the sort of description I would find myself having to use at times. (To all the patient people who put up with me, Thank you.)

Of course, a person who knew the language well could have conveyed the same thought more concisely and clearly: "I need a hammer."

This same idea goes beyond spoken language.  

I use VIM on a daily basis.  Until recently my VIM vocabulary consisted of :wq, dd, i, /, :%s and esc.  Not a vary wide vocabulary at all for such a powerful tool.  I could get most anything done, but it was more like that first long-winded description of a hammer.  I am continuing to work on expanding my VIM vocabulary, and in doing so finding that what previously took many keystrokes can now be done nearly instantly with a single command.

However, the real value of a rich vocabulary is much more than simply the ability to be concise.  A rich vocabulary allows you multiple options to express your thoughts depending on the intended goal.

Instead of simply stating that it was "humid", a story-teller may choose to describe the air as "thick with moisture, soaking one's clothes and sapping one's strength."  Not as concise, but perhaps adding important details.

The same is true with our programming language vocabulary.  The goal of a rich vocabulary in Ruby, Erlang, or (insert your favorite language here)  is not always to write the least lines of code.  Our goal may be to increase maintainability, expose intentions, improve performance, etc.  By improving our vocabulary and grasp of the language, we are able to express our thoughts both efficiently and in the way that best fits the specific situation at hand.

How is your vocabulary with the tools that you use?  What are you doing to improve?


Saturday, September 27, 2008

Remove Gems By Prefix

If you are working with Merb or DM you know that approximately a gazillion gems are involved.  When, for whatever reason, I want to remove them it is a pain to do by hand.


Here is a simple script to help:

#!/bin/bash
prefix=$1
gem list --local | grep $prefix  | awk '{ print $1 }' | xargs sudo gem uninstall

I saved mine as remove_gem_by_prefix, gave it executable permissions and placed it in my path.

Now I can issue the commands:

$ remove_gem_by_prefix merb

or 

$ remove_gem_by_prefix dm

And they all get blasted.  You do need to be careful to make sure the prefix you provide is unique to the gems you wish to remove.

Monday, September 15, 2008

Git-O-Mator

Inspired by Rein Henrichs Hack && Ship, I have created Git-O-Mator.


Git-O-Mator is more name than these 2 simple scripts deserve, but what fun is naming small?

Git-O-Mator can be found on GitHub, and contains the scripts new_repo and hack.  

New_repo
New_repo was originally mentioned in the last blog post "Quick Remote Git Repository Creation Script", and has the syntax of:

new_repo foo

Which will create a Git repository locally and on a remote host account that you configure.

Hack
Hack is very similar to Hack && Ship.  Syntax is:

hack on

This will automatically switch to the default branch which you can easily configure. Alternatively you can use:

hack on foo

Where "foo" is the name of the specific branch you wish to use.  If the branch does not exist, it is created.  

To rebase with the master, you have:

hack sync

To merge and push to your remote repository:

hack push

It also supports Rein's ssp (Simple Software Process) with:

hack ssp

Which is equivalent to hack sync && hack push.  If you prefer hack sync && rake && hack push, then you may use the -t flag for testing:

hack ssp -t

Silly little experiment.  If you see room for improvement, feel free to fork and improve!

Saturday, September 13, 2008

Quick Remote Git Repository Creation Script

If you are using Git for your source code management, GitHub is an awesome tool. It especially shines for public projects where you freely allow others to fork your code and possibly pull patches back in.

Sometimes I'm just working on a project that I would prefer to keep in a private repository. GitHub provides paying accounts with such an option. However, I already have hosting accounts that are terribly underused. Here is a little script I use to create a remote git repository on one of my VPS accounts that I can then pull from and push to.

Prerequisites
A hosting account which you can ssh / scp into.

The Script

$ vim new_repo

#! /bin/sh
PWD=`pwd`

# You must adjust these variables for your specifc hosting account.
# Remote user you will connect as.
REMOTE_USER="admin"
# The IP address you will SSH / SCP to.
REMOTE_HOST="123.456.123.456"
# The remote path you wish to store your .git repositories in.
REMOTE_REPO_PATH="/home/admin/repos/"

if [ -d $1 ]; then
  echo "EXITING: Local directory '$1' already exists."
  exit 0
else
  mkdir $1
  cd $1
  git init-db
  touch README
  git add .
  git commit -m "Initial Repository Creation"
  cd ..
  git clone --bare $1/.git $1.git
  echo "** Copying new repository $1.git to $REMOTE_HOST:$REMOTE_REPO_PATH"
  scp -r $1.git $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH
  rm -rf $1.git
  rm -rf $1
  echo "** Cloning locally at $PWD/$1"
  git clone $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH$1.git
fi

exit 0

Or get it from GitHub

http://github.com/jpease/git-o-mator

Configuration

Of course, you will need to REMOTE_USER="admin" with an actual user on your hosting account, adjust REMOTE_HOST="123.456.123.456" to point to your accounts IP address, and edit REMOTE_REPO_PATH="/home/admin/repos/" with whatever path you wish to contain your Git repositories.

Once that is done, provide executable permissions.

$ chmod +x new_repo

That's it. Now if you execute:

$ ./new_repo testing

You will end up with /home/user/repos/testing.git on your remote host, and ./testing locally. From ./testing you can git push to send commits to the remote repository, and git pull to retrieve from the remote repository.

If you see room for improvement, I'm sure there is some, please leave a comment with your revision!

Saturday, August 30, 2008

Compiling Nginx on OS X Leopard in 5 minutes

I went to compile Nginx on my laptop this evening, and couldn't find a how-to for Leopard. Well at least not on the first page or 2 of search results.

Danger Weary Traveller!

I happen to be running OS X version 10.5.4 build 9E17.  

If you are running something different, these directions may fail.  In fact, for all I know your computer may actually blow-up.  Yes, as in burst into flames and melt into a smoldering heap of plastic mush.  Compiling stuff really is that scary.  Hide the children.  Don eye protection.
 
False Advertising Disclaimer
Whether it will really take you 5 minutes or not probably depends on your processor and whether or not your copy & paste skills are up to par.  But seriously, it took me longer to write this post than to do the actual install.

Related Sites
Official Nginx Site
Nginx Wiki
Official PCRE Site

Satisfy PCRE Dependency
Nginx requires PCRE to be installed.  PCRE stands for Prank Calling Really is Evil, or something like that.  But whatever it is, Nginx thinks it just can't live without it.

$ sudo mkdir -p /usr/local/src
$ cd /usr/local/src
$ curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz
$ tar xvfz pcre-7.7.tar.gz
$ cd pcre-7.7
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ cd ..

Install Nginx
$ curl -O http://sysoev.ru/nginx/nginx-0.6.32.tar.gz
$ tar xvfz nginx-0.6.32.tar.gz
$ cd nginx-0.6.32
$ ./configure --prefix=/usr/local --with-http_ssl_module
$ make
$ sudo make install

Now if you ask:

$ which nginx

You should receive the answer /usr/local/sbin/nginx

If not, you probably need to add /usr/local to your PATH.

Nginx will setup a default index.html file in /usr/local/html. The default nginx.conf file will be in /usr/local/conf and will be set to serve this index.html file. To start Nginx:

$ sudo nginx

And finally, to see the fruits of your labors open your favorite browser and navigate to http://localhost

Next you get to configure Nginx to serve up whatever it is you want to serve. But that search query will already provide you with many, many results...

Wednesday, July 16, 2008

The Real Goal of Education

Is education about memorizing facts? No, it's about learning to learn. It's about learning how to think.

"...developers today code in something called Python, but when I was in school C was all the rage. The need for reasoning, though, remains constant..." - Our Googley advice to students: Major in learning