Thursday, April 2, 2009

Finding text in files from the Command-Line

This tip is posted everywhere, but for my love of copying and pasting, here's how to find any text in a directory of files quickly from the command line:

find . -name "*.php" -print | xargs grep "text_to_find"

To break this down:

find . -name "*.php" -print finds all files in the current or sub-directories that has the filename *.php and print out the file name

| This is the pipe. It sends the output of the above find command to the next command:

xargs takes the input from the find command and passes those files to the next command:

grep "text_to_find" searches in each of the files for the text "text_to_find"

Tuesday, March 31, 2009

Kensington Slimblade

Trackballs seem to be a sensitive subject when it comes to computer users. When I mention to people that I use trackballs regularly, I typically get a face of disgust. The usual excuses are: "I can play games 10 times faster with my regular mouse!" or "Trackballs are so awkward!"

For me, I've never found a mouse that gives me the level of control when working in Photoshop or doing any precision work as I have with my trackball. But I don't use just any trackball. Most trackballs have a tiny ball that you maneuver with your thumb, which is totally awkward for me. The rest have a tiny center-mounted ball that's just not large enough to really get any precise control out of.

My trackball of choice is the Kensington series with the large center-mounted ball. Over the years I've owned the Turbo Mouse, Expert Mouse, and as of recently, their new Slimblade.

I was selected to be part of their Slimblade testing program so they sent me one to review and I absolutely love the design of this thing! It's low profile, feels very well-built, and the color scheme is gorgeous.

They've moved the mouse lasers to the side walls so dust doesn't build up inside of it, and they made the ball bearings even smoother than the Expert Mouse.

Scrolling About.

One of the greatest features of the Expert Mouse was the scroll wheel. It was an incredibly intuitive and elegant solution for the lack of scrolling on the Turbo Mouse. The Slimblade took a different approach. They decided to remove the scroll wheel and let you just spin the ball to scroll. I was very skeptical about spinning the ball causing the cursor to move a lot, but it's actually pretty stable during scrolling. It does take some getting used to compared to the scroll wheel, but after a few days it felt very natural. The mouse cursor does move around slightly when scrolling, but overall it's pretty stable.

Ergonomics.

I waited to write this part because I wanted a longer experience with the mouse. At first it was very uncomfortable. The way my hand sat on the Expert Mouse was tilted slightly to the right. When I did that on the Slimblade, since my hand is sitting on the desk instead of the cushion, that hits a pressure point in my hand and it kinda hurt. I seem to have either adjusted my grip or it went away because I don't notice that anymore. I think they really should've shipped this with a wrist rest to help with this problem.

The Software.

One of the things I've always liked about the Kensington trackball series has been the quality of driver software. The previous versions were infinitely customizable, being able to make any button do anything you want. You could even assign multi-click actions so hitting the left and right buttons simultaneously would trigger an event.

The Slimblade has, unfortunately, strayed from this path. In fact the only way you even know the software is installed is a menubar icon. The buttons are all preset functionality: Left-Click, Right-Click, View Mode, and Media Mode. In the two weeks or so that I've been using this mouse, I really haven't found myself using either View or Media Mode.

Media Mode (upper left button) lets you control iTunes. If you use iTunes and don't already use hotkey apps like SizzlingKeys or Synergy, this is nice. I listen to Pandora much more than iTunes lately so this button isn't all that useful for me.

View Mode (upper right button) lets you zoom and pan in apps that are supported. For some apps, like Photoshop, this is useful, yet for other apps, like Safari, not so much. This mouse is very sensitive so it's hard to avoid zooming while you're panning around. I don't think this mode adds a lot of value and I would really like to be able to change the behavior of this button.

Overall, there is almost no customizability in the software and the customization options you are given require editing a text file. Not cool, Kensington. Not cool.

Final Thoughts

If this was my first interaction with Kensington trackballs, I don't think I'd be as much of an enthusiast as I am. The software is severely lacking and the ergonomics really leave something to be desired. If Kensington improves the software and starts shipping this mouse with a wrist rest to match the angle of the mouse, it will be a dream come true, but in it's current form, it feels unfinished.

Monday, March 30, 2009

Python Shell Class Caching

I'm learning Python right now and one of the things that I thought was strange behavior was how, when you first imported a module in the shell, it would essentially be cached for the rest of your shell session. Any changes you made to your class file would not be reloaded until I exited the shell and reopened it.

There is a much simpler way to reload your class file, using the reload() command: reload(module) It would be nice if there were a 'development' mode where it never cached the class files while you were in the shell. Any suggestions?

Friday, March 27, 2009

SafariStand downloads and the Terminal

I love SafariStand. I love SafariStand's ability to organize downloads by date. I hate trying to navigate to the current day's download directory via the terminal. I typically don't delete downloads very often so my Downloads folder tends to get cluttered with a bunch of folders titled '2009-03-11', '2009-03-15', etc.

If you're a heavy terminal user, it can be a pain to get into the current day's folder because tab-completion always stops at '2009-03-' if your folder spans just one month, '2009-' if it spans multiple months, or '200' if it spans multiple years.

I decided to rectify this situation by making an alias to the date command to generate the current date in the same format. It's pretty simple:

In your .profile or .bash_profile file in your home directory simply add the line:

alias today='date "+%Y-%m-%d"'

Then when you're in the terminal, go to your downloads folder and type

cd `today` (note the back quotes around today) (the back quote is shift-tilde)

and it will automatically generate the proper date string and take you right into your folder.