Tuesday, July 9, 2013

Intro to entropy (or "how many bits do I need?")

If you've ever wondered about the minimum number of bits needed to encode a particular message, check this out:


Wednesday, June 26, 2013

Use git from Matlab

For those of you who are fans of both Matlab and git, you'll really like the following project: https://github.com/slayton/matlab-git (Matlab File Exchange page: http://www.mathworks.com/matlabcentral/fileexchange/38600-git-matlab).

Simply put git.m somewhere in your path and now you can use standard git commands (e.g. status, commit, pull, push) right from the Matlab terminal. I have personally found this quite handy.

Wednesday, June 19, 2013

Latest Java update (1.6.0_51 released on June 19, 2013) breaks Matlab

Today I updated Java on my Mac (running OS 10.8) to 1.6.0_51 which unfortunately broke my Matlab (R2010b) installation: I could open the application but I couldn't interact with the GUI in any way. It seems many other people have had this issue and I wanted to endorse the solution I used:
I found this workaround, should work until Apple/Mathworks issues a patch: 
Download the Apple Java SE 2013-003 update (no longer on the Apple website but I found this link:http://apple-java-for-mac.en.softonic.com/mac/download
Then download and install Pacifist http://www.charlessoft.com 
Use Pacifist to open the Apple Java package and install using the install option of Pacifist. 
Your Java SE should be downgraded to where it was prior to applying the 2013-004 patch. This worked for me, matlab is functional again. 
Source: http://www.mathworks.com/matlabcentral/answers/79489-java-1-6-0_51-breaks-matlab-2012b-and-below
Author: http://www.mathworks.com/matlabcentral/answers/contributors/4383739-julien-aubert

If you find this useful, please visit the source link and upvote Julien's answer.

For anyone who's curious or concerned, Pacifist is just a shareware (free trial) tool to let you install older versions of applications, bypassing any "safeguards" Mac OS has in place. The whole process was simple, easy, and much faster than Googling for other options (which I also did).

Saturday, February 11, 2012

Sunset underneath the Golden Gate Bridge

Like last year, I went to photograph the sun set behind the Golden Gate Bridge. I went to the Berkeley marina because it was at sea level and at the angle (see the end of this post for details).

The clouds were beautiful:

The sun set perfectly behind the bridge:

All in all, it was beautiful:

I went back today but it was too foggy so I walked out on the pier instead...

... and caught a couple shots of Berkeley:

To anyone looking to capture shots involving the precise position of celestial bodies, I highly recommend The Photographer's Ephemeris (free for desktop download, paid iPhone and Android apps).

Saturday, January 14, 2012

How to restore Picasa albums

I really love using Picasa to edit and organize my photos. It has a fantastic set of features for editing as well as sharing. However, I had some issues when I moved some photos from my internal hard drive to my external hard drive: the albums created from these pictures disappeared. I had spent a lot of time making these albums so I was determined to find a way to restore them.

Picasa keeps backups of old albums, so at first I tried just copying the backup files into the "current albums" folder. However, Picasa seems to be too smart for such a simple hack and would undo all of my work immediately. I Googled many times trying to find a solution that would work but none were 100% correct. After combining the tricks I read about, I discovered the following solution.

Edit: it seems as though Picasa has changed the way it stores albums starting with build which was released on December 8, 2011. You can read their release notes here but essentially it looks like they'll be storing album information in the same picasa.ini files that they already used to store photo edits. Hopefully this post is soon useless!


How to restore your "missing" albums:
  1. Locate your "missing" albums.
    1. I found mine in [home folder]/Library/Application Support/Google/Picasa3/Picasa3Albums/backup/[date]
  2. Identify your missing albums.
    1. Open each album file (it ends in ".pal") in a program such as MacVim.
      1. You should be able to spot the title of the album around line 7 or 8, as shown in the picture below (power users see the script at the end of this post to automate this process):
        Locating the album title in the .pal file
      2. If this is one of the missing albums, follow step 3 and then return to this step for each subsequent album.
    2. Note: do not use TextEdit -- it automatically saves extra information that you don't want and will cause this process to fail.
    3. If you're using Windows, you might try something like Notepad++ instead of MacVim.
  3. Copy the "missing" album to a new folder (in case you mess something up).
    1. If your album is missing because you moved your pictures without telling Picasa, you'll need to use this file to point to the correct files. Do this by editing the "filename" entries; one is highlighted in the picture below:
    2. Changing the album's knowledge of the path (location) of your files in the .pal file.
  4. Create a "backup" of your existing albums using "Tools -> Back Up Pictures"
    1. Click "New Set"
      1. Make sure you use "Disk-to-disk backup"
      2. Choose a location you can easily find again (we'll call this the "backup folder" from now on)
    2. Make sure you click "Select none" so you're actually not backing up any picture files
      1. If the "Backup" button won't light up, try selecting then deselecting an album
    3. Go into the backup folder and then open the folder. $Library/Application Support/Google/Picasa3/Picasa3Albums/
    4. Open up the only folder within (it should be a weird mash-up of letters and numbers). Put your edited "missing" album files into this folder.
  5. Go to the Picasa3 folder (in [home folder]/Library/Application Support/Google/Picasa3/) and rename it something like "Picasa3 BACKUP". If you ever need to undo the steps in this tutorial, delete the Picasa3 folder that will be created in future steps and rename your backup folder back to "Picasa3".
  6. Go to Applications/Picasa, right-click and choose "Show Package Contents". This lets you see hidden parts of the application.
  7. In the new window that pops up, go to the folder Contents/Resources/cdautorun/ and double-click "Picasa Restore.app"
    1. The window that pops up looks like an error, but don't worry about it. Instead, choose "Open Manifest..." and choose "PicasaManifest.xml" in your backup folder
  8. Now start up Picasa again and let it search for all of your photos again. When it finishes, all of your albums should be back!

Did this work for you? If not, what went wrong?

Power users:
I created a little shell script to automate the process of finding the album titles. Here it is:

for f in *.pal
        echo "Processing $f"
        head -7 $f | tail -2
echo ""
Note that you'll have to store it outside of your Picasa3 folder since Picasa tends to wipe out any unrecognized files. Run it from within the albums folder (the one with all of the .pal files).

Tuesday, May 17, 2011

Instant, cheap heat

I'm one of those people that's cold even in warm weather. Rather than constantly running up the heating bills, I make use of a flax bag. You only need to pop it into the microwave for a few minutes and it's warm for at least an hour. In fact, since the flax seed inside has a high heat capacity, even using an un-microwaved flax bag is equivalent to an extra blanket. They're certainly much cheaper (and more satisfying) than heating the whole space to 80 degrees!

Source: http://www.f-r-chiro.com/images/100_0942.JPG
Source: http://www.massagesantarosa.com/assets/HTPimages/BlueBeachMed-heating-pad.gif

I've been fortunate enough to have received flax bags for Christmas and so I've never had to buy my own. However, I'm told you can buy them at farmer's markets (~$20) or make them at home (some suggest using rice or other materials). I've also seen a few commercial versions. Do you have any good sources or tips on making your own?

Version control for the time-limited

I often keep many versions of the same file around in case I decide later that I needed some little paragraph or code snippet. It's also very useful to be able to see under which set of code a particular set of data was generated (e.g. "did I fix the bug before or after I made this data?"). Thus, I was looking for some version control software to help me out.

I won't claim that this is the best version control software out there, but it works well for me. I use Git as a backend (read more about it on Wikipedia if you'd like -- Linus Torvolds started it) and SmartGit as my user interface. It allows me to commit changes with comments or revert to old versions. I can also see the differences between versions and track file history (branches, etc.).

As your next step, you can check out some of the screenshots I've posted below (stolen from SmartGit's screenshots page) or read another review.

Directory and file list

Graphical change log

Differences between two files