Ack, grep for Developers
A relatively new tool in my kit that I’ve come to use very frequently over the last 6 months or so is Ack. Notwithstanding that it is written in my preferred development language, and is maintained by a developer active in the Perl community working on some important projects, like TAP, it really does just save typing while producing Real Purdy output. I won’t go so far as to say it completely replaces grep, at least not without a learning curve and especially for people doing more “adminesque” tasks, but as a plain old developer I find its default set of configuration and output settings incredibly efficient for my common tasks. I’d go into the benefits myself, but I think the “Top 10 reasons to use ack instead of grep.” from the ack site pretty much covers it. To highlight a couple here,
-
It’s blazingly fast because it only searches the stuff you want searched.
-
Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories. Which would you rather type?
$ grep pattern $(find . -type f | grep -v '\.svn')
$ ack pattern
-
ack ignores most of the crap you don’t want to search
- VCS directories
- *blib*, the Perl build directory …
tips
Git commits per contributor one-liner
Just for fun, in the Spree Git repository:
git log | grep ^Author: | sed 's/ <.*//; s/^Author: //' | sort | uniq -c | sort -nr
813 Sean Schofield
97 Brian Quinn
81 Steph (Powell) Skardal
42 Jorge Calás Lozano
37 paulcc
27 Edmundo Valle Neto
16 Dale Hofkens
13 Gregg Pollack
12 Sonny Cook
11 Bobby Santiago
8 Paul Saieg
7 Robert Kuhr
6 pierre
6 mjwall
6 Eric Budd
5 Fabio Akita
5 Ben Marini
4 Tor Hovland
4 Jason Seifer
2 Wynn Netherland
2 Will Emerson
2 spariev
2 ron
2 Ricardo Shiota Yasuda
1 Yves Dufour
1 yitzhakbg
1 unknown
1 Tomasz Mazur
1 tom
1 Peter Berkenbosch
1 Nate Murray
1 mwestover
1 Manuel Stuefer
1 Joshua Nussbaum
1 Jon Jensen
1 Chris Gaskett
1 Caius Durling
1 Bernd Ahlers
git spree
She sells C shells by the seashore
In contrast to my previous post on tabs in vim, here’s a different way of managing multiple files, multiple SQL console sessions, multiple nearly anything. This works with any program that behaves well with regard to Unix job control, and really allows Unix to shine as an IDE in its own right. The emphasis here will be on using whatever tools are suitable to do the job, rather than on one specific editor. Note that the details given here will not work very well for network programs that assume a constant connection like an IRC client. However, at least the Postgres and MySQL consoles both support this feature, and they’re the only “networked” applications I can imagine using in this way. This post will focus more on a way of thinking than on technical know-how, though there is a bit of how-to mixed in.
Most readers are familiar with backgrounding a task at a Unix terminal with ^Z and then bg. Something that is less common, at least in my experience (in favor of GNU screen and the like), is using shell job control for anything more than detaching a running program from one’s terminal. When applied liberally, the tactic allows one to harness the power of Unix all via one login. To …
tips
End Point SEO with Linkscape
Linkscape was released in October of 2008 and is SEOmoz’s collection of index data from the web that currently contains 36 billion URLs over 225 million domains. You must have a pro membership to access advanced reporting, but without a pro membership you can access basic data such as mozRank (SEOmoz’s own logarithmic metric for page popularity) for the url, number of links to a url, number of domains to a url, and mozRank for the domain.
For example, I ran a basic report on www.google.com and found:
-
The mozRank of http://www.google.com/ is 9.36 out of 10
-
There are ~96.8 million links to http://www.google.com/
-
There are ~1.6 million domains linking to http://www.google.com/
More interesting data on www.facebook.com:
-
The mozRank of http://www.facebook.com/ is 7.40 out of 10
-
There are 0.9 million links to http://www.facebook.com/
-
There are 60,000 domains linking to http://www.facebook.com/
Because I haven’t given justice to describing Linkscape, please read more about Linkscape, or see Linkscape Comic for visual enhancements.
Case Study
In an effort to examine and improve End Point’s search engine performance, I pulled together some snippets of data from Linkscape for …
seo
Vim tip of the day: tabbed editing
How many tabs does your browser have open? I have 17 tabs open in Firefox presently (and opened / closed about 12 while writing this post). Most users will agree that tabs have changed the way they use the Web. Even IE, which has spawned a collection of shells for tabbed browsing, now supports it natively. Tabs allow for a great saving in screen real-estate, and in many cases, better interaction among the various open documents. Considering how much time programmers spend in their text editors, it therefore seems logical that the editor should provide the same functionality.
And the Vim developers agree. Although Vim calls them “tab-pages”, the functionality is there, waiting to be used. Before reading any further, ensure that your Vim supports tabs. You can do this by running this command, on anything resembling Unix:
vim --version | fgrep +windows
If you don’t see any output, check your vendor’s packaging system for something like vim-full
. If you don’t have a Vim available with the windows feature, go get one and come back.
Now that you can use tabs, let’s get started. One way to open tabs is via the command line. Vim uses the -p
option to determine how many tab-pages to open. …
tips vim
Interchange jobs caveat
I’d used Interchange’s jobs feature to handle sending out email expirations and re-invites for a client. However I found out the hard way that scratch variables persisted between individual sub-jobs in the job set. I’d tested each of the two sub-jobs in isolation and had had no issues.
This bit me because I’d assumed each job component was run in isolation and variables were initialized with sensible (aka empty) content. In my case it fortunately only affected the reporting of each piece of the job system, but definitely could have affected larger pieces of the system.
The lessons? 1) Always explicitly initialize your variables; you don’t know the ultimate context they’ll be run in. 2) Individual component testing is no substitute for testing a system as a whole; you can reveal bugs that would otherwise slip through.
interchange
Vim Tip of the Day: running external commands in a shell
A common sequence of events when editing files is to make a change and then need to test by executing the file you edited in a shell. If you’re using Vim, you could suspend your session (ctrl-Z), and then run the command in your shell.
That’s a lot of keystrokes, though.
So, instead, you can use Vim’s built-in “run a shell command”!
:!{cmd}
Run a shell command, shows you the output and prompts you before returning to your current buffer.
Even sweeter, is to use the Vim special character for current filename: %
Here’s :! %
in action!


A few more helpful shortcuts related to executing things in the shell:
:!
By itself, runs the last external command (from your shell history):!!
Repeats the last command:silent !{cmd}
Eliminates the need to hit enter after the command is done:r !{cmd}
Puts the output of $cmd into the current buffer.
tips vim
Emacs Tip of the Day: ediff-revision
I recently discovered a cool feature of emacs: M-x ediff-revision. This launches the excellent ediff-mode with the defined version control system’s concept of revision spelling. In my case, I was wanting to compare all changes between two git branches introduced several commits ago relative to each branches’ head.
M-x ediff-revision prompted for a filename (defaulting to the current buffer’s file) and two revision arguments, which in vc-git’s case ends up being anything recognized by git rev-parse. So I was able to provide the simple revisions master^
and otherbranch^{4}
and have it Do What I Mean™.
I limited the diff hunks in question to those matching specific regexes (different for each buffer) and was able to quickly and easily verify that all of the needed changes had been made between each of the branches.
As usual, C-h f ediff-revision is a good jumping off point for finding more about this useful editor command, as is C-h f ediff-mode for finding more about ediff-mode in general.
git emacs