Blog

All Posts (83)

Code smell: Schizophrenic method

A schizophrenic method is a method that is begging to be split into two. It has a lot of if statements, but closer inspection reveals that most of the ifs can be eliminated by splitting the method into two. It may take some effort to unravel the two cases from the hodgepodge of ifs on various variables, but it's beautiful if you can do it.

Read more…
Here is how to simulate perfect pitch using your teeth:
  • Tap your teeth together. You should hear the same pitch every time you tap your teeth together.
  • Go to a piano and find what note corresponds to the pitch coming from your teeth. For example, my teeth give me a Db.
  • Hum your way up (or down) from that note to C.
Now you have a way to hum a C without aid of any instrument, tuning fork, or app. Just your teeth.
Read more…

Liking MYN better than GTD

I'm really liking MYN better than GTD. Instead of having a bunch of context lists, now I have one short list based on urgency (yes, urgency, or "start dates"; the book explains why). The list is short because stuff to do/review in the future is hidden.

Here's what my list looks like:

First, it's remarkable how short it is, compared to my huge GTD lists.

"High" is things that must absolutely be done today, even if I have to stay up late.

"Medium" is things to consider doing in the next couple of weeks. Some of them are recurring (every 3 days, every 4 months, etc.). The starred ones should preferably be done today, although they don't have to be.

"Low" is things that are "over the horizon" that I should at least review each week.

Also note what is not shown: the 136 hidden tasks. They are not shown because they have start dates in the future. Those are 136 tasks that I don't need to include in my weekly review, unlike in GTD. I really appreciate that.

Read more…

I tried this once so far and it worked: FirstGlobalMoney. The charge is $5.99 to your debit card, which is better than Western Union ($10 + $3.50 credit card cash advance fee). You have to wait a few days the first time for them to verify your information. After that, recipients should receive it in half an hour. You select from a list of pickup locations for the recipient (typically a grocery store or pawn shop with remittance services).

Read more…

MYN vs GTD

I'm trying out a new task management system called MYN ("Mind Your Now"). I have ported all of my GTD tasks into MYN. It seems to be quite good:

  • The best thing is that lists are kept small because you can hide items for a given number of days/weeks/years. You choose the next time that the item should pop in for review. So the weekly review becomes very quick.
  • Another good thing is that the system gives you good suggestions for what to do next: your list is sorted, so the stuff you need to focus on appears at the top. It is sorted first by urgency (counterintuitively) (with 3 classes of urgency), and then by start date (not due date) (so newer tasks appear first). I have always wanted a system that could suggest to me what to do next.

There is a free e-book called The One Minute To-Do List that has the MYN  system (with implementation using Toodledo) in its closing chapters. I liked it so much that I bought one of Michael Linenberger's books to get advanced details on the system.

Read more…

Code Reviews in Iambic Pentameter

A few months ago, I tried doing an experiment: Writing my code reviews in iambic pentameter. When you write in iambic pentameter, you can't write nasty things—and if you tried, it would come off as humorous.

In the end, I stopped doing it though because people weren't responding to my reviews.

Anyway, preserved for posterity are the following 42 actual code reviews in iambic pentameter.


1. A 404 is when the story's gone.
But if the problem's that you're not allowed
To see it, then you want a 403.
ForbiddenException, that it should be.

2. To make SOLR respect a private field,
getBooleanSearchFields helps you to be healed.
Mode videos, without this, were all concealed.

Oh, but I see the same thing you did wield.

3. isPrivatePublic makes but little sense;
isPrivacyEnabled has defense.

4. You speak after you sleep, but if announce
That you will sleep, t'were best announced before.

5. IDs are not sequential - oft they jump
From high to low, then high again, then low,
createdDate were better for this flow.

6. Wherefore psw? I think you password mean,
Abbreviating's tasty as benzene.

7. .ban-top-center-cta as a class
Refers to "top" and "center" which are not
Semantic - no they're presentational.
Would that you chose .ban-publish-add-image
Then there'd be no semantical scrimmage.

8. Sort by createdDate, but you should know
ID does not increase in the same way.
Consider:

> select from_unixtime(_created_date/1000), _id from _collection
    -> order by _created_date asc
    -> limit 10;
+-----------------------------------+-------+
| from_unixtime(_created_date/1000) | _id   |
+-----------------------------------+-------+
| 2012-11-08 20:17:29.4910          | 17499 |
| 2012-11-09 01:07:31.3610          | 17610 |
| 2012-11-09 01:09:04.3650          | 17618 |
| 2012-11-09 01:18:07.1550          | 17637 |
| 2012-11-09 01:18:57.7690          | 17556 | <- Jumps down
| 2012-11-09 20:06:21.7750          | 17574 |
| 2012-11-09 20:08:05.8680          | 17579 |
| 2012-11-09 20:08:54.1530          | 17654 | <- Jumps up
| 2012-11-09 20:33:14.9920          | 17593 | <- Jumps down
| 2012-11-10 00:24:31.0810          | 17695 | <- Jumps up
+-----------------------------------+-------+
10 rows in set (0.15 sec)

beginFrom should be *date*, I'd recommend,
else you'll have to account for some loose ends.

9. This use of :not is not the greatest thing.
Can we step back and think what's going on?
.l-cnt-topad - is that content or not?
If no, .l-content should from it be gone.
If yes, .next-bg needs another class,
Perhaps .l-next-bg-content would pass.

10. Instead of papering o'er the problem here
It would be best to ask, what's the root cause?
allOptions.smarty's $defaultMsgKey
On line 282's not specified.
If you put there the $defaultMsgKey 
Then this line will not be needed by thee.

11. You added $defaultMsgKey right here
Beside $newMsgKey, like man and wife.
But in collect.js, I'm 'fraid to say
$newMsgKey, without her partner, lay.
Two places in collect.js she stands
Alone, and quite rejected by her man.

If $defaultMsgKey were put beside,
She and YOKO-6863 be bride.

12. For keeping it top level, I you thank.
The more we do, it's money in the bank.

And these module prefixes are real swank.

13.                             These strings
Should be in en_US's list of things.

14. For every other field, it ends with "-field",
Why was the suffix from this field repealed?
I'd recommend you change to "site-url-field".

15. How this did ever work, I do not know.
The initImagePicker function calls
To processImages, which I'm sure sets
this.images. Unlike the comment says,
We can have images and videos both
Which you can see if you do bookmark this:

http://mightymega.com/2015/07/14/star-wars-tie-fighter-music-box/

16. I thought the powers at be did think it best
To put all z-indexes in _defs.less.

17. I wish we did not have to nest so deep,
Nest here, nest there, it multiplies like sheep.

18. No value for the href? Please explain
Why you thought href="" worthy to disdain.

19. The only thing that the jira required
Is “return path.replace(/.*\/\/[^/]*(.*)\?.*/, '$1')”. Or am I tired?
That regex will return the stuff that's parked
Between the domain and the question mark.

20. After a year, the meaning of "SB"
Will be but a forgotten memory.
Could you rename: collectStoryBuilder?
Then it will surely never bewilder.

21. Why nest these classes in l-bookmarklet?
l-bmk prefix does not suffice?
Removing all this nesting would be nice.

22. You import a big file into a small,
Why not just make this file contain it all?
It would be turning Saul into St. Paul.

23. In recent conversation we agreed
That underscore CSS class names suck.
Please use a hyphen; underscores, please chuck.

24. The top of this file says the prefix is
ems-. But you put ath- here.
Should you not use ems- to cohere?

25.                               I do not understand
Why this has to be so deeply nested.
If it were not nested, would it not work?
If we stopped nesting, it would be a perk.

26. "$googleAnalyticsSecondaryId"
Don't match "googleAnalyticsSecondary"
I would make them same for consistency.

27. This is not the "number of stories viewed",
It is the "IDs of the stories viewed".
I think this comment needs to be renewed.

28. Uma, why did you add _.storyChainedCount,
When we already have _.shownStoryCount?
    Are they not the same?
    Just a different name?
I'd recommend that you remove your count.

29. I'm sorry, but I don't quite understand.
Isn't the status 'active' or 'optout'?
How does the new code differ from the old?

30. If I do showOnBoarding($user, true),
Then showOnBoarding($user) should be true
But it is false. Is not this a boo-boo?

31. A boolean var name begins with "is"
But this is string and not a boolean.
Please rename this to $downloadBtnClass,
And then this name will be as clear as glass.

32. There is no need to strtolower this,
storeLink() already does it, like a kiss.

33. These offsets will be messed up either when
- pruneWaterfallBoxes kills earlier stuff
- reverse infinite scroll adds earlier stuff

How you will deal with these things will be tough.

34. <span class='ban-help-text'> should be changed to be
<span {FEATURED_LINK_ATTRS}>, right?, to agree.

35. newOffsetIndex is indeed array,
So it should be "newOffsetIndexes".
_.offsetIndex too is a list of things;
"_.offsetIndexes" would have better wings.

36. selector ain't a string - it's jQuery
If you rename to "$node" it would be good,
To make it clearer what's under the hood.

37. The activeKeys are keys, so why not make
Them actually keys in _.itemsList? I ache
To see _.getActiveElements looping
Through all the items. No! If they are keys,
activeElements = _.itemsList[activeKeys[i]].
O(n^2) becomes O(n). Gods are pleased.

38. I recommend that you make unit tests
For RedisImitatorService please.
It's easy to make bad bugs when you sneeze.

39. This kind of thing leads to XS attacks.
Could you encode title using this way?
http://stackoverflow.com/a/1219983/2391566
You'll make malicious users cry, "Mayday!"

40. This no longer inits imagePicker;
I'd rename: "getDocumentImages",
The wrong meaning then won't be contagious.

41. I do not grok this logic; woe is me.
.bnd-cvr-featured-author, if parent,
Causes the buttons to be hidden. Why?
Connection I don't see, and so I sigh.

42. I do not know why this is called $events.
It's just the current target, is that right?
So wouldn't $currentTarget be more tight?
Read more…

The kind of work I like to do

While talking with my wife, I gained a big insight into the kind of work I like to do.

The greater this fraction, the more I will like the work:

        Importance

        -----------------

        Time Spent

The greater the importance (e.g., to the company, or to me), the more I like it. The quicker I can do it, the more I like it. But if the project isn't very important, I won't really like it. Or if it takes a lot of time, I won't like it.

This is why I really enjoyed building Yubnub (high importance to me, only 24 hours spent). Conversely, I hate debugging intermittent production issues (the bug isn't really important to the company, and it takes days or weeks to figure out).

Read more…

Capsule summaries of Shakespeare's plays

The Comedies

  • The Comedy of Errors. Twins, separated at birth, take the same name. Thumbs up.
  • Love's Labor's Lost. Three gentlemen vow to abstain from food, women, and sleep for three years, devoting the time to study. Thumbs down.
  • The Two Gentlemen of Verona. Proteus tries to steal his friend Valentine's Sylvia. Thumbs down.
  • The Taming of the Shrew. Petruchio must somehow tame the shrewish Katharina. Thumbs up.
  • A Midsummer Night's Dream. Demetrius and Lysander are in love with Hermia; Helena is in love with Demetrius. Thumbs up.
  • The Merchant of Venice. Antonio owes Shylock a pound of his flesh for not repaying the debt he incurred for his friend. Thumbs up.
  • Much Ado About Nothing. Hero is falsely accused of cheating on her fiance, the night before their wedding day. Thumbs up.
  • The Merry Wives of Windsor. Falstaff, short of cash, tries to woo two rich, married women, who are too clever for him. Thumbs up.
  • As You Like It. Orlando (brother of Oliver) and Rosalind (daughter of Duke Senior) are banished from Duke Frederick's kingdom to the Forest of Arden. Thumbs up.
Read more…

Ephesians 1:3-14

Ephesians 1:3-14 is the second reading at Mass next Sunday (which I will be reading).

I see in this passage the purpose of humankind:

  1. to "live for the praise of [God's] glory" (praise, faith)
  2. "to be holy and blameless before him in love" (good works, avoiding evil)
  3. "the mystery of his will" and his "plan for the fullness of time" (the purposes that only God knows)

Also in this passage are ways that God equips us for our purpose:

  1. "every spiritual blessing" (love, joy, peace, patience, kindness, goodness, etc.)
  2. "the forgiveness of our trespasses" (right relationship with him)
  3. "the seal of the promised Holy Spirit" (God's guidance)
Read more…

From the Decree Concerning Justification:

  • "...Christ Jesus was given by God to men [not only] as a redeemer in whom to trust, [but also] as a legislator whom to obey..."
  • "...the justice received [is] preserved [and] increased before God through good works..."
  • "...the just [ought] for the good works done in God to expect and hope for an eternal reward from God through His mercy and the merit of Jesus Christ, if by doing well and by keeping the divine commandments they persevere to the end..."
  • "...he who has fallen after baptism [can] by the grace of God rise again[; he] can indeed recover again the lost justice [with] the sacrament of penance..."
  • "...after the reception of the grace of justification [a] debt of temporal punishment remains to be discharged either in this world or in purgatory before the gates of heaven can be opened..."
  • "...the good works of the one justified are in such manner the gifts of God [and] also the good merits of him justified; [the] one justified by the good works that he performs by the grace of God and the merit of Jesus Christ, whose living member he is, [truly merits] an increase of grace, eternal life, and in case he dies in grace, the attainment of eternal life itself and also an increase of glory..."

Here is how I interpret the Decree:

Not State of Grace State of Grace
1. Before you were baptized, all hope was lost. 2. After you were baptized, all hope was gained.
3. When you committed a mortal sin, all hope was lost. 4. When you underwent the Sacrament of Penance/Confession, all hope was gained.
5. When you failed to perform the good works that God gave you the grace to do, all hope was lost. 6. When you performed the good works that God gave you the grace to do, all hope was gained.

If you die in the state of grace, then by God's grace, you merit the attainment of eternal life. (A debt of temporal punishment remains to be discharged, either in this world or in purgatory, before one would enter heaven to be with God.)

Read more…

Random melody generator

Have you ever had to come up with a melody line for a song intro, but weren't inspired to make something up? I play the violin for the Surrey 1 Couples For Christ music group, and there is never violin sheet music for the songs that we play. If the song is on YouTube, I can write down the lead guitar part. But if not, then I don't know what to play, and I'm not always good at creating something from scratch.

So what I am trying today is the Melisma Stochastic Melody Generator from Carnegie Mellon University. Enter the key and whether it is major or minor, then press "Generate Melody", and you will get a midi file with a generated melody.

Here is an example you can listen to.

Then, if you read sheet music, you can use a MIDI to sheet music converter. I haven't found a good one yet though.

Update

A good way to turn your midi file into sheet music is to download ScoreCloud, choose to Record, then play the midi file using QuickTime. You get simpler results by recording with your microphone than importing the midi file, which produces a messy result.

Read more…

I am reading Cardinal Ratzinger's "Introduction to Christianity", and I must say, the following sentences are impenetrable, at least for me. I have no idea what they mean:

To be sure, it is a characteristic of understanding that it continually goes beyond our mere ability to apprehend and attains the awareness of the fact that we are comprehended. But if understanding is the apprehension of the fact that we are comprehended, then that means that we cannot yet comprehend that fact once again [in a second moment of understanding]; it furnishes us with meaning precisely because it comprehends us.

Not grokking that. At all.

But the rest of the book is pretty good so far.

Read more…

Keirsey Temperament Sorter

According to the Keirsey Temperament Sorter, my personality type is E/I-N-F-J.

Here is a description of INFJ:

INFJs are gentle, caring, complex and highly intuitive individuals. Artistic and creative, they live in a world of hidden meanings and possibilities . . .

. . . They put a lot of energy into identifying the best system for getting things done, and constantly define and re-define the priorities in their lives . . . 

. . . INFJs are concerned for people's feelings, and try to be gentle to avoid hurting anyone. They are very sensitive to conflict, and cannot tolerate it very well . . .

Because the INFJ has strong intuitive capabilities, they trust their own instincts above all else. This may result in an INFJ stubbornness and tendency to ignore other people's opinions . . . On the other hand, INFJ is a perfectionist who doubts that they are living up to their full potential . . .

Read more…

Jon's 1-Month Rule

Are you trying to figure out if you should buy the expensive version of something or the cheap version?

Just use Jon's 1-Month Rule: Am I going to use this at least once a month?

If so, then buy the more expensive one.

*

The same applies to time and energy. If you are going to use it less frequently than once a month, then don't waste much time researching reviews, nor much energy stressing about your purchase afterwards, etc.

Read more…

Canadian NextDoor.com: GoNeighbour.org

This is interesting for Canadians waiting for the NextDoor.com neighbourhood social network to open in Canada. It's called GoNeighbour.org and it looks like the same sort of thing, but for Canadian neighbourhoods.

The funny thing is that there are only like 2 pages on the internet that link to it. Wonder why there aren't more articles about it.

Read more…

APA Style Validator

My wife needs to write some papers that conform to APA style/references. I looked on the web but couldn't find a validator/lint program for APA style.

So I wrote this one: APA Check. It only has a few checks right now, but that will grow. It's written in JavaScript so it's easy to hack and submit pull requests.

Read more…