Jul 2, 2015 - The Exact Middle of the Year Redux


Over six years ago I wrote a post on my old Blogger blog about what I believed the exact middle of the year was. When I had written it, I remember feeling that the computations that I did were faulty since there was just something odd about the numbers I was getting.

Today, I remembered about my old post, on this year's "Middle of the Year Day," and wanted to revisit the computations that I used. Re-reading the post, the computations made logical sense, but, again, the result just felt wrong. Especially when you introduce leap seconds into the logic, things became much more murky. But then I realized something simple that I had actually accounted for, but was subtle and forgotten as you continued to read the post: the calculations that the exact middle of the year was made by grouping 4 years together, and dividing the four into equal pieces. Therefore, the calculation of the time of July 2nd at 15:04:34 is not "the exact middle of the year", but rather the "quarter marker of the current leap year cycle". In other words, on July 2nd at 15:04:34, we would be crossing another 25% through the current leap year cycle (in my parlance, a "leap year cycle" is every 4 years).

However, we do not usually look at the calendar and think about time in 4-year cycles. We usually subdivide time based on our non-scientific concept of a year, which means 365 days on a non-leap year and 366 days on a leap year. Thus, given this, the middle of the year - to the hour - is July 2nd at noon on a 365 day year. According to Wikipedia, we keep July 2nd at noon as the middle of the year on leap years too.

But, then there are timezones, so July 2nd at noon occurs at different times for different timezones. If you remained in the same timezone throughout the year, then the exact middle of the year would be July 2nd at noon for you, but if you were in Los Angeles and talked to someone in New York, you would find that they had their exact middle of the year 3 hours before you. To alleviate this discrepency across timezones, we could use a common timezone, UTC (or GMT), and just change the time for everyone depending on where you are in the world. Thus, if the exact middle of the year is July 2nd at 12:00 UTC, for myself living in the Los Angeles timezone, the middle of the year is July 2nd at 5AM (UTC-7 during summer time; or 4AM if you don't take into account Daylight Savings, which is UTC-8). So, depending on how you look at time, you could celebrate the middle of the year at either noon or whatever time noon in UTC is in your own timezone.

So, six years ago, I sought to find the exact middle of the year, and over the last half decade, the concept of the "middle of the year" became complicated by leap years and seconds and timezones, and just the general perception of time. Though I may have missed this year's crossing into the last half of the year, I feel better in knowing that I was wrong, because being wrong gave me the opportunity to look back at the question, and gave me the opportunity to evaluate my findings in a broader context.

May 31, 2015 - Setting up Magic Lantern on an Eye-Fi card for a T3i/600D


So today I wanted to take a quick detour from my normal software engineering posts and talk a little bit about a problem that I finally re-solved for my other hobby: photography. As many hobbyist photographers know, MagicLantern is an awesome open-source alternative firmware for many Canon cameras. I myself own a T3i/600D and have been using MagicLantern on it for a while now. I also own an old Eye-Fi GeoX2 card to make it easier for me to geotag and sync my pictures.

A couple years ago I managed to do what many said was difficult or impossible to do: get MagicLantern to work with the Eye-Fi cards. And the marriage between the two worked nearly flawlessly for a long time. However, a few months ago, the card had become corrupted and I had to low-level format the card. From this point on, MagicLantern did not want to work with the card. It did not help that I did not note down what I did to get the solution to work. I gave up on it for the time being, assuming that I would get back to fixing it at some point later.

Well, a much longer time passed than I expected and I now had a new need for my camera - and I wanted to be able to use MagicLantern's features again. So today I sat down in front of my computer & began hammering at it to get it to work. I finally came upon the answer and got it working.

  1. Copy the images that are currently on the Eye-Fi card by connecting the card to the dongle that came with the card, and let Eye-Fi sync the images. To make sure Eye-Fi didn't miss any images, manually copy the images again to another place off the card.
  2. Eject the Eye-Fi card. Then end the Eye-Fi Helper service.
  3. Plug the Eye-Fi card back in, then use Explorer to format the card. Do not do a quick format - do not select "ExFat" as the file system type.
  4. Open the MagicLantern firmware in 7-Zip, then select all the files and drag them to the root of the Eye-Fi card.
  5. Eject the Eye-Fi card.
  6. With the camera off, switch the camera to "M" (Manual) and make sure that there are no accessories (except the lens, of course) attached.
  7. Insert the Eye-Fi card into the T3i/600D.
  8. Turn the camera on. If the firmware update menu for MagicLantern shows up, great! Otherwise, press Menu and navigate to "Firmware v..."
  9. Click on the "Firmware v..." to update the firmware and enable MagicLantern.
  10. Once the menu mentions that the card has been marked bootable, turn the camera off, wait about 5 seconds (make sure the busy LED is not illuminated), then turn the camera back on.
  11. At this point, MagicLantern should be installed. You will notice the time show up and the free space of the Eye-Fi show up in the bottom-right corner.
  12. Go to Menu > Eye-Fi Settings and Enable the Eye-Fi card to attempt syncing again. Once the sync is complete, you can turn off the camera.

As you can see, the process is not very difficult - it just seems like a lot of steps because I'm a bit verbose. However, from this point, you should be able to take advantage of both Eye-Fi's syncing and MagicLantern's features on your T3i. However, don't rely on this - things can still go wrong, as they did for me. Your results may very.

May 23, 2015 - Know Your Tools


A few weeks ago I was given the opportunity to give a presentation to the dev team at work on Docker and how it could help us from a development perspective. It was a timely presentation as our team recently began transitioning from one version of our flagship product to another, where a lot of the underlying technologies have changed drastically. However, because we will still need to support the currently-released version of the product, it means that our developers would need to reset their development environments in order to diagnose customer issues frequently. The prospect of having to pivot our development environments presented a serious challenge for us, since setup for each environment is non-trivial.

Now, I've been a fan of Docker since I first heard about it in 2013, and have actively used it since then. But because of how stable the platform is, and the nature of my job, I never really had many chances to really dive into the more recent updates to the Docker ecosystem. However, when I did some more research for my presentation, I found out about Docker Machine, Docker Compose, Docker Swarm, as well as a number of other Docker-related tools. It made sense that I wasn't aware of these very useful tools since the containerized-application space has been changing rapidly in the last couple years, but I did not realize how much.

This realization that I did not know about these useful tools made me realize that there are many tools out that I use that I may not fully understand or are not up-to-date with. So, how does one keep up-to-date on developments for some of the most useful tools? I'm not sure, but I would suggest subscribing to GitHub projects, email lists and RSS feeds to be notified of changes. Or, whenever running a tool, check for updates to the tool and reading the changelog, if there is one.

Finally, don't settle for "that's just the way it is." Always look for new ways to do something. For instance, for a long time I used standard Docker --link arguments to link containers, but with Docker Compose, I no longer need to deal with linking containers at runtime.

This post is about 2 weeks overdue. I had the first paragraph written and had a really good post, but I forgot what my point was when I got sidetracked and didn't return to finishing this post until must later. I'm sorry it isn't as useful as it could be.