Archive - 2008

Date

December 11th

October 10th

Make it stop!

From today’s Metro:

An Ohio man was facing a $150 fine for playing rap music too loudly on his car stereo in July. But a judge offered to reduce that to $35 if he spent 20 hours listening to classical music by the likes of Bach and Chopin. The man, 24, lasted only about 15 minutes, a probation officer said.

October 6th

Greatest OS textbook cover

in

OS Textbook

October 5th

Nuit Blanche 2008

nuit blanche
Nuit Blanche is getting a little too popular in my opinion. The streets smelled of pot and cigarettes the entire night. Some exhibits I was looking forward to seeing weren’t even there.

This guy was pretty cool, though, even if a little schizophrenic.

September 21st

JavaScript forms

The code in question:

<html>
    <head>
        <script type="text/javascript">
            function doIt() {
                var frm = document.getElementById('form1');
                frm.action = 'rightaction.html';
                frm.submit();
            }
        </script>
    </head>
    <body>
        <form action="wrongaction.html" id="form1" method="post">
            <input type="hidden" name="action" value="fieldaction.html" />
            <button onclick="doIt()">do it</button>
        </form>
    </body>
</html>

On IE, instead of updating the action attribute of the form element, it changes the value attribute of the hidden field named “action”. It does this even with frm.setAttribute('action', 'rightaction.html'). The only workaround I found was to temporarily remove the hidden input tag from the DOM, change the form’s action attribute and then reinsert the input tag. Is there a better solution?

Update: After some googling, found the answer. The fix is to use the getAttributeNode() function. The resulting code is as follows:

<html>
    <head>
        <script type="text/javascript">
            function doIt() {
                var frm = document.getElementById('form1');
                frm.getAttributeNode('action').value = 'rightaction.html';
                frm.submit();
            }
        </script>
    </head>
    <body>
        <form action="wrongaction.html" id="form1" method="post">
            <input type="hidden" name="action" value="fieldaction.html" />
            <button onclick="doIt()">do it</button>
        </form>
    </body>
</html>

July 8th

bzr-loom : a better example

in

If the last post made sense, there’s a much more in-depth example here.

Combine bzr-loom with shelf and you can handle any sort of interruptions in your workflow without having to manually keep track of uncommitted changes.

One downside of bzr-loom is the terminology. bzr combine-thread actually destroys the thread tossing all the changes made in it, which can be unpleasantly surprising. There’s a bug about it, though.

July 7th

bzr-loom

in

Branching may be cheap in DVCSs from the technical perspective, but sometimes it’s other factors that make it a pain. For example, the environment setup procedure could be very tedious, or you may be unable to use hardlinks (Windows) and your branches are too large. The bzr-loom plugin comes in handy in these situations. A very simple example follows:

## Install bzr-loom using `bzr branch lp:bzr-loom` in your .bazaar/plugins/
 
# Create a new repository
$ bzr init bzr
$ cd bzr
 
# Create a new file
$ echo initial > first
 
# Check it in
$ bzr add first
added first
$ bzr ci -m "initial"
Committing to: /home/tro/temp/bzr/
added first
Committed revision 1.
 
$ cat first
initial
 
# Set the branch nick specifically. This is the initial development "thread".
$ bzr nick initial
 
# Create a loom. From this point on, you have to have the plugin to interact with this repo directly
$ bzr loomify
 
# Only one thread exists right now
$ bzr show-loom
=>initial
 
# Add a new thread (acts as another branch inside the current directory)
$ bzr create-thread feature-1
 
# Add a new file
$ echo "second file" > second
$ bzr add second
added second
$ bzr ci -m "+second"
Committing to: /home/tro/temp/bzr/
added second
Committed revision 2.
 
# Switch back to the initial dev thread. Note how "second" disappears, since it is in another thread.
$ bzr down-thread
All changes applied successfully.
Moved to thread 'initial'.
$ bzr show-loom
  feature-1
=>initial
$ ls
first
 
# Switch to feature-1
$ bzr up-thread # this would do a merge, if any new changes were made in "initial"
$ ls
first  second
 
# Edit first
$ echo "edit in feature-1 thread" >> first
$ cat first
initial
edit in feature-1 thread
$ bzr ci -m "useless text meant to illustrate merging between threads"
 
# At this point pretend that we are satisfied with the changes in "feature-1"
# and want to merge them into "initial". Go there.
$ bzr down-thread
$ ls
first
$ bzr merge -r thread:feature-1 .
+N  second
 M  first
All changes applied successfully.
 
# Merged changes from feature-1 to initial
$ ls
first  second
$ cat first
initial
edit in feature-1 thread
$ cat second
second file

This gives you a limited git-like ability to spawn off new branches in the current directory.

May 12th

Wotan Server

These guys totally saved me today. I dropped my phone today (had it on my lap when I got up) and its screen got all messed up. Turns out flashing the firmware helps restore things to normal state. Float’s helped to restore contacts and msgs. Success.

May 4th

Python concurrency

Part of the reason why pjs pjabberd only works on a single processing unit (core) right now is because of the GIL in Python. The architecture uses the asyncore module (asynchronous, like twisted). Looks like it was a good choice, though. In Concurrency with Python, Twisted, and Flex Bruce Eckel demonstrates how he got extreme parallelism from Python+Twisted by spawning n python interpreters, where n is the number of processing units on a machine, and communicating between them via sockets. The Flex part can be mostly ignored. This will come in handy for pjabberd when we add support for multiprocess operation and clustering.

April 18th

Jabber video

This is my lame-o jabber video.

Video editing on Linux sucks. I used Cinerella to make this. Issues encountered:

  • The slides had to be individually exported to PNG from OpenOffice.
  • Each slide then had to be individually resized in gimp to match the size in the video. Cinerella just couldn’t do that for me.
  • Cinerella crashes once in a while, so I learned to save my work every 5 seconds.
  • Cinerella’s UI is awful, but you get used to it.
  • The biggest problem is its importing and rendering. I had to try out 10-15 different combinations of audio/video formats to make it render the video properly. It couldn’t import any avis or movs that I generated from recordmydesktop’s ogvs (via mencoder). The only format it liked was mp4.
  • Then it couldn’t get the sound right. It was recorded with Audacity in mono with 16kbps bitrate. Cinerella kept producing either no sound or sound in only one channel. I had to manually drop the bitrate in the rendered result to 16kbps and tinker with output settings (neither mp3 nor mpeg audio worked). I had to manually duplicate the contents of the audio track into another, which resulted in 2-channel output (even though the project was already set to 2-chan).

To give it credit though, the docs are pretty decent.

I spent way too much time making it all work. Next time, I’ll just find a Mac that I can use to do this.