Blog

All Posts (94)

Sometimes DuckDuckGo sucks

I've been using DuckDuckGo as my main search engine. But man, sometimes it sucks compared to Google.

For example, if I search DuckDuckGo for pope francis interview, it doesn't even find the page.

On Google, it is search result #1.

Here's how the search engines fared:

  • DuckDuckGo: Not found.
  • Google: Result #1.
  • Yandex: Not found.
  • Yahoo: Not found.
  • Bing: Not found.
  • Blekko: Not found.
  • Ask/Teoma: Result #1. I wonder if it uses Google.
  • AOL: Result #1. Uses Google.
  • Lycos: Not found.
  • Dogpile: Not found.
  • Excite: Not found.
  • Mahalo: Not found.
  • Yippy/Clusty: Not found.
Read more…

Visualizing a 4D hypersphere

My coworker Chris Brewer created a visualization that allows you to experience a 4D sphere (or "hypersphere") by zooming around a 3D space.

Set Viewing Distance to 1000 and choose Map 1.

What appears to be a spherical container is actually the "equator" of the hypersphere. The three spokes are meridians (lines of longitude), and they meet at one of the poles. Mind-blowing.

9:44:27 AM jona: so tell me what this is exactly - it seems that I'm inside a sphere that gets distorted as I move around it
9:45:00 AM BrewerC1: Sure, so do you know what a hypersphere or 4 dimensional sphere is?
9:45:38 AM jona: is that something where x^3 + y^3 + z^3 + a^3 = 5?
9:45:49 AM BrewerC1: Yeah, exactly like that
9:45:52 AM BrewerC1: er except
9:45:55 AM BrewerC1: squared
9:45:57 AM jona: ok
9:46:29 AM jona: how does the x, y, z that I'm moving around relate to that equation's x, y, z, and a?
9:46:58 AM BrewerC1: so in this spaces, you are moving through 4d space, but with the constraint that you are always R^2 units from the origin of the space
9:47:06 AM BrewerC1: which confines you to the surface of the hypersphere
9:47:11 AM jona: ok
9:47:19 AM BrewerC1: So the surface of a sphere is a 2d space
9:47:25 AM BrewerC1: and the surface of a 4d sphere is a 3d space

Read more…

Some thoughts on interviewing

I am interviewing candidates for two Application Engineer positions at Ning, and there are a few thoughts that come to mind as I have been doing this.

I'm looking for two things when I look at a candidate's code: style and substance.

Regarding style, is the code clear, well-documented, unit-tested (ideally) and maintainable? Is this candidate's code going to be pleasant to dive into and maintain, or is it going to be a mess of logical spaghetti that's going to be a headache to modify?

Regarding substance, does the candidate have deep knowledge in some area that they can bring to the team? Things like Computer Science knowledge, Unix knowledge, OO expertise?

I am coming to believe that a good grasp of English grammar is quite an asset. If you know what a noun and a verb are, you know what I mean when I say that good object names are nouns and good method names are verbs. And, funny as it sounds, I am a believer that good names are the heart of a good design. If you have well chosen names, your design can scale in size to a large codebase; not to mention, good names are a sign that you are thinking clearly.

I also believe that adding doc blocks to every class, method, field, and constant is very helpful to future maintainers (including yourself). This seems to be contrary to majority opinion – most programmers are of the opinion that well-chosen method names are enough. However, I would much rather make modifications to a class that is documented throughout than one without any doc at all. A well-chosen name is good, but accompanying documentation is even better. Sometimes a phrase won't do – you need a sentence or paragraph. Look at the Java SDK documentation – every class, method, and field is documented – it's great. In response to the objection that the doc basically repeats the function name (/** Gets the color. */ for getColor()), see "the ideal comment" in How to Write Doc Comments for the Javadoc Tool for ideas on how to make comments more helpful.

Read more…

Trying out Sublime Text text editor

After more than 6 years of using jEdit as my text editor, I'm trying out a new one on the recommendation of my co-worker, Danni McNinch. It's pretty slick. You do Command-P to goto anything. Also it's quite pretty, at least on a Mac.

Things I like better than jEdit:

  • Close an HTML tag using Option+Command+.
  • Looks better overall.
  • Goto Anything is faster and more reliable than jEdit's Fast Open plugin. Update: jEdit's SmartOpen plugin seems to work pretty well, although there's a bug preventing it from working using the Mac OS X theme (workaround is to switch to a different theme).

Things I miss from jEdit:

  • Free SFTP plugin.
  • Highlight Occurrences plugin to highlight all occurrences of any word that the cursor is on. The highlight remains after you leave the word. You can also highlight other words, which will appear in different colors.
  • Splitting windows. It's a lot simpler than the Sublime Text Origami plugin.

Update: I switched back to jEdit. Sublime is good (and it looks better), but I was just too used to my old editor and missed the few things that it did better.

Read more…

UX: Is it better to ignore errors or fail loudly?

This question came up in a discussion I was having with my co-worker Chris Brewer. Suppose /foo is valid, but the user asks for /foo/bar. Should we just show /foo, or show a 404?

In other words, which is better: being nice or failing loudly?

Superficial love or tough love?

Arguments for the former: Postel's Law. Null Object pattern.

Arguments for the latter: Throwing exceptions. Fail loudly.

Read more…

Why doc is important in code

At Ning, my teammate Chris Brewer and I like to document our code thoroughly: JavaDoc-style doc for all our PHP/JS classes, methods, method parameters, and instance variables.

There are two very good reasons for documenting everything, even non-public functions:

1. Developers come and go. If you need to do some work on some unfamiliar code written by someone 5 years ago (maybe even yourself), you will appreciate the doc he left saying what the class or method is supposed to do. For example,

class Bundle extends XG_Model {

doesn't help much, whereas

/**
 * A collection of Entry objects. For example, a blog is a Bundle of BlogEntry
 * objects. Equivalent to a "widget instance" in the old WWF world.
 */
class Bundle extends XG_Model {

gives you more clues.

2. The doc is a loose contract that often hints at the assumptions for each method parameter. For example,

* @param integer $start  (optional) index of the first object to return

tells you that the code doesn't expect you to set $start (it is "optional"). If we wanted to change the function to make $start a required parameter, we would know that some callers may not have set $start, and we would know to double-check all callers to make sure.

These are little things, but they make a developer's life easier.

Read more…

Philosophy books

I have been feeling a bit intellectually starved of late, not having read seriously in a while. I came across this great list of Peter Kreeft's recommended philosophy books, and I would like to do some slow reading of some of those, starting with the Book of Ecclesiastes. I would like to choose titles that have some connection to my Catholic faith - so Plato and Aristotle for example. "On Beauty" also sounds promising.

Read more…

Ning A-Team is Hiring a Software Engineer

The team I am on at Ning ("A-Team") is looking to hire a junior software engineer. You just might like working here if you like working sane hours, working on user-facing code, and having co-workers that are laid back yet darn smart. You'll also like working here if you are a fan of solid engineering practices like unit tests, code reviews (ReviewBoard), version control (Git), having a bug database (Jira), and having dedicated QA engineers.

Email me if interested!

Read more…

Notes on using the Clown Car Technique in IE

The Clown Car Technique is a clever way to implement responsive images by stuffing a big blob of SVG into an <object> tag.

Below are some tips and tricks for making it work properly in IE and making it clickable.

To make it work properly in IE:

  • Pull the fallback image outside of the <object> tag and use conditional comment to display either the <object> or the fallback image. Putting the fallback image inside the <object> tag doesn't seem to work in IE8 - note that Estelle's demo shows a broken image in IE8.

<!--[if (gt IE 8)|(!IE)]><!-->
<object data="data:image/svg+xml,{{urlEncodedSvg}}" type="image/svg+xml"></object>
<!--<![endif]-->
<!--[if lte IE 8]>
{{fallbackImage}}
<![endif]-->

  • On the <object>, specify a width (e.g., width: 100%; or width: 50%;). If you do not specify a width, the height will stay at about 100px for some reason. This is what Estelle does in her clown-car demo.
  • Also on her clown-car demo, Estelle sets the URLs to https rather than http. Otherwise, you get "SEC7111: HTTPS security is compromised" errors in the IE console. That said, the errors don't seem to be user-facing...

To make it clickable:

  • Put <a> around the fallback image.
  • Add xmlns:xlink="http://www.w3.org/1999/xlink" to the <svg> element, and put the following inside the <svg> element, replacing {{href}}, {{width}}, and {{height}} with your values. This will add the link behavior for Firefox, Chrome, and Safari.

<a xlink:href="{{href}}" target="_top">
<rect x="0" y="0" width="{{width}}" height="{{height}}" fill="red" fill-opacity="0" stroke="none" />
</a>

  • For IE, put the following on the <object> (replacing {{href}} with your URL): onclick="window.location = '{{href}}';"
  • Also for IE, on the <object>, specify cursor: pointer;
Read more…

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.

Read more…

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

Replacement for google.com: yandex.com. 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.

Read more…

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
Read more…

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.

Read more…

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.

Sorting

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:

Read more…

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.

tips.php

tips.txt

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
--------------------------------------------------------------------------------
Read more…

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

Read more…

Did you know?

I'm a software engineering consultant. This means I can help your company with your software engineering needs:

  • providing temporary manpower for short-staffed software projects

  • helping new software projects get off to a good architectural start

  • improving the performance and reliability of old, legacy software systems

  • doing an important investigation or small project that you've always wanted to do but haven't had time for

Since 1999, I have done software engineering projects for the Canadian government, for Silicon Valley startups, and for established Bay Area companies, for small companies and medium-sized companies, for successful commercial projects and open-source projects. 

Currently accepting small projects. If you have one, email or call me.