Git Blame: List a Particular Author’s Files Across a Code Base

My goal: to have git tell me which files across the breadth of our current code base have lines of code in them that are attributed to a particular author.

My googling for a script came up with bubkes, so I decided to write my own and share that on the internet. No doubt there’s a better way of doing this, and no doubt there’s a better bash script possible (my bash scripting skills are rudimentary at best), but what I did does do the job.

Here’s the bash script:

#!/bin/bash

matchGitBlame() {

	if [[ "$1" == *$2* ]]
	then
		local count=`grep -o "$2" <<< "$1" | wc -l`

		if [ $count -gt 0 ]
		then
			echo "$count : $2 : $3"
		fi
	fi
}

files=`find . -type f`
name=$1
name2=$2

for file in $files
do
	blame=`git blame $file`
	matchGitBlame "$blame" "$name" "$file"
	matchGitBlame "$blame" "$name2" "$file"
done

If you execute the script like so (the script works with one or two author names as attributes):
./blame-script.sh authorName1 authorName2 > blame-script-results.txt && sort blame-script-results.txt -rVo blame-script-results.txt

you should find in the file named blame-script-results.txt something like the following:

180 : authorName1 : ./Breadcrumb.java
43 : authorName1 : ./ManagementTrail.java
41 : authorName1 : ./DashboardTrail.java
24 : authorName2 : ./NavigationTabsPanel.java
17 : authorName1 : ./DropDownMenuPanel.java
5 : authorName2 : ./ManageReportDropDownMenuPanel.java
1 : authorName1 : ./CrumbItem.java

Philip Roth on Politics in Art

From what I consider Roth’s best book, I Married A Communist:

“Politics is the great generalizer,” Leo told me, “and literature the great particularizer, and not only are they in an inverse relationship to each other – they are also in an antagonistic relationship. To politics, literature is decadent, soft, irrelevant, boring, wrongheaded, dull, something that makes no sense and that really oughtn’t to be. Why? Because the particularizing impulse is literature. How can you be a politician and allow the nuance? As an artist the nuance is your task. Your task is not to simplify. Even should you choose to write in the simplest way, a la Hemingway, the task remains to impart the nuance, to elucidate the complication, not to deny the contradiction, but to see where, within the contradiction, lies the tormented human being. To allow the chaos. To let it in. You must let it in. Otherwise you produce propaganda, if not for a political party, a political movement, then stupid propaganda for life itself — for life as it might itself prefer to be publicized.”

Best-of-Three Coin Toss: The Most Likely Way to Win

Always pick whatever side of the coin comes up first, i.e. if heads comes up on the first toss, always choose heads thereafter.

The reasoning: There’s probably some kind of minimal bias one way or another in the coin or in the tosser’s toss. Assuming there’s no data to help you out beforehand for determining the bias, as soon as you get your first piece of data in the form of the first coin toss, chances are the bias is towards whatever side of the coin turns up.

The complication: If the probability distribution is 90% heads and 10% tails and tails happens to come up up first, well, you’re very likely to lose a best-of-three coin toss series by always choosing tails. But if no one actually knows the probability distribution beforehand, you’re better off always choosing the side of the coin that comes up first for a short coin-toss series. Larger coin-toss series, i.e. a best of twenty series, will mean that if the bias is sufficiently skewed, it is indeed better to change your coin-flip choice in light of results.

Top Ten Prince Songs You Might Not Have Heard

Prince is coming to Melbourne, and on Monday night I’ll be five rows from the stage with a iridescent smile on my face and the funk in my hips.

The last time Prince was in town, his jam on All The Critics Love You In New York during the encore was the highlight, even if only diehards such as myself would have known of the song. And that’s generally the problem for diehards attending the big shows of the big names: they will have already heard the hits done to death and could do with their own personal favourites getting a run rather than the same-old same-old.

So here’s my personal top ten selection of B-sides and album tracks that I very much doubt I’ll hear Monday night, but like All The Critics Love You In New York managed to do the last time around, perhaps one of them will sneak into the show.

1. Erotic City

Perhaps the greatest B-side ever put down on vinyl.

Erotic City was literally and figuratively on the flip side to Let’s Go Crazy. No doubt Prince delighted in the thought of unsuspecting kids turning over their newly purchased single of good time funking rock to discover a sinuous, spare, almost mechanical dance song that would revolutionise club music and shock the bejesus out of people who say “bejesus”.

Ridiculously good.

2. PFUnk

The best that Prince can do at this stage of his career is a killer song on a mediocre album. But like so much of Prince’s best work, PFUnk didn’t even appear on an album.

PFUnk is Prince’s rather ungracious response to the rebuke he suffered after issuing legal notices to the relevant parties ordering any product or image of his to be taken down from the internet. Ironically enough, the song was an internet-only release. Happily enough, it was the best thing he’d done in years.

PFUnk is a huge, one-man Funkadelic jam — over seven minutes long; a hard rock chorus, skeletal space-age funk verses; multiple voices, multiple beats; killer solos, killer horn fills; false ending, latin-jazz outro. All that and it features a series of the hardest ones in the business throughout the chorus (the four is silenced every second bar so the one hits harder than a bomb).

3. The Ballad of Dorothy Parker

The Ballad of Dorothy Parker is Prince’s paean to Joni Mitchell, a feminine folk funk classic that’s the equivalent of a fresh summer kiss. And like When Doves Cry, Prince renders a full rhythmic symphony out of programmed drums that make the sparseness of the instrumentation noticeable only in retrospect.

4. Tamborine
Not content with too-fast corvettes as code for sexual frustration (is Little Red Corvette the only smash hit to have been about premature ejaculation?), Prince turned to tambourines that he dreamed being inside of.

One can only assume those dreams were heady stuff — they’re accompanied by manic drums, eastern melodies evoking harems and yet another demonstration of how well Prince can scream.

5. Lady Cab Driver

Prince usually celebrates sex. On Lady Cab Driver, not at all.

Prince brings the funk, but it’s a cold funk, mechanical, emotionless, like the sex he’s seeking. And when he finds it, the frustrations pour out with the climax.

6. New Position

It’s a throwaway song, probably something Prince laid down in an inspired hour or two of fun, and its infectious, slinky and sexy joy should have anyone heading to the boudoir to try out a new position.

7. Irresistible Bitch
Another ridiculously good and ridiculously explicit B-side. So spare that every little line is a memorable hook.

8. Feel U Up

As above, a signature B-side.

9. D.M.S.R.

Some of the slinkiest synthesisers on record — a party starter.

10. 17 Days

Erotic City eclipses its A-side, Let’s Go Crazy. 17 Days can’t do the same against When Doves Cry, but it’s killer nonetheless.

Also continues Prince’s fine fascination with prime numbers: 1999, 7, “17-year-old boys and they’re idea of fun” in Sign O’ The Times, 3121, 1+1+1 is 3, “23 positions in a one-night stand” in Gett Off, 3 Chains Of Gold, 17 Days, “it’s been 7 hours and 13 days” in Nothing Compares to U, and 5 Women.

And for bonus joy, here’s Living Colour’s rendition:

And the honourable mentions: Housequake, Let’s Work, Adore, Sister, Forever in My Life, Girls and Boys, Hot Thing, I Love U in Me, Do U Lie?, Vibrator, G-Spot, 5 Women, Joy in Repetition, Crystal Ball, Eye No, Damn U, Feel U Up, Girl, La, La, La, He, He, He, A Love Bizarre, Scarlet Pussy, Crystal Ball, It’s Gonna Be A Beautiful Night, Sexy Dancer, Bambi, She’s Always in My Hair, Scarlet Pussy, Hello, 1+1+1 is 3, Party Up, How Come U Don’t Call Me Anymore?, Starfish and Coffee.

Literature and Australia

There is no Australian literature, no Russian literature, no French literature; there is only literature. But over at the Age, Michael Hayward reveals, despite working in publishing, how parochial and uncritical he is:

In 2011, in not a single course in the whole country were students asked to read Henry Handel Richardson’s The Fortunes of Richard Mahony. This is the equivalent of not one Russian university teaching Anna Karenina, of Madame Bovary going untaught in France.

The real shame is that in literature departments, where people supposedly have a love of literature and have developed the ability to critically appraise it, they do not read Anna Karenina and Madame Bovary and Hamlet and Don Quixote and The Leopard and American Pastoral and Love in the Time of Cholera as the basis for all courses. The real shame is that anyone could suppose that The Fortunes of Richard Mahony touches Anna Karenina and that they are both equally deserving of study in a literature department.

Perhaps to prove my point, the very next sentence in Michael Hayward’s piece is this:

It is a rampageous scandal, to borrow a coinage from HHR  herself.

Rampageous scandal is hardly a bon mot worth quoting, and one only hopes it’s not the most felicitous turn of phrase in Henry Handel Richardson’s oeuvre.

A Link Between Unphonetic Orthography and Homophony?

Considering the number of languages in the world, I really don’t have much to go on, but my impression is that the more homophonous a language’s lexicon, the more unphonetic its writing system.

Here are some languages that I have some acquintance with that I’ve grouped according to their relative homophony and orthographic phoneticism, from the least homophonous and most phonetic to the most homophonous and least phonetic:

Group 1: Spanish, Italian, Portuguese, Greek, Russian and Finnish.
Group 2: English and French.
Group 3: Languages using the Chinese writing system and Japanese.

This grouping I freely admit is purely impressionistic: I have no hard data on the amount of homophones in each language, although the relative phoneticism of the writing systems I can say with confidence is about right.

The link that I’ve conjectured, if it does indeed exist, would seem to make sense. Written and spoken languages are different — you don’t often say what you write and vice versa — partly (mostly?) to take advantage of the particular properties of pages and eyes, voices and ears; so it shouldn’t necessarily come as a surprise that homophones need further elucidation on the page and a move away from pure phoneticism becomes desirable.

I think Korean would be one language to go against the presumed trend — its writing system, Hangul, is deeply phonetic while having to deal with a number of homophones that come from Chinese loanwords.

I also suppose that Korean illustrates another linguistic trend: the later a writing system’s invention or adaptation for a specific language, the more phonetic it is designed to be from the outset, and the less time has passed for the spoken language to have drifted from how it’s written down.

Of course, take this with a large, unsubstantiated grain of salt: it’s all speculation based on the private musings of a very amateur linguist, none of which is supported even by a Wikipedia page written by a prankster.

Sade @ Rod Laver Arena, 2nd December, 2011

Countless people would have looked twice at Sade’s name and assume it a prank when she first came to prominence in the mid-eighties. No one need look twice these days: Sade is pronounced her way first, the marquis be damned.

Thirty years since the heady days of Smooth Operator and Sade still pulls a sizeable crowd, and a much cherished one at that: the kind that still pays full-price for music. Although Sade is an understated performer and her between-song patter is mostly rehearsed, the theatrical elements of her show — video projections, choreography, costume changes, stage effects — combined with an overlong absence from these antipodean shores make for an entertaining evening.

The night begins with Soldier of Love. The song incorporates a mechanised, industrial feel that is a slight departure from her usual fare, and the whole production plays on it: the performers emerge from the depths of the stage on the beat; the band synchronise their movements in lock step; Sade coolly hams it up; the lights accent the snare drum pounding on the two and four.

These theatrical elements are generally a clever touch the whole night through; a nonsensical video providing the back story to Smooth Operator while affording time for an obligatory costume change, however, is not. Regrettably, neither is the song’s rendition a great success — Smooth Operator feels limp and rushed. But no matter: soon after, an atmospheric rendition of Is It A Crime elicits the greatest response of the night, the slow burn of the verses that build to the chorus that goes somewhere close to emotional a welcome change from the general restraint of Sade’s material.

The relaxed funk of Paradise has a handful of the audience on their feet, and when the song breaks down into a sanitised, adult-oriented hip hop section, everyone gets on up. Sade wisely leaves the stage to her two back-up singers who have the crowd responding to their cliched calls. It’s lightweight and ridiculous; nonetheless, it’s fun.

We’ve been told we’re loved, we’ve heard the hits; while she never commands the stage, Sade is a gracious performer, and, smartly, she doesn’t rely on her intimate, understated music alone to entertain in a venue as vast as Rod Laver Arena. Her urbane exotica and the show’s production are all well done and — dare I say it — a smooth operation indeed.

Bioy Casares and Borges

Bioy Casares kept a record of the very many encounters and meetings he had with firm friend Borges in Buenos Aires. These records were edited and published in a 1600-page behemoth simply titled Borges, a title which does not definitively alert the unsuspecting Amazon shopper that its contents are in Spanish.

Although I read Spanish well enough, and although I feel the need to complain about previous translations of both Borges’ and Bioy Casares’ works, I would have much preferred the book in English translation for a non-Argentinean audience, where footnotes on literary and political figures I’d never heard of would have been abundant and the strain of reading such a long work in Spanish could be avoided. Unfortunately, no such English translation appears to be available.

Nevertheless, I do occasionally dip into Borges, and for the most part I end up agreeing with David Gallagher’s sentiments regarding the book — too long, too desultory, not really all that revealing. Nevertheless, there are still a number of amusing moments, and so I thought I’d share a few I’ve discovered recently:

Sunday, 28th of September, 1969

Hablo por teléfono con Borges. Me dice: Mi sobrino Luis se casa pasado mañana. Está en cama, muy resfriado. ¿Será una estratagema para no casarse? Sin embargo, no está obligado… Qué raro, elegir la inmovilidad como una forma de fuga.

I speak with Borges on the phone. He tells me: My cousin Luis is getting married the day after tomorrow. He’s in bed with a severe cold. Could it be a way to avoid getting married? Still, no one’s forcing him… How odd to choose immobility as a form of running away.


Monday, 14th of August, 1961

BORGES: <<Me faltan veinte días para irme a Texas. ¿Cómo detener el tiempo? Madre está muy divertida con el viaje. Ojalá que me dejen hablar de otros temas, además de literatura argentina. Esa idea de que todo hombre es un commis voyageur de su país es una porquería, es la negación de la cultura, de la literatura, de todo.

BORGES: I leave for Texas in twenty days. How does one stop time? Mother is very amused about the trip. Hopefully they let me speak on topics other than Argentinian literature. This idea that everybody is a commis voyageur of one’s own country is crap; it’s the negation of culture, of literature, of everything.


Sunday, 18th of March, 1962

Le hablo de mi cuento <<El calamar opta por su tinta>>. BORGES: <<Está bien. El verbo optar supone una inteligencia que los calamares probablamente no tienen>>. Comentado los primeros resultados de las elecciones y el posible triunfo peronista: <<Recuerdo un dicho parecido: ¨El perro vuelve a su vómito¨. Aunque más adecuado sería, por estos días; ¨El argentino vuelve a su Perón¨>>.

I tell him about my story, The Squid Chooses Its Own Ink. BORGES: “It’s good. The verb choose presupposes an intelligence that squid probably don’t have.” Commenting on the preliminary election results and the possible Peronista triumph: “I remember a similar saying: ‘The dog returns to its own vomit’. Although something more apt would be, for these times: ‘The Argentinian returns to his own Peron'”.

Note: Borges’ apter saying has an added kick in Spanish because perro, the word for dog, is very similar to Perón.


Monday, 19th of March, 1962

A unos metodistas que se oponían a la pena capital, les dijo: <<Cristo la sancionó. Murió en la cruz; no elogió — era Dios y podía hacerlo — la reclusión en la cárcel>>. <<No los convencí>>, agrega. Yo le recuerdo que, para John Donne, Cristo era suicida.

He said to some Methodists opposed to the death penalty: “Christ sanctioned it. He died on the cross; he did not choose — he was God and was able to do so — imprisonment in jail.” “I did not convince them”, he added. I remind him that, according to John Donne, Christ committed suicide.

A Short Documentary on Cryptic Crosswords and David Astle (DA)

I love cryptic crosswords, so much so that I run, with a little help from some friends, The DA Trippers, a site devoted to David Astle’s crosswords.

A bunch of RMIT students wanted to film a short documentary on cryptic crosswords and asked DA, as he’s known in the biz, to be involved. Being the genial guy that he is, DA agreed, and a series of coincidences meant that I ended up in the documentary as well, along with fellow DA-Trippers founder, RC.

And that doco — it’s right here: http://www.youtube.com/watch?v=c4GurqnVAF4