21 September 2010

Message from (GNU) God

Because I have a CSAIL account (courtesy of 6.172), I now receive ~10 more emails a day, on top of ~50 from my regular MIT account (if you want to contribute, that would be shewu-at-csail). On one thread, someone was asking for help to get matlab/gui tunneling over ssh.

Here was the original inquiry:

May I know that if there's any way to remote access to athena with GNOME? I could set up the graphics xterm connection (using X-Win32), but there's no gdm installed and startx does not work

My purpose is to use the matlab on the athena server for homework... My computer is a 64bit windows and does not support matlab...

Since this is the CSAIL mailing list, several people gave helpful responses and solved the problem within a day. However, this morning, when I checked my email, I saw a response from the GNU God, Richard Stallman:

I am obliged to remind people that Matlab is a proprietary program. It doesn't respect the freedom of those who use it.

There is a free replacement named Octave which does the same job. It does not have the same range of high-level packages, so your help is needed in extending them.

=D

I wonder why Stallman did not critique OP's use of Windows.

I do realize that posting even famous people's emails is rude, but dude, this is the GNU God!

Learning by Doing

For 6.172 (that's Performance Engineering of Software Systems for non-MITers), we were assigned our first project. The task was to optimize (or rewrite) the supplied code to solve three tasks (OCW has two of the three tasks). We were given access to sixteen dual-hexacore (so twelve physical cores total, with hyperthreading (so twenty-four virtual cores)) machines with 48GB RAM each. The code was distributed via the class' own git repository, and it would also be used for submitting our beta and final code. Because I was a lowly froshie and was eager to become acknowledged, I spent most of my free time staring at the computer, coding.

For simplicity, I coded on the CSAIL machines so I would not have to worry about code fragmenting among multiple machines (my CSAIL AFS locker, my laptop, and my desktop). I used a combination of vim and screen to view and edit multiple files at once, make to compile the project, gdb to debug, and git for version control. You'll realize that these are all terminal-based and open source tools, which means that I did not have to rely on a GUI or purchase the programs. I do not want to resort to torrenting tools and working in the terminal solicits weird looks from people. :D

In any case, I was having trouble tracing the cause of a bug in a program. Having read a book about basic debugging and working with gdb during the summer, I pulled out gdb and said book and began delving into code. Setting breakpoints was easy:

(gdb) break everybit.c:254

to set a breakpoint in file everybit.c at line 254.

I finally figured out that getting a signed char (in range [-128, 127]) to map to [0, 255] while keeping the same bit representation was to simply cast it to an unsigned char. In other words, the map I wanted was [0,127] -> [0,127] and [128,255] -> [-128,-1], and casting works because for i in [0,127], the most significant bit does not matter, but for i in [128,255], the most significant bit is worth +128 in unsigned chars rather than -128. This bug took me approximately two days to and multiple trials to squash.

Later, when I was well into the project, I encountered an annoying git error that complained about a non-fast forward change. I'm still not sure how to fix this because I did not log what I did to resolve the solution, but the logical thing is to copy the edited file, checkout the file (so it is reverted to the one in the git repo), and then merge by hand. Actually, thinking about it now, creating a new branch, pushing changes to that, and then merging that branch with the master branch will let git combine the two files so you can just delete the old parts (the different parts are sectioned with <<<<<<<<<< and >>>>>>>>>>).

Merging brings me to my second note about git. DO IT! Pushing everything to the master branch, while it may seem convenient, will cause major troubles (somewhat similar to those aforementioned). Branching will be used in any decently sized software development and by any decently reasonable software developers.

Last but not least, recording all tricks that you tried and noting what works/does not work is one of the most valuable lab skills. Your log becomes an invaluable resource (aside from Google) because not only do you have archives of what you have tried before, but also note new observations and untested tricks/experimentation methods. The more you consult your blog to add new material, the more you will see your old notes, and thus remember them! After all, this is what blogs are for!

15 September 2010

In Times of Desperation

So, this morning, when I poured milk into my daily bowl of cereal, the milk ran out.


Because I can't live without milk1, I headed toward La Verdes after my biology recitation2 to buy a gallon of milk. When I finally found the milk shelf surrounded by a myriad of sodas, I saw the price. $5 for a gallon, $3 for half a gallon, and $2 for a quart. For sake of completeness, the Shaw's near Random House sells milk for approximately $4 a gallon.


Seriously?! The Costco near my house sells milk for $2.25 for a gallon. I can practically get four times the milk for the same amount of money at Costco than from here. So then I thought about the problem some more:

(Assuming that walking costs no money)


Therefore we choose La Verdes milk over Costco milk at this moment, but most definitely Costco milk over La Verdes milk when I have an entire list of food to purchase.

$$Q.E.D.$$

[1] I drink approximately 36 ounces a day; 12 ounces at each meal
[2] completely useless if you have a decent background in the subject or pay attention to the lectures and read the textbook

09 September 2010

Mac Snac 004 - QuickLook X-Ray Folders

Here is a cool Mac OS X Snow Leopard trick that I found from the MacCast:

Well, here's a cool little trick I ran across while trying to find a way to hide the menu and scrollbars in Mac OS X. This one is a Terminal hack that you can perform in Mac OS X Snow Leopard to get folders in Quicklook preview to show up with transparent covers. This gives you an "x-ray" style view of the icons of items inside that folder. Pretty neat. Here's a little video on how to do it along with step by step instructions after the break:




Step-by-step
1) Launch Terminal (Applications–>Utilities–>Terminal)
2) Type in the following command:

    defaults write com.apple.finder QLEnableXRayFolders 1
3) Control+Option+Click the Finder icon in the dock and select ‘Relaunch’ to restart the Finder.
4) Select a folder in the Finder and press the spacebar to open it in Quicklook.
5) The folder icon should now have a transparent cover and you can see the icons of items inside the folder



Secrets – The GUI Method
1) Go to the Blacktree Site and download Secrets
2) Install Secrets. Double-click the .prefpane file and say OK when it asks if you want to install the Preference Pane.
3) Open System Preferences–>Secrets
4) In the ‘Top Secrets’ section check the box next to ‘Show X-ray folders in QuickLook’.
5) Click the ‘Quit This’ button to quit the Finder.
6) Click the Finder icon in the dock to relaunch the Finder.
7) Select a folder in the Finder and press the spacebar to open it in Quicklook.
8) The folder icon should now have a transparent cover and you can see the icons of items inside the folder


This is what it looks like:


[source]

06 September 2010

Bloody Hell!

AN: If you are any bit allergic to the sight and/or description of blood, I suggest you do not read the following.

I was surprised to find out that a philips head screw was stuck in the bottom of my left shoe and punctured the surface on which my foot rests.

Oh my!

So how did I find out?

Bloody hell!

I casually jumped off the third to last step in my stairwell and felt something puncture my left heel. When I took my foot out, blood dripped everywhere on the platform as I thought, `Ohhhhhhhh dear...' When I inspected the interior of the shoe, I noticed a sharp point poking out of the sole. Thinking that it was a piece of mulch or a small stone, I tried to extract it. It didn't budge. I reversed the shoe and saw that a philips head screw was more or less screwed (or hammered) into my shoe. I probably stepped into it when I helped disassemble the roller coaster and other wooden structures in the EC courtyard right before the hurricane came. I limped up two flights of stairs into my dorm and wiped, neosporined, and bandaged my foot. I tried to clean out the shoe to no avail. After I gave the wound proper medical attention, I went to the aforementioned platform in the stairwell and cleaned up the blood (because I am a good citizen). I guess I won't be leaving my room (or dorm) today...

The culprit. Approx 2" long.

No, I am not British.

UPDATE: I went to MITmed and the doctors said that the wound was not bad. They cleaned it with alcohol and gave me a tetanus shot just in case. The doctor said that I should definitely not take the swim test tomorrow. He also said to come back on Friday to get the progress of the wound checked.

Quotes (because people say funny things when one gets injured):

``I think you need new shoes'' -- the doctor at MITmed
``Only at EC'' -- V. Enjamio
``Well luckily you still can play bridge'' -- S. Fingeret
``the blood stain looks more to me like a sad clown. wait no angry clown.'' -- A. Zhu

04 September 2010

The Hacking has Commenced

MIT was generous enough to give each student a MingleStick, a USB drive-like device that could store your user info and get other people's information via IR communication. It was pretty frivolous to me, so in true EAsT camPUS (this is the correct capitalization of my dorm's name) fashion, I cracked it open to see the circuits.

Augh, sunglare!

That big microcontroller in the center is a PIC24FJ64, made by Microchip. Since I had not worked with this family of chips before (I mainly used PIC18Fs before I jumped on the Arduino bandwagon), I searched on Google for a datasheet and found one here. The other easily identifiable parts include the male USB type A connector, the IR sensor and emitter, and a switch, power LED, and coin cell battery on the back.