This site is no longer updated. Please visit my new website.

The World of Kevin

Software and electronics engineer studying at Columbia University.

End of an era

It’s been a good run, Tumblr, but I finally found the time to run my own site on my own domain using my own software. I won’t be updating this site anymore, but it’ll stay up for posterity. All posts have been imported to my new site.

Visit my new site now!

Plotting airplane GPS data in Google Earth

For fun, I collected some GPS data from the takeoff and landing of my most recent flight home. I used the now defunct Xtrail app to save GPS data from my iPhone to a GPX file, which I then opened with Google Earth.

Path of takeoff from JFK airportTakeoff from New York JFK

Path of landing at SFO airportLanding at San Francisco. The data got messed up in the middle because Xtrail kept crashing. Fortunately, it’s not very noticeable from this perspective.

You can then run the flight simulator to see how well you can follow the line!

My airplane nearly flips overHint: I suck.

There are a couple tricks to make this work better:

  • Get the window seat.
  • Make sure your iPhone starts getting a GPS lock long before you need to use the data. It can take awhile in some planes.
  • If you don’t get GPS data continuously during your flight, you’ll have to wait until you have cell reception at about 20,000 feet before you can log data again.
  • When Google Earth asks to map your GPX file’s coordinates to the altitude of the terrain, just say no.

The Making of the Lattice Energy Video

In our school’s AP Chemistry program, we are allowed an extra credit project at the end of the first semester. I chose to make a video tutorial about calculating lattice energy because I had trouble with in the past. Since it’s one of the more challenging and creative assignments I’ve done for school, it deserves a quick writeup.

The project took about six hours in total. I started by finding and solving a few lattice-energy problems from the Internet. I decided how to introduce lattice energy and wrote a script. It’s deliberately repetitive because we “must cross the line between ignorance and insight many times before we truly understand” (source). That was the easy part.

The harder problem to solve was the technical one: how to record my tutorial. I’m not a fan of tablets with styluses, because a real pen and paper feel have better control even though they can’t undo. I decided to explain the problems on paper and record it with my iPhone. My Glif+ adapter allowed me to mount my phone on a tripod, but no tripod could shoot straight down. To avoid skewing the image, I opted to hold my phone with a stack of books:

Stack of books that held my iPhone above the page being recorded

The thin Dr. Seuss book protrudes from the rest so that the camera can’t see the stack of books. I had to counterbalance it with Mathematica and Algorithms in C++. I padded one side of the phone with an envelope for some minor skew correction. The phone was connected to my computer to keep it charged and to download footage periodically.

For lighting, the iPhone’s built-in flash turned out to be the best choice. Because the flash and the camera are so close together, my hand’s shadow wasn’t visible from the camera’s point of view. This also allowed me to darken the room during shooting to prevent stray shadows from other lights:

My phone and the page being recorded

I measured the camera’s field of view and printed papers with boxes on them. Combined with the alignment guides that I taped to my desk, the boxes gave me an estimate of where to stop writing.

Various sheets of paper with writing scattered on table

Believe it or not, that photo isn’t filtered. The vignette is from a camera flash, and the colors are from the difference in color temperature between my light and the flash.

It’s normal for Time Machine to freeze while copying a large backup

I’m writing this blog post because I couldn’t find any information online about Time Machine hanging while copying files for a backup.

A bit of background: Last week, I accidentally wiped the first ~1 GB of my boot drive with dd because I assumed /dev/disk1 was the removable drive. Thanks to Time Machine, I didn’t lose more than a few minutes of work.

After everything got restored, however, the first Time Machine backup afterwards took a very long time. It seemed to hang after copying about 15 MB, no matter how many times I restarted it. The solution: Watch your computer until it finishes “Preparing Backup,” then let Time Machine run overnight.

If you cancelled the first backup and Time Machine wants to copy your entire hard drive, you need to tell it to inherit the backups from your previous OS X install.

Here’s the log file in case anyone’s interested. I have no idea why it separates the copying into many operations.

12/3/12 11:20:02.699 PM[14524]: Starting manual backup
12/3/12 11:20:03.561 PM[14524]: Backing up to: /Volumes/Kevin’s WD Time Machine/Backups.backupdb
12/3/12 11:20:04.637 PM[14524]: Inheritance scan required for /, associated with previous UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXE33CB4
12/3/12 11:20:04.851 PM[14524]: Event store UUIDs don't match for volume: Macintosh HD
12/3/12 11:20:06.982 PM[14524]: Deep event scan at path:/ reason:must scan subdirs|new event db|
12/3/12 11:20:06.983 PM[14524]: First backup after disk inheritance for / - complete scan required
12/4/12 12:03:26.066 AM[14524]: Finished scan
12/4/12 12:07:11.597 AM[14524]: Found 62118 files (7.34 GB) needing backup
12/4/12 12:07:12.944 AM[14524]: 14.73 GB required (including padding), 572.52 GB available
12/4/12 12:20:05.637 AM[14524]: Copied 15.1 MB of 7.34 GB, 91406 of 91406 items
12/4/12 1:20:06.371 AM[14524]: Copied 15.2 MB of 7.34 GB, 636464 of 636464 items
12/4/12 2:20:06.602 AM[14524]: Copied 61 MB of 7.34 GB, 968341 of 968341 items
12/4/12 3:20:07.020 AM[14524]: Copied 61 MB of 7.34 GB, 1128509 of 1128509 items
12/4/12 4:20:07.373 AM[14524]: Copied 7.01 GB of 7.34 GB, 1749413 of 1749413 items
12/4/12 4:42:53.173 AM[14524]: Copied 2041957 files (7.34 GB) from volume Macintosh HD.
12/4/12 4:42:57.259 AM[14524]: Using file event preflight for Macintosh HD
12/4/12 4:43:00.507 AM[14524]: Will copy (1.5 MB) from Macintosh HD
12/4/12 4:43:00.527 AM[14524]: Found 187 files (1.5 MB) needing backup
12/4/12 4:43:00.574 AM[14524]: 6.43 GB required (including padding), 563.23 GB available
12/4/12 4:43:55.494 AM[14524]: Copied 4614 files (1.6 MB) from volume Macintosh HD.
12/4/12 4:43:58.155 AM[14524]: Created new backup: 2012-12-04-044355

Set up a L2TP/IPsec VPN server on Ubuntu 11.04 to connect with Apple iOS and OS X clients

Just for fun, I decided to set up a VPN on an Ubuntu server I have in my house. A VPN will secure otherwise unencrypted Internet traffic when you’re on public Wi-Fi, and it can allow you to bypass internet filters.

I followed Riobard Zhan’s instructions, but there were some changes I made to be compatible with the latest Apple devices and Ubuntu. The changes below were tested with an Ubuntu 12.04 server and iOS 5.1.1 and OS X 10.7.4 clients.

In the file /etc/ipsec.conf, under conn L2TP-PSK-noNAT, you need to enable dead-peer detection (DPD) so that you can connect to the VPN more than once without restarting IPsec and friends:

dpddelay = 15
dpdtimeout = 30
dpdaction = clear

Also, whenever there is something like

echo 1 > /proc/sys/net/ipv4/ip_forward

use this instead:

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

because you don’t have permission to write to that file if you’re not logged in as root. Which you should not be doing.

If you are getting this error:

ipsec_setup: ERROR: Module xfrm4_mode_transport is in use
ipsec_setup: ERROR: Module esp4 is in use

this guy says it’s harmless.

Eclipse Hunting

I went to watch the eclipse at the Lawrence Hall of Science in Berkeley, CA. As part of an extra credit assignment for Mrs. @BarnettDreyfuss’s physics class, I did a writeup about the eclipse experience.

I brought my Linux Craptop with me so that I wouldn’t get bored. I ended up writing my notes there because I thought I was really clever. So the times listed should be fairly accurate. (I took them from camera EXIF data, my Twitter updates, my computer’s clock, and my computer’s uptime.)

I also made some drawings, which are quite horrific because I am the world’s least talented artist. As they tell us, Mrs. Barnett minored in art. She is probably laughing her head off right now.

I’m going to upload the drawings for extra credit, but your time is better spent looking at the photos I took.

Pen sketches of the sun made approximately every 5 minutes.

Here is the play-by-play commentary of the eclipse.

4:24 PM We arrived at Lawrence Hall of Science. Ooh, pretty panoramic view. The line to get glasses is insanely long. Reminds me of the pictures of WWDC.

4:39 PM Still in line, but it looks like they’re going to run out of free glasses by the time they get here. I hope we’re in the first 500 so that we get glasses.

4:44 PM Whoo, got glasses! The first thing I did was try to take a picture of the sun through them.

Crappy photo of the sun from sun viewing glasses

It didn’t turn out well. Probably the auto-exposure.

4:49 PM Boot a non-Apple laptop. Estimated 5 hours of battery life. AWW YEAH. (Well, the extra capacity battery I just got sticks out the back of the thing, but still: five hours of battery life. Not minutes, but hours.)

4:54 PM A bunch of teenage girls just walked by. “I don’t even understand what’s going on.” Probably just here for the extra credit. America!

5:00 PM Crowding really brings out the worst in everyone. A moron with a camera who won’t let anybody get near him. Seems to be looking for fights all the time. It’s nice that you got here early, but so did the rest of us. You are not special. And your reasonable-sounding excuses for getting angry fool nobody. These are your fellow human beings—be nice. This is a goddamn public facility—share it.

The guy on the other side of me, however, is a pretty cool guy.


5:16 PM Eclipse technically started. Nothing interesting to note yet, though.

5:19 PM The sun is dented in the bottom left. Here we go!


5:23 PM The moon is moving diagonally from the bottom-right area to the top-left area.

5:28 PM Helping people with safe eclipse viewing through Twitter. Tweet tweet.

5:30 PM Silly pinhole viewer doesn’t even work. Oh wait, the hole isn’t big enough.

5:31 PM Stupid pinhole viewer still doesn’t work. Oh wait, the hole isn’t round.

5:32 PM The thing still doens’t work.

5:40 PM My mom attempts to take a photo of me.

This is a photo of me. It was taken by my mom. She is bad at photos.

She isn’t the best photographer.

5:58 PM Friendly astronomer let us use his telescope! The photos turned out great.

Picture of the eclipse through Friendly Astronomer’s telescope. It’s sharp and clear.

Note: Post-processing was applied to this photo. It is an HDR composite by the iPhone’s built-in camera application.

6:13 PM People here are generally pretty cool. This guy was really enthusiastic about his pinhole viewer, so he reminded me of Mr. Hall.

Enthusiastic science guy shows off his pinhole viewer.

Wait, PINHOLE VIEWER?! Why does his work when mine didn’t?

6:16 PM Ah, pinhole viewers require a fairly exaggerated crescent shape to show something meaningful. Stupid user doesn’t work.

Projected image of the eclipse by my pinhole viewer.

Note: The image here is upside-down because of the nature of the pinhole viewer. (It works sort of like a camera.)

6:20 PM The sun is but a mere crescent-shaped sliver in the top-left.

6:24 PM Lots of creative ways to look at the sun.

Crowd of people hold their hands up in the air.

Everybody loves watching the cute little boy do the same. He’s adorable!

They’re using their fingers to simulate the shape of a pinhole viewer.

6:28 PM “Surreal: the brightness implies sunset, but the length of shadows implies daytime.”

6:34 PM Whoa, the crescent area moved to the bottom of the sun! wat.

6:35 PM Now the crescent is in the bottom left. Is it because the sun is also moving down as the moon moves across it?

6:39 PM Helicopter! Was it a news helicopter? There seems to be no other reason for a helicopter to be flying around here, other than to get photos of the nerds in their natural habitat.

Helicopter flies over the Lawrence Hall of Science building.

6:42 PM Some pseudoscientists doing a “documentary” about the healing powers of some random-ass thing because it captures the light from the sun. Berkeley!

Pseudoscientist 1 holds the statue thing to the sun while Pseudoscientist 2 videotapes.

Later, I talked to the cameraman. He’s actually from Denver. So make that one pseudoscientist and one really weirded out filmmaker.

6:43 PM Saw a guy with an Apple Worldwide Developers Conference shirt from 1998. I was going to say hi and try to get a photo with him, but then he left. Darn.

6:45 PM iPhone battery is at 2 percent. Wat do.


6:50 PM I wonder what my life will be like the next time a solar eclipse hits the Bay Area in 20 years. Then again, I might not be living in the Bay Area. Well, San Francisco looks pretty nice from here.

7:00 PM Whoa, they have eclipse viewing devices with actual magnifying lenses! Why didn’t I know about this earlier?!

The contraptions magnifies the sun.

They magnify the image of the sun to several inches wide. You can even (sort of) see sunspots!

7:03 PM Better get that panorama shot in before I run out of electricity. Snap snap snap. Oh but my phone turns off. Wonderful.

Panoramic photo of the Bay Area, including Golden Gate Bridge, Bay Bridge, and San Francisco skyscrapers.

I probably stitched this wrong but it’s late and Photoshop’s automatic stitching job looks fine to me right now.

7:04 PM Cute couple alert. Solar eclipses are romantic? Maybe she’s into science. Who knows.

7:13 PM Left for awhile. Cute couple borrowed my glasses. They don’t know this, but—I saw that!

7:35 PM the sun is merely dented in the top left.

7:38 PM sun still dented.

7:39 PM sun dent no longer visible with unaided eye.

7:42 PM leaving LHS. bye.

8:02 PM We get lost on the way home because the GPS sucks and my phone is out of power energy.


12:00 AM Finish organizing photos and drafting this post. Good night, everyone.

Please Do Learn to Program

Earlier today, Jeff Atwood of Coding Horror posted “Please Don’t Learn to Code” as a response to the recent initiatives to get people programming. Here’s a quick summary: he advocates against popularizing coding on the basis that most people have jobs that won’t require it directly. He cites the mayor of New York as an example.

I respect Atwood a lot. So I reread his article several time throughout the day, trying to understand where he comes from.

I still can’t believe how much he doesn’t get it.

The motivation behind the “everyone should code” movement is not to make everyone into a professional programmer—obviously, that would create a seriously dysfunctional society.

Instead, its primary goals are (1) to teach critical-thinking skills, and (2) to help people understand the computers that run their lives.

(Please note that I am simply advocating for introductory programming courses. Beyond that, every hour spent learning to code becomes less useful to learning those skills than the previous hour was.)

Programming teaches you how to think.

The act of writing software involves the dissection of a problem, a deep understanding each of the problem’s components, and the creation of precise instructions for a machine that will solve the problem. Debugging a piece of software requires the programmer to come up with a list of all the things that could be going wrong, and find logical ways to prove that they functioning correctly.

How are these logical skills not useful for a mayor? Or any other job, for that matter—unless you are microwaving burgers for McDonald’s, these skills are quickly generalized and useful in many other situations.

(Note that I use the word “programmer” loosely: it refers to anybody who knows how to program, not just those who do it as their day jobs.)

Put another way:

  • We encourage kids to play a musical instrument or two in order to stimulate their cognitive development: does that mean we want everyone to play for the Chicago Symphony Orchestra?

  • We push for increased science education in schools so that future adults can understand scientific and medical discoveries relevant to their lives: does this mean we want every student to become a molecular biologist?

  • We encourage people to go to the gym so that they can stay fit: does this mean we want everyone to be in the NBA?

No, no, and no. That is the superficial way of seeing things. We do these things not because they are directly useful, but because they offer indirect benefits. That the reasons aren’t immediately apparent does not imply the activities are useless or frivolous.

Microprocessors run your life.

When you press the power button on a TV, are you closing a circuit to power the TV? No, you are giving input to a piece of software on a microprocessor that causes it to run the wake up function.

When you press the gas pedal on your car, are you mechanically changing some part of the engine to make it run faster? No, you are giving a input to a program running on a microprocessor. You do not drive the car through the gas pedal; the microprocessor screens your input and allows your input to guide it in driving the car when it makes sense.

Currently, the United States has about 100 CPUs per person, a number is only going to increase as more things become digitized. More CPUs implies that we’ll need more people to write software for them.

But that job will fall to a small minority of the population. For everybody else, this means that a general understanding of the computer’s mechanisms (computer literacy) will become critical to becoming a contributing member of society. How else will a judge make an educated ruling in a trial between software companies? How else will Congress understand that blocking a data-transfer protocol won’t end piracy? These are only a few examples of the importance of a “good enough” understanding through basic programming. It’s only going to get worse.

You can yell at me about this article through Twitter. I’m @kevinchen.

The Dent in the Universe

I have always loved computers.

From the moment I found an old, beige, 166 MHz Windows 95 PC in kindergarten, I’ve always been curious. Who invented it? How does it do math so fast? Open it up, and what do you have? A mess of chips, circuit boards, wires, connectors, …

Put it all back together, and you have magic.

Steve has been the single largest driving force behind the community that’s changed my life. It’s in this community that I’ve made my closest friends, found new career paths, and reaped the greatest rewards. I’m reading the news and writing this reflection on a Macintosh. And I’ve never even met him.

To me, Steve was a man who did his best every day. He didn’t settle for anything less, and he didn’t allow the people around him to do so either. He was never afraid to challenge existing ideas. He taught people to live each day to the fullest.

And he held out for one final product launch. His last mark on the technology industry was the iPhone 4S: the iPhone For Steve.

His vision lives on in hundreds and hundreds of young people. They, too, have made it their life’s work to reduce the barriers between people and the technology they use. The universe has been dented.

Goodbye, sir. Thanks for changing my life.

— Kevin Chen, high school student

Have we entered a golden age, or is the world descending into a fiery abyss? The future is unknowable, but the study of history suggests that neither extreme is likely. Golden ages and dark ages are rare, and our understanding of our own time is easily swayed by hopes, fears, and other emotions. If the exuberant optimism of the 1990s now seems excessive, the pessimism of the early 2000s may in time seem equally far off the mark.

— Closing words of The Earth and Its Peoples: A Global History by Richard W. Bulliet, et al.

Things Paper

I love Things. It’s the best GTD / to-do list manager in the world, and I use it every day both on my Mac and on my iPod touch. 

But recently, my iPod touch stopped booting after I tried to disassemble it and fix the home button. Because I still want to use Things when I’m out and about, and because I have way too much free time, I created Things Paper, a paper version of Things: 

It has everything I like about Things — tags, due dates, areas of focus. It also comes in a disposable form factor, and tasks can easily be entered the next time I get back to my Mac. 

Next up: Twitter Paper.

Download (PDF)
Download (Pages)

Most of the icons came from The Noun Project; however, some of them came from the Special Characters menu and my mucking around in Illustrator.