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:
...in 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?

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...

yes...

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:

breaktimer.sh

#!/bin/bash
while true
do
growlnotify -m "Take a break"
afplay /System/Library/Sounds/Blow.aiff
sleep 3600
done

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 :-)

Friday, May 18, 2012

Spotted license plate 000 NPE

The significance of this odd spotting will probably only make sense to computer programmers (NPE = Null Pointer Exception), but a few days ago, Mila and I were following an SUV with license plate 000 NPE, which is quite amusing. I don't think it is a customized vanity plate – here in British Columbia, license plates have three numbers followed by three letters, or three letters followed by three numbers. It could be a genuine coincidence.

Tuesday, May 08, 2012

Figured out my favorite kind of music: poetry recordings

I don't have a favorite kind of music that I like to listen to. If you ask me, "What's your favorite kind of music?", I have no answer. I like a song, but I soon tire of it.

But there is a recording that I enjoy listening to over and over: The Caedmon Poetry Collection: A Century of Poets Reading Their Work. Here you can hear T.S. Eliot, e e cummings, Auden, Yeats, Pound, etc. reading their work. I wish there were a link to a page with some audio samples that I could share with you.

Wednesday, April 25, 2012

Is God fond of us?

Last night I was at a coffee shop with Mila and in the course of our conversation, she mentioned that "God is crazy in love with us." Father Dave said something like this a few weeks ago as well. My question is, is it proper to think of God as being deeply or "crazy" in love with me? It "would be nice", but I haven't heard or read this viewpoint from an authoritative source.

Is God vengeful or loving? This question disturbed me, so I have spent the past three hours this morning Googling around for something, anything, that can help me to come to grips with this question. Is he both? Check out the famous icon of Christ Pantocrator below:

Christ Pantocrator

Note how the left half of the face is gentle and the right half is stern, representing his human and divine natures. I like the gentle side but am a bit worried about the stern side.

Many Christians intellectually believe that God is unconditionally loving, but in their hearts they believe that he is stern and vengeful. Here's a not-bad article that I came across on the subject. Google also linked me to an excerpt from the book What Catholics Believe which asks, "How can a God of love also be a vengeful God who demands suffering of his son?" It then starts to get good and talks about the parable of the prodigal son, but then suddenly, page 59-61 are not shown in this preview.

Another book I turned to this morning was Good Goats, which was recommended to me some years ago. One idea from it that rings true for me is that God loves you at least as the person who loves you the most. Nice idea, right? I can believe it, but unfortunately the book is spoiled by some ideas that strike me as heretical, at least to a Catholic - it questions mortal sin and hell, which are traditional Catholic teachings, and this despite the authors being Catholic. So I needed to look elsewhere for answers.

Long story short, I finally turned to Pope Benedict XVI's 2006 letter Deus Caritas Est (God Is Love). It is a long letter, but I needed to read it this morning. I was getting confused by all the various viewpoints on the question, and I needed something authoritative, a dose of sanity. I won't go into detail here (if you have the same question as me, go read it - it's great), but below are some highlights:
  • While "God is the absolute and ultimate source of all being", he is "at the same time a lover with all the passion of a true love".
  • "Marriage based on exclusive and definitive love becomes the icon of the relationship between God and his people and vice versa."
  • "This divine activity now takes on dramatic form when, in Jesus Christ, it is God himself who goes in search of the “stray sheep”, a suffering and lost humanity."
So my understanding now is that, yes, it is proper to view God as being "a lover with all the passion of a true love". Not the "puppy love" that the words "crazy in love with us" may evoke, but the deeper love that is more like that between husband and wife. Have I fully figured out what the love of God is like? No. As Augustine said, "If you understand it, it is not God." Is God vengeful? Maybe, in an odd, roundabout way - he can get angry (as husband and wife can), but he also provides a way out. Do I fully understand this? No. But I'm a bit more at peace with the idea of God being a lover, with the image of marriage being a key to understanding it.

Sunday, April 22, 2012

Rembrandt's painting "The return of the prodigal son"

You gotta love Rembrandt's painting, "The return of the prodigal son". That's the elder brother peeking around the column in the background.

Rembrandt-The return of the prodigal son

Henri Nouwen has a highly reviewed book about this painting and the parable behind it. I haven't yet read the book, but it seems to be about moving from being the prodigal son, to being the elder brother, to being the welcoming father.

The Compleat Gentleman: 10 Favorite Quotes

There is a book called The Compleat Gentleman (2009) on what it means to be a gentleman. To be honest, I found a good deal of it boring, but it did have some good bits. Here are ten of my favorite quotes:

1. "He is a man who stands up for others - sometimes even for his enemies - often when those others have no clue that he is there for them."

2. "Most of the time a gentleman is just a mild-mannered fellow whom folks may take for granted. But when the job of saving the world comes up, there's a change in the man."

3. "There is simply no substitute for strength of character, and in boys, or men, this requires two things increasingly rare in our time: knowledge of the past and a vision of the future."

4. "The process of character development begins and matures in the home."

5. "Protect the weak and less fortunate."

6. "He is also a man of silence, a man reconciled to his own death."

7. "A gentleman is dedicated to the virtue of goodness. He believes he ought to do the right thing."

8. "He respects her, listens to her, and does all that he can to give her what she desires. This is true in terms of her existential ambitions, and it is equally - if not especially - true of her physical needs."

9. "Some of the most important things about a man are the things he keeps from most people all the time and from those closest to him until the time is right."

10. "'A gentleman,' Confucius said, 'is distressed by his own lack of capacity; he is never distressed at the failure of others to recognize his merits.'"

Saturday, April 07, 2012

Canada Food Guide

In Canada we have something called the Canada Food Guide, which recommends that each day, adult men have 8-10 "servings" of vegetables/fruit, 8 of bread/rice/grain-products, 2 of milk/alternatives, and 3 of meat/alternatives.

Reading this makes me realize that my bachelor's diet of Mr. Noodles, eggs, and cereal is not enough. I'm definitely going to be changing how I eat to be healthier and more in line with this guide.

Are you making sure you are eating healthy?

Thursday, April 05, 2012

10^24 (a trillion trillion) = number of stars in the universe = number of atoms in a cubic foot of air

First, go look at this picture of a tiny patch of the sky at night. Be amazed: those aren't stars – those are galaxies.

Consider that there are estimated to be a trillion (1012) galaxies in the universe:
1000000000000

And that each galaxy contains about a trillion (1012) stars:
1000000000000

So how many stars are there? About a trillion trillion (1024):
1000000000000000000000000

This is hard to imagine. In our everyday experience, do we ever come across a trillion trillion of anything? Actually, yes – there are about a trillion trillion molecules in a cubic foot of air:
1000000000000000000000000

Another way to remember this is that it is roughly the same as Avogadro's number (about 6x1023), or the number of atoms in a gram of hydrogen atoms.

(Pondering immense quantities like these can make an atheist or a theist out of a person, the latter particularly if you accept Aquinas’s proofs that God is, among other things, existence itself.)

Monday, March 26, 2012

The 5 Love Languages

That's the title of an interesting book by Gary Chapman on 5 different types of communication that people like to receive:

  • Words of Affirmation (praise, compliments, etc.)
  • Quality Time
  • Physical Touch (hugs, etc.)
  • Acts of Service (doing the dishes, taking out the trash, etc.)
  • Receiving Gifts
Above I have arranged them starting with the ones I like best. Feel free to praise and compliment me :-). Quality time is also good. And, what can I say, I like to give hugs to my family. On the other hand, acts of service and gifts are nice, but honestly they don't do a lot for me.

I want to know: what are your top 3?

Saturday, March 17, 2012

Tech news recommendation: Hacker News

I gave up on RSS feeds (after many years of tracking dozens of them) because they consumed too much precious time each day. At work I asked for someone to recommend one good news source for tech news.

Golf recommended a great one: Hacker News. It's a great 1-page list of top tech news of the day. I find the items there relevant, to me anyway.

Wednesday, March 07, 2012

Jesus had a beard

If the Shroud of Turin actually shows the face of Jesus, then it is interesting to note that, yes, Jesus did have a beard, and quite a full one. His face is also stockier and more rectangular than the delicate face we are accustomed to seeing in paintings.

Mila (the woman I am courting) pointed out to me that it is notable that this image had to wait for modern technology (i.e., photographic negatives) before it could be clearly shown.


The face on the shroud (left) and its photographic negative (right) (source).