5 Useful Mac Apps

I’ll admit it, I am a big fan of applications and an even bigger fan of Mac OS X applications. I even spent months researching which applications I would download and purchase even before I got my MacBook Pro (I’m thinking especially of TextMate).

This article is going not going to recommend the usual list of applications that you find being recommended like QuickSilver or TextMate. Instead I’m going to recommend those applications that I didn’t really hear of before I found them by luck. All 5 of these I use very often and I love them. They are not ordered from best to worst, that would be impossible given the different purposes and different areas that these apps address.

In the words of Bryan Hansen, the developer of Jolt (the first app I list):

The biggest problem for mac apps like this is getting the word out that they even exist.

Here are the players:

1 – Jolt – Bryan Hansen – Free or $5 donation
Jolt Icon
Jolt is a beautiful tool for all laptop users. Its goal is to temporarily prevent the power saving dim that we all experience. You might be watching a video or reading a long article and your Mac will interrupt you by dimming. This simple program solves that problem without interrupting your workflow at all.

The interface is strikingly simple. It sits in your menu bar and with a simple click it will activate. It defaults to 5 minutes but you can set multiple levels from 3 minutes to forever. To access its preference just right click the icon. I found this app useful just a few hours after I downloading it.

2 – cd to – Jay Tuley – Free
I’m a developer who really loves the terminal. I write Ruby/Perl scripts all the time. I have a terminal open 150% of the time I’m on my laptop (that means I have on average 1.5 terminals running at all times).
cd to icon
Seeing that I do so much in the terminal, Jay’s Finder Application is a godsend. Again, a perfectly simple interface, “cd to” is just a button you can place on the Finder’s toolbar. Right now it’s look and feel is just like Mac OS X 10.4 Tiger’s Finder window, but it fits in just fine on my Leopard Finder’s toolbar. With just a click it opens up the Terminal, changes directory to the current directory the Finder was in, and clears the screen so you have a fresh terminal. How awesome is that!? If you can’t think of how much time this will save you, then this isn’t the application for you. But, if you’re sitting there and already struggled this very day trying to find the current path to a directory in one of your Finder windows download this tiny app and struggle again.

3 – Desktoptopia – Desktoptopia Team – Now Free!
I am passionate about my desktop wallpaper. Until I bought Desktoptopia I would spend hours (it makes me cringe thinking about it) looking for that perfect wallpaper on my Windows laptop. Well, now I just click the menubar icon and in seconds I’ll have a really great wallpaper downloaded and set for me. This small investment has been a huge time saver and therefore a very smart purchase for me. You can freely check out most of my wallpapers for the last six months, I am proud of all of them: http://myskitch.com/joep/
my desktoptopia wallpaper

The interface for Desktoptopia is again very simple (seeing a trend with these great apps?). It is a preference pane where you can set general settings to choose the categories of wallpapers and if you want you can have your background change every few minutes. You can enable a menubar icon from which you can choose “Next Background,” rate the background (1-5 stars), and even visit the artists website.

In case anyone is interested the Wallpapers all download to ~/Library/Application Support/Desktoptopia/.Backgrounds/ so you will always have a hard copy. Still many of these wallpapers are submitted by users and so I would be hesitant about freely spreading the Wallpapers without the artist’s permission.

4 – Skitch – plasq – Free (Beta, if invites are not immediate then just leave a comment)
Skitch is simply phenominal at what it does. Skitch takes screenshots using crosshairs, fullscreen shots, iSight pics, simple but useful and fast editing like arrows and text, the list really goes on and on. Those are normally just the basic run of the mill features of image editors but Skitch makes it dead simple. Thats not even close to the good part.
skitch logo

The highlight of Skitch is the fact that it comes with your very own myskitch account. When you sign up with Skitch (very simple) you are given webspace to store your images. The desktop application, again a phenominal interface from the menubar, has a single button you can click that uploads (“web posts”) your image to your myskitch page. From there you can distribute that image freely, share it with friends, make it public, allow people to comment, or use them on your webpage like I do.

The superfast drag-and-drop feature to “Save” the image is integrated right into Skitch’s window design. To give the image a nice name and choose the format (jpg, png…) you don’t even have to open up a dialog box! Its almost too simple and intuitive. There is also a robust history, insanely easy cropping and resizing images, the list of feature just keeps going on and on.

You won’t believe me if you don’t try it yourself. This is one of the few apps I could have really benefited from having on a Windows machine but no such app existed. Lets just say that this little gem has seriously altered and improved my workflow in more ways then one.

5 – TextExpander – Smile on my mac – Free (Donationware)
This slogan is so true it actually isn’t funny:

If you’re not using it, you’re wasting time.

TextExpander example
Since downloading TextExpander I have grown so accustomed to having a shortcut type out my name that when I had to use a Windows computer the other day I had difficulty typing my name. This is not a bad thing, instead it is proof that this little program does what it does so well that I count on it, I depend on it, and it rewards me by making me smile every time I use it and hear the little chime of saving time and keystrokes. (run-on sentence?)

TextExpander makes a short snipper of text like typing “nname” expand to “Joseph Pecoraro” or “bjcom” expand to “http://bogojoker.com”. I have a bunch of snippets for personal things but the most common have to be your name, address, phone, already prepped and ready to go once installed. Adding snippets is a breeze, and to top things off TextExpander even keeps stats on how many characters and how much time it has saved you. I have used just about 700 snippets, expanding to about 7,000 characters saving me about 2 hours worth of typing at 100 Words Per Minute. I can now no longer misspell “tomorrow” (because I just did and I had a snippet fix it for me).

So there you have it. 5 apps that you can use today that I think will directly impact your relationship with your computer. They will make certain things simpler, make you happier, and finally you will be more productive. Enjoy.

mgrep – Multiple Regex Grep – SotD

My newest Ruby utility is called mgrep. It is a multiple regular expression version of grep. Input is processed line by line and each regular expression is said by the user to match or not match. All lines that meet the user’s desires for matching/non-matching regular expressions are printed in the following format: “filename [line number]: line of text.”

This can be taken in a number of different directions. I’m thinking “Partial Matches” meaning one regular expression matches one line in the file and eventually a second regular expression matches a totally different line and if all of these conditions succeed by the end of the file then print out the filename. This sounds more useful and will most likely be in version 1.0.

Here is the current usage:

usage: mgrep [-#] ( [-n] regex ) [filenames]
  #         - the number of regular expressions, defaults to 1
  ( ... )   - there should be # of these
  regex     - regular expessions to be checked on the line
  filenames - names of the input files to be parsed, if blank uses STDIN

options:
  --neg, --not, or -n    line must not match this regular expression

special note:
  When using bash, if you want backslashs in the replace portion make sure
  to use the multiple argument usage with single quotes for the replacement.

The usage is a little confusing seeing as the number of regular expressions on the command line are variable based on another command line switch. All in all though it is rather clear. Options will likely come in the future, much like grep or awk if I get around to it.

Here is an example probably not useful but at least it shows functionality, the line must contain a number, a double letter, and end with a !: [input]

1 ab !
- aa !
1 aa -
1 aa !
oh yah! 1

And when I run my script, I’ll put all the regular expressions in /here/ to make it clearer, this syntax is allowed by mgrep for convenience. Here is what it looks like:

joe[~/sandbox]$ mgrep -3 '/\\d/' '/(\\w)\\1/' '/!$/' input
input [4]: 1 aa !

To show of the –neg or -n option this command will show all the lines that do not have a hypen and still end with a !:

joe[~/sandbox]$ mgrep -2 -n '/-/' '/!$/' input
input [1]: 1 ab !
input [4]: 1 aa !

The script surely be updated soon, but grab it now and try it out:
mgrep – Most Recent Version – Download
mgrep – changelog

Regular Expression Examples

A number of visitors have come to my website using the search terms regex replace. So I thought I would devote an entire article on how to use regular expressions to do a find and replace on a string in some popular languages. Example code is always attractive so lets get to the point! There is example code in Ruby, Perl, Python, Javascript, and Java. [If you have other suggestions let me know or show me in your comments!]

All of the basic examples:

  1. put the string “one two three” into a variable
  2. then use a regular expression and a native function to the language to
  3. transform the original variable’s value to the new string “one 2 three”

Click Here For the Basic Examples

Now you may recognize that in the above examples that regular expressions where not even needed. All we did was find and replace a string and that simple task can be done without regular expressions! So here is a more advanced example without the training wheels.

In the advanced examples:

  1. the string “a1b2c3” [may not need to be stored in a variable] is
  2. manipulated by a [globally replacing] regular expression
  3. resulting in “a11b22c33” [where all numbers, but not letters, are duplicated]
  4. which is stored in a variable

Click Here To Toggle the Advanced Examples

Ruby:

result = 'a1b2c3'.gsub( /(\d)/, '\1\1' )

Perl:

$result = 'a1b2c3';
$result =~ s/(\d)/\1\1/g;

Python:

import re
result = re.sub(r'(\d)', '\\1\\1', 'a1b2c3')

Javascript:

var result = 'a1b2c3'.replace( /(\d)/g, "$1$1" );

Java:

public class RegexTest {
  public static void main(String args[]) {
    String str = "a1b2c3";
    String result = str.replaceAll("(\\d)", "$1$1");
  }
}

Pay strict attention to the number of backslashes required in python, the $1 used in Java and Javascript (however these are also global variables found in Ruby and Perl), and the trailing /g option required in Perl and Javascript for the global replacement. Each language has its own little spin on things.

I hope this helped answer your questions on regular expressions. In case I whet your appetite on Regular Expressions I can point you to my Introductory Article on Regular Expressions and my command line utility rr that allows you to run Ruby regular expression find and replace commands on files, standard input, and even piped input.

Clicky Greasemonkey Menu Script Updated

I noticed that I can’t really live without this script. Clicking those menus is just too difficult. The updates made to Clicky January 19th changed the way they handled their dropdowns. Clicky wrapped them into objects and added a bunch of functionality to make their content updateable via AJAX requests for their new filters. Some spiffy updates but code that I could not use from within Greasemonkey!

So have at it. The user script is available right here.

If you look at the script you will see that I handle opening and closing of the menus much like the Clicky’s object code does it. There is a variable to hold the current open menu if there is one so that opening a different menu closes any other open menu. I only add an onmouseover event and jimmy in my own close code when you click the close menu button. This works around Clicky’s object code without breaking anything that I can see.

rr – 1.1 – In Place Edits and Multiple Files

Less then 48 hours after rr becomes 1.0 it gets a few very handy improvements!

In place modification of files is activated via the –modify (or shorthand -m) option. This means that you can bypass any output redirection and just go straight to modifying the original file. This feature does use filename.tmp as a temp file which it later renames to the original filename. Again if no filenames are specified then input is expected to come from STDIN and therefore the new –modify option will be ignored in this special case.

Another original goal of mine was adding support for multiple filenames. Specifically so that useful shell tricks like *.txt file globbing would work nicely with rr. Well support has been added and it works great with the new –modify option.

The usage message has been cleaned up a bit but here is the very basic usage for all new people.

usage: rr [options] find replace [filenames]
       rr [options] s/find/replace/ [filenames]

I wanted to point out a rather hidden feature. The way I implemented the options is that the ARGV array is actually parsed first for all options and then removes the options before going on to parse the find, replace, and filename arguments. This means that your options can go anywhere on the command line so long as they start with a -.

This presents 1 problem, a workaround, and a question for users. Using the second form of usage, where the find and replace portions are separate argument if your regex or replacement text starts with a “-” the script will interpret it as an option. You can avoid this by using the s/find/replace/ usage (or putting the regex in /regex/ format, which is allowed). But really this boils down to deciding whether or not I am being too liberal with my command line arguments. Since this is a very big fringe condition with a workaround I am going to allow options to be placed anywhere, allowing you to bring up the last command in bash with the up arrow and adding an option to the end of your rr command (like the new -m) to repeat your last command with an option much easier.

rr is always free, Try It Out:
rr – Current Version Download
rr – changelog.txt – Click Here

$ gem install regex_replace

search