Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Monday, September 29, 2014

Git command to show you the largest commits you did in the past week

At Ning, we have a weekly meeting where we give feedback to the team based on how the week went. However, it's hard for me to remember the most important things I did in the past week.

The following git command will help. It gives you the commits from the past week sorted by number of lines:
git fetch; git log --author=Aquino --shortstat --pretty=format:'%C(yellow)%h %C(blue)%ad (%ar) %C(green)%cn %C(reset)%s' --date=short --since='1 week ago' "--remotes=*" -C | perl -ple 's/.*, (\d+ insertion).*/\1/' | perl -0 -ple 's/(.*\d\d\d\d-\d\d-\d\d.*)\n(\d+) insertion*/\2 \1/g' | sort -nr | less
(Make sure to replace Aquino with your name.)

It produces output like this:
90 0d9214a 2014-09-26 (3 days ago) Jonathan Aquino ABC-487: Extract uploading code into AbcUpload class.
68 0978007 2014-09-25 (4 days ago) Jonathan Aquino [no-jira] Remove hardcoded numbers...
54 d28dc90 2014-09-23 (6 days ago) Jonathan Aquino ABC-330: Make cropping actually work.
52 94afa2f 2014-09-24 (5 days ago) Jonathan Aquino [no-jira] Show full text of post in the detail view.
47 77e4710 2014-09-25 (4 days ago) Jonathan Aquino ABC-487: Extracted controller function into AbcCamera...

Friday, August 01, 2014

Final causes

I'm interested in understanding more about final causes, after reading Edward Feser's blog post, The Return of Final Causality, and the paper it links to, Does Efficient Causation Presuppose Final Causation.

What is a final cause? From what I understand, Aristotle said that every change requires four things (four "causes"):

  • efficient (the doer of the change)
  • material (what the changing thing is made of)
  • formal (the nature of the changing thing, common to all things of that type)
  • final (the normal result of doing what the doer is doing)
For some reason, most contemporary philosophers reject #3 and #4. I'm not sure why.

The basic idea of a final cause is given by the last sentence of the paper:
It is not empty to assert that all efficient causes are aimed at something.
Sometimes when you do something, the result is different than normal. Regarding this, the paper quotes Aquinas: inanimate beings, the contingency of causes arises from imperfection and deficiency: because by their nature they are determined to one effect, which they always produce, unless there be an impediment due either to weakness of power, or some extrinsic agency, or indisposition of matter. For this reason natural causes are not indifferent to one or other result, but more often produce their effect in the same way, and seldom fail.
 I am going to re-read Feser's book The Last Superstition. Some questions I will have in mind while reading it are:

  1. I would like to understand Aristotle's ideas better (act and potency, form and matter, the four causes.)
  2. What reasons have we to believe that these ideas are true?
  3. Which of Aristotle's ideas do moderns reject and why?
  4. What problems does the rejection of these ideas cause?

Saturday, July 13, 2013

On Purpose in the Universe

Atheism doesn't work for me because it is connected to the idea that there is no purpose in the universe, no purpose in a person's life. Aristotle, on the other hand, argues that purpose is a fundamental part of reality (one of his Four Causes).

I fully agree with something that Steve Jobs said in his Stanford commencement address: "You can't connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something - your gut, destiny, life, karma, whatever." In atheism, you can't have that magic. You are pitted against a hostile environment of random chance, illness, and misfortune. But in Catholicism, there is purpose: purpose in good things, and God can even pull good out of evil things. It is about life, hope, love, and flourishing; in other words, purpose. And I like that.

Monday, July 01, 2013

Continuing quest to wean myself off Google services

I found a good replacement for and the Chrome browser, and they are both from Yandex, which is a search engine based in Russia. (Those Russians are smart!)

Replacement for It seems to give better search results than DuckDuckGo... maybe. I'm continuing to try it out, but it is looking good so far.

Replacement for Chrome: Yandex browser. It is based on the open-source Chromium project. (Review.) And you can install 1Password on it via the Chrome web store.

Wednesday, June 12, 2013

What I like about zsh

I've been using zsh as my shell for a few weeks now, and I quite like it. Here's why:

  • I can customize the prompt to show the current directory, the current Git branch (and whether it is dirty), and the current time.
  • The history-substring-search plugin lets me type in any substring and press the Up arrow, and it will show me history entries matching that substring (with the match highlighted in purple).
  • History is shared across shell instances. And I can save a year's worth of history to a file.
  • I can replace a substring in the previous command by doing ^foo^bar^:G
  • When I mistype a command or script name, it offers suggestions.
  • When I do !456, it confirms which command that would run.
  • I can do "less **/XG_Media*" to open a file buried in some subdirectory, e.g., src/main/webapp/lib/XG_MediaUploaderHelper.php

I also like running zsh in iTerm2. iTerm2 is cool because:

  • It lets me map Alt+Arrow and Command+Arrow to behave like I want them to.
  • It offers auto-completion using all strings in the window, when I do Command+;
  • It lets me use the Solarized theme.
  • It has a couple of cool features that I don't use much yet:
    • Find text
    • Instant replay

Hotmail lets you use custom domain for free

It takes some setting up, but you can map any custom domain to your Hotmail account. I don't think any other free email service offers custom domains.

Thursday, June 06, 2013

On Heaven

I used to think that heaven is a place with wide expanses of green grass, blue skies, and billowy clouds. Yeah, God is there, but the main thing was to get to this wonderful Place.

But now I understand it to be different. Heaven is more like entering God. At least that's how I understand this quote from the Catechism of the Catholic Church:

The ultimate end of the whole divine economy is the entry of God's creatures into the perfect unity of the Blessed Trinity. But even now we are called to be a dwelling for the Most Holy Trinity.

Which I think is pretty cool.

Wednesday, June 05, 2013

Elo Preference Ranker

This little tool helps you to rank a list of your preferences by comparing them a pair at a time. Simply paste in a list of items to rank, one per line (e.g., your favorite skills). Then press "Start ranking!". You will then be presented with a pair of items at a time, and you are asked to choose which is better or more important. As you go, the sorted list will appear at the bottom.

It uses the Elo ranking algorithm, which is used to rank chess players based on whether they win/lose/draw against each other. The more pairs you compare, the better. Once you have compared all combinations, the process ends.

What is this good for? Suppose you are buying a home or a car and you have several dozen preferences, and you want to know, which of these are most important to me, and in what order? Or suppose you are working through What Color Is Your Parachute? and you want to sort your list of skills and interests to find your favorite ones. Simply throw your list into the tool and start ranking them.

Input Strings

Enter the strings to rank, one per line. Then press "Start ranking!". You will be presented with pairs of strings - click the button corresponding to which item is more important or better.


Click the button corresponding to which item is more important or better. You can also press "J" for the left item and "L" for the right.

Something. Something else.

You have finished comparing all items!

Sorted Output Strings

The sorted strings are:

Tuesday, May 21, 2013

zsh tip of the day

I've been getting into the zsh shell as a replacement for bash. But there are so many things to learn that I wanted a "Tip of the Day" to give me a random tip whenever starting my shell. The tips are from zsh-lovers.

So I made a tip-of-the-day script. Simply put these two files in ~/tips, then add php ~/tips/tips.php to your .zshrc file.



The next time you start up your shell, you will see something like:

zsh tip of the day

# Match file names containing only digits and ending with .xml (require
# *setopt kshglob*)
$ ls -l [0-9]##.xml
$ ls -l <0->.xml

Sunday, May 19, 2013

Need to memorize a bunch of words?

Need to memorize a bunch of words? Try taking their initials and making an words out of them using the Internet Anagram Server.

Unlike some other online services which generate the largest single word out of all your letters (and often not hitting all of your letters), this one will generate several words that together try to use up all your letters.

For example, acdefiopstvwy gives Decaf Tipsy Vow.

Decaf Tipsy Vow helps you to memorize the following list of negative feelings:

  • Disconnected
  • Embarrassed
  • Confused
  • Averse
  • Fatigued
  • Tense
  • Impatient
  • Pain
  • Shocked
  • Yearning
  • Vulnerable
  • Outraged
  • Worried

Similarly, Jag Chef Trip helps you to memorize the following list of positive feelings:

  • Joyful
  • Affectionate
  • Grateful
  • Confident
  • Hopeful
  • Excited
  • Fascinated
  • Thrilled
  • Refreshed
  • Inspired
  • Peaceful

Saturday, May 18, 2013


Life-changing website: It finds the lowest used price for any book, searching a variety of online used bookstores. Best of all, the prices include shipping. I just ordered a book - would have cost $21 new, but got an older edition for $6.

Friday, May 17, 2013

Unclosed Tag Finder

Here is a tool to find unclosed tags in your HTML. Just paste in your HTML and press Submit. You will see a result like "Closing tag </table> on line 188 does not match open tag <td> on line 62.".


Thursday, May 16, 2013

The Facebook Like Bug

I'll be honest - there are certain kinds of debugging that stress me out - such as when the bug is intermittent. One example is a bug that I've been looking at for the past day and a half: for quite a while, our users have been finding that Facebook Like buttons aren't working on their sites. They click Like and the popup appears for a second before disappearing. And it doesn't happen all of the time.

Well, we finally carved out some time this week to take a look at the issue. And yes, I could reproduce it yesterday. So I did my tried and true method of "deconstruction", in which I keep taking things away from the page until the problem stops. Well, I whittled the page down to just the Facebook Like snippet and it was still happening. So it was something to do with the URL we were giving to the Like button.

And then I couldn't reproduce it anymore.

Anyway, I was able to reproduce it again today. I put a bunch of Like buttons on a page: some that worked, some that didn't. And I eventually got it so that the only difference was that the Like buttons that didn't work had URLs that redirected to another URL.

By the way, throughout this saga, I was trawling the Facebook Bug Database and Stack Overflow for a silver bullet - someone who fixed the problem and here are the steps. I couldn't find any silver bullet, but it was still valuable because I heard mention of the Facebook Debugger, which sometimes fixes things when you put a URL through it because it clears Facebook's cache.

I tried putting my URL into Facebook's Debugger but it didn't fix my Like button. But I took a second look at the debugger results, and 'lo, there were some warnings about missing OpenGraph tags. I browsed around a bit and found that three of those tags are required (og:type, og:url, and og:title). So I put those tags on my page and...


the problem was fixed! Yay!

Wednesday, May 08, 2013

What's on your dock?

Tell me what's on your Mac OSX dock. These are the apps that you value the most.

Here's what's on my dock right now:

  • Finder
  • PostBox
  • Calendar
  • Adium
  • Notational Velocity
  • jEdit
  • iTerm2
  • Safari
  • Firefox
  • 1Password
  • Network Connect
  • Colors
  • Clock Chimes
  • iTunes
  • App Store
  • System Preferences
  • Microsoft Excel

Useful Git tool: tig

Here's a great article describing a useful Git tool called tig.

One thing it doesn't mention is that you can actually press comma (,) when doing a tig blame, to do a blame on the parent commit. This is useful if the blame on the current commit isn't showing who really changed the line. You can do blame on the line all the way up the parent tree.

Other tig tips:

  • Use this to browse the tree of another branch: tig origin/rel-1.5.
  • If while browsing the commits on another branch you press Shift+C on a commit, it will cherry-pick it into your current branch.

Sunday, May 05, 2013

Ideas for what to write in cards

Here's a great list of ideas for what to write in a card, if you're stuck for ideas. From Hallmark.

Monday, April 29, 2013

Japanese method of folding t-shirts

I use this.

Tuesday, April 09, 2013

Moving away from Google products: an experiment

I'm doing an experiment to see how well I can live without Google products. They have served me so well for so long, but I don't want to depend on them too much. So I have made the following moves:

  • Google search => Duck Duck Go
  • Gmail => Hotmail
  • Blogger => Ning
  • Chrome => Safari

So far, it has been OK!

Design email newsletter for programmers

Here's a great weekly email newsletter about design for programmers: Hack Design.

I was reading one of the newsletter articles today, called Making the Transition from Development to Design. It had some good quotes, such as these ones:

I think the future designer is going to look and act a lot more like a design technologist.

Avoid pixel-pushing at all costs – your job is to solve problems.

Our ideas should be bigger than reality, but our execution should be married to it.

Monday, April 08, 2013

Today's bug hunt

Today I worked on finding and fixing a bug that is difficult to reproduce. In fact, I couldn't reproduce it. So I had to look at the code and reason where the bug could possibly be located. From the error message in the bug report, I narrowed it down to a particular JavaScript file. And it sort of looked impossible that the bug could ever occur. Basically, the error message said that a variable was undefined, but we were clearly defining the variable before we were using it.

Or were we? It turns out that one of the places that used the variable was in a public method. So after thinking about it for a bit, it dawned on me that this method could be called before the object finished getting fully initialized. To prevent this, we always make sure to put all JavaScript that must run on page load in an "addOnRequire" callback. Anyway, the team that wrote this code doesn't work on this product much so they didn't do that.

So I thought about emailing the team to make them aware that they should use addOnRequire(). But then, they are not currently working on the product, and might not be for weeks or months, so how would they remember? So then I thought, I'll write a test that scans the JavaScript files to catch this pattern. Since our tests run frequently, we'll catch this problem any time it arises in the future. Cool!

Friday, April 05, 2013

An unobtrusive break reminder, for Mac

I was having trouble finding something to remind me to take an exercise break every hour or two. A lot of the break timers out there dim the screen and force you to press a button if you want to postpone it. This is problematic for programmers like me - you get into the "flow", and interruptions like that break your concentration, which is Not Good.

It turns out that it's not terribly hard to create your own (unobtrusive) break timer. Here's one that simply shows a Growl notification and makes a sound every hour, on a Mac with growlnotify installed:

while true
growlnotify -m "Take a break"
afplay /System/Library/Sounds/Blow.aiff
sleep 3600

On the importance of leisure

Likewise, your question refers to the classical notion of leisure, to the question, as I like to ask it: “What do we ‘do’ when all else is done?” As Pieper pointed out in his famous book, the Greek word for leisure, skole, is the origin of our word for school. The denial of leisure becomes the classical word for “business,” both in Greek and Latin. Thus, the time we devote to keeping alive, to making a living, while necessary and important, is not primarily time “for its own sake.” This latter time is the time beyond business. It is in this latter time that we should be “free” to think of the highest things. Not to have such time is to be a kind of slave to this world.

From an Interview with Fr. James V. Schall, S. J.

Thursday, April 04, 2013

Soy Sauce Puzzle

So this is something that happened to me a few days ago, and it makes for a nice puzzle.

My wife asked me to pour soy sauce and vinegar into two saucers, equal parts (1:1 ratio).

I poured the vinegar into each saucer. But then I poured twice as much soy sauce as was needed into the first saucer.

Question: How do you fix this easily?

My wife solved it without thinking.

Wednesday, February 06, 2013

Growly Notes - like OneNote but for Mac

I'm trying out a free Mac app called Growly Notes. I need a kind of "space" in which to record ideas, and I need it to be organized so I can find it again quickly later. This app may fit the bill. It has a bit of a following. And it's colorful, which is nice.

Also see the Lifehacker review.

Friday, November 23, 2012

Pine cones open up when you bring them inside

My fiancee has been collecting pine cones for room decorations, and one cool thing we discovered is that they open up after you bring them inside. I'm not sure if it's caused by the warmth or the dryness or something else.

A day or two after you bring them in, you'll see that they gradually splay open. Evidently they are doing this to expose the seeds inside.

Saturday, October 06, 2012

Two life-changing questions to ask yourself each day

There is a traditional practice of asking oneself the following two questions at the end of each day. It also works great with other people – my fiancée and I enjoy asking each other:.

1. What are you most grateful for today?
2. What are you least grateful for today?

There are other ways to ask them as well: What increased/drained your energy today? What brought you consolation/desolation today? What part of today did you really like/dislike?

The idea is that by reviewing your day and looking for what brought you life vs. what drained your energy, over time you will see patterns in the things that give you joy, and the things that don't. And you can make decisions that lead you to more of the former and less of the latter.

I read a recommendation for this book which talks more about it.

Thursday, August 09, 2012

Favorite drink: Milkshake

Man, I just love milkshakes. I don't like pop or coffee that much, but it's nice to have a good, thick milkshake. I am enjoying one made out of cookies-and-cream ice cream right now. Better than a Frappucino or a Blizzard.

I was watching how they make a milkshake, and it seems that (at least at Just Desserts at SFO Airport) all they do is stick ice cream in a blender. Good 'nuff.

Wednesday, May 30, 2012

A better way to brush your teeth

Yesterday Mila informed me that various people have pioneered improved ways to brush one's teeth. One of the ways is the Bass Method. Basically, you point the brush into your gums at a 45 degree angle and jiggle the brush. See description (scroll down to "Modified Bass brushing technique") and video.

Monday, May 21, 2012

Make your own mini Moleskine notebook for (almost) free

Moleskine makes these nice mini notebooks that are so small you can slip them into your wallet. But they cost $10 for two. Here I'm going to show you how to make something pretty similar using materials you probably already have at home. All you need are:

  • a 3x5" writing pad
  • a 3x5" index card
  • a stapler
First grab a bunch of paper from your writing pad, and put it on top of the index card:

Next, fold everything in half:

Add a couple of staples along the fold:

And voila, you have a mini Moleskine-like notebook that you can stick in your jacket or wallet. I like to write the date in front – since these cost essentially 0 cents to make, I end up making a lot of them over the course of a year. Enjoy!

Saturday, May 19, 2012

New todo-list system: One-Minute Todo List

I was trying a todo-list system called SuperFocus, in which you keep your todos in a notebook, and you must do at least one item on each page before moving on to look at the items on the next page.

But I got frustrated with it because tonight I had 10 minutes to do something from my lists, and I had a ton of important stuff in the last few pages. But because I have to do at least one item on a page before moving to the next page, I was stuck a few pages back on: polish shoes.

That tells me that there is something wrong with this system.

So I'm trying yet another todo-list system. This one is called the One-Minute Todo List. Here is a link to the free e-book PDF. The basic idea is to have three lists:

  • Critical Now (stuff that must be done today). Max 5 items. 
  • Opportunity Now (stuff to do within the next 10 days, when you get an opportunity). Max 20 items. Review daily.
  • Over-The-Horizon (stuff that could be done after 10 days). Unlimited items. Review weekly.
The third, unlimited list scares me a bit - it could get really huge. Anyway, we'll see how it goes.

One of the advantages of trying out a new to-do list system is that you can start with an empty list :-)