Thursday, May 13, 2010

STS-132

The next couple of days will be quite amazing if I can just stop stumbling over my own two feet. I feel like I'm 12 again.

Tuesday, December 30, 2008

Human Readable iTunes Playlist

Some quick xslt for converting an iTunes playlist exported as xml into plain text suitable for copy/paste to email or whatever:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text">

<xsl:strip-space elements="*">

<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="dict/dict">
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="key[text()='Year']">
<xsl:value-of select="following-sibling::integer">
<xsl:text> </xsl:text>
</xsl:template>

<xsl:template match="key[text()='Name']">
<xsl:value-of select="following-sibling::string">
<xsl:text> </xsl:text>
</xsl:template>

<xsl:template match="key[text()='Artist']">
<xsl:value-of select="following-sibling::string">
<xsl:text> </xsl:text>
</xsl:template>

<xsl:template match="text()|@*">
</xsl:template>

</xsl:stylesheet>


Then run as such:

xsltproc playlist.xslt NewYearsPlaylist.xml

Wednesday, October 01, 2008

Language

I was having a discussion the other night with a friend about computer programming languages. She was trying to explain what a programming language is to a non-tech person. Something she said triggered a memory about a talk I saw at OOPSLA '98 in Vancouver 10 years ago. Out of all the computer conferences and talks I've heard over the years, this one particular talk stands out and I point people to it whenever appropriate.

It was the keynote talk by Guy Steele, one of the authors of the Java language. He did something very unique in the talk that kept the audience engaged for almost the entire hour. It was a technique I haven't seen before or since, and while a bit gimicky, it was definitely memorable.

Fortunately, someone has posted the talk to Google Video with some enhanced graphics.

http://video.google.com/videoplay?docid=-8860158196198824415

It might be surprising to some younger folks I know to see that he used an actual overhead projector with handwritten slides. Projectors and powerpoint for presentations were rare even just 10 years ago. The content of the talk is just as relevant today to computer science as it was 10 years ago.

Sunday, November 18, 2007

Compiling Firefox with tcmalloc

Here's how I compile firefox with tcmalloc to experiment if it helps with the fragmentation problem.

Follow the standard firefox build instructions here: http://developer.mozilla.org/en/docs/Build_Documentation

My .mozconfig:

. $topsrcdir/browser/config/mozconfig

# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@

# Options for 'configure' (same as command-line options).
ac_add_options --with-pthreads
ac_add_options --enable-application=browser


Patch to disable zone allocator because I want it to allocate everything, even small objects, directly via tcmalloc. There's probably a better way, but this was quick and dirty.

Index: nsprpub/pr/include/private/primpl.h
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/include/private/primpl.h,v
retrieving revision 3.87
diff -r3.87 primpl.h
1867c1867
< #define _PR_ZONE_ALLOCATOR
---
> /* # define _PR_ZONE_ALLOCATOR */


Build command to link tcalloc in:

LDFLAGS=-ltcmalloc make -f client.mk build


To run with the heap profiler I do:

HEAPPROFILE=/tmp/firefox ./firefox


This creates heap dumps in /tmp like firefox.0001.heap. By default it does it whenever the usage increases by 100MB and when a total of 1G of objects have been alloced (regardless how much is still in use). See http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html for which env vars to set to change this, as well as how to examine the heap in pprof.

I don't really have any results to report yet. It would be cool to figure out how to instrument something like the images Pavlov has created showing the fragmentation. It shouldn't be that hard to do with tcmalloc or a malloc wrapper. A malloc wrapper would make it easier to compare different implementations, but might be harder to implement without adding a lot of overhead.

Tuesday, March 06, 2007

Building JDK 7 from source on ubuntu feisty

  1. Download sources from http://jdk7.dev.java.net.

  2. Several additional ubuntu packages are required:
    • apt-get install sun-java6-jdk libasound-dev libcupsys2-dev xutils-dev m4 libxt-dev x11proto-xext-dev libxext-dev libxtst-dev libxi-dev libxp-dev libxmu-dev
    • Note: if it breaks because of a missing system header or lib, go to packages.ubuntu.com and search for the missing file to find out what package to install.

  3. I had to edit one Makefile to fix a compile error (will submit this patch to Sun).
    • vi j2se/make/sun/jdbc/Makefile
    • add -fPIC to the compile commands under the make_libs target (after $(CC))

  4. Copy resources from a previous JDK binary release because they aren't included with the source:
    cd jdk1.7.0-b07/jre/lib
    mkdir resources ; cd resources ; jar -xf ../resources.jar
    ( cd com/sun/java/swing/plaf/motif/icons/ ; cp *.gif ~/src/jdk/jdk7/trunk/j2se/src/share/classes/com/sun/java/swing/plaf/motif/icons )
    ( cd com/sun/java/swing/plaf/windows/icons ; cp *.gif ~/src/jdk/jdk7/trunk/j2se/src/share/classes/com/sun/java/swing/plaf/windows/icons )
    ( cd javax/swing/plaf/metal/icons ; cp *.gif ~/src/jdk/jdk7/trunk/j2se/src/share/classes/javax/swing/plaf/metal/icons )
    ( cd javax/swing/plaf/metal ; cp -r sounds ~/src/jdk/jdk7/trunk/j2se/src/share/classes/javax/swing/plaf/metal )
    ( cd ../lib ; cp -r audio ~/src/jdk/jdk7/trunk/j2se/src/share/lib )
  5. Create build-linux.sh script:
    #!/bin/sh
    export ALT_BOOTDIR=/usr/lib/jvm/java-6-sun
    export ALT_DEVTOOLS_PATH=/usr/bin
    export FULL_VERSION="$(basename $(pwd))-$(date +'%Y''%m''%d''.''%H''%M')"
    export HOTSPOT_BUILD_JOBS=2
    export PARALLEL_COMPILE_JOBS=2
    cd control/make && /usr/bin/make MAKE_VERBOSE="" ECHO="echo" dev
  6. time ./build-linux.sh

  7. Go get lunch

  8. If it works, you should have a jdk in control/build/linux-amd64 (or linux-i386 depending on your platform)

  9. Run bin/java -version:
    java version "1.7.0"
    Java(TM) SE Runtime Environment (1.7.0-internal-fastdebug-kellyc_06_mar_2007_22_32-b00-fastdebug)
    Java HotSpot(TM) 64-Bit Server VM (build 1.7.0-internal-fastdebug-kellyc_06_mar_2007_22_32-b00-fastdebug, mixed mode)

Wednesday, January 10, 2007

my iPhone thoughts

Several other folks have been blogging about the iPhone, but so far it seems to be all gushing praise, and yes, alot of that is deserved. It's a beautiful product, as Apple almost always produces. As for some of the lacking features (3G), yes, Apple should have added those, but remember this is a first gen product. Does anyone remember the first gen iPod? You have to make tradeoffs and pick features in a first gen product.

There are a few things I think they missed though, and some nagging questions which their marketing materials don't answer yet:
  1. One handed operation? One of the key advantages I see for blackberry users is the scroll wheel. I do not have a crackberry, but when I have checked them out, that is really the killer feature, not the full qwerty keyboard. Most people read alot more email than they compose on it.
  2. Replaceable battery? C'mon Apple. You've dealt with enough iPod battery problems that you should have a clear answer for that issue on this product. Who is going to want to send in their primary means of communication to get a battery fixed for a couple weeks?
  3. Charging, especially mobile. I have an iPod nano, and I don't think the connector is particularly easy to connect normally (figuring out if it's right side up from a screen printed icon is not the best, especially if the icon has worn off). With my motorola phone (non-Razr) I can pretty much plug it into the charger in my car single handed without looking, something very nice if I'm on a call and it does the low power beep. I suppose they expect you to dock it in your car before you start driving. Similar for unplugging it. When I'm trying to catch a train to work, I want to be able to unplug my phone single handedly without looking.
  4. What kind of CPU? I know it runs macos X, but what kind of horsepower does it have?
  5. I'm sure the screen will get smudged up especially holding it up to your ear.
  6. How much non-talk time battery life is there? Especially if you use it for video playback?
I expect the 2nd gen iPhone to already be in the works and probably ready for release by the end of the year or Q1 2008. I don't remember how long it took for the 2G iPod to come out, but like the iPod this is a revolutionary product that will continue to evolve into something better. I love the nano so much more than my old 2G iPod, so I'm looking forward to the 3rd and 4th gen iPhones (and what nokia, etc. do to answer it)

Sunday, March 26, 2006

Linux might as well not have fonts

So I installed Fedora Core 5 on my laptop tonight because I installed it on my 64bit box last weekend and it looked kinda nice. I don't use the 64bit box's UI much. My laptop had a ubuntu 6.0x beta or something on it and I was quite please with ubuntu as far as it supported everything on my laptop out of the box but I'm so used to Redhats locations of files and settings that it was a little bit of a learning curve.

So to my surprise, FC5 really sucked out of the box on my laptop. Things that didn't work:
1. Wireless (needed to go get a proprietary firmware for Intel)
2. NTP server synch with no network basically halts the startup process
3. Media buttons (volume up/down/mute)
4. NFS mounting of my terrastation volume (RPC Timeout and then Segmentation Fault)
5. Fonts

So I fixed 1 pretty quick by hooking up an ethernet cable.

But #2 required booting into single-user mode (add -s to the grub boot line) and turning off the option to sync the clock (rm /etc/ntp/step-tickers)

Media buttons required setting the keyboard shortcuts in System->Preferences->Keyboard Shortcuts.

Fixing NFS took alot of effort including looking at the packets in ethereal. The RPC Timeout was the most frustrating. Finally I figured out that terastation was doing dns lookups and I didn't have it setup to route to any dns servers. It just happened that the timeout of DNS and the response packet from the mount command were almost always timed such that the client timed out 1/2 a second before the dns timed out and the response was sent. Once I got it so it could see a dns server the mount command core dumped. ulimit -c unlimited and gdb mount core showed nothing useful (symbols were stripped). So I went looking for the mount source. I found it at kernel.org (util-linux). After compilation running mount just worked. yay. stupid friggin redhat with their custom patches.

Ok, the last thing (so far...) Fonts. My Google personalized page looked like total crap and I had to scroll alot more than I used to. And Google Finance's charts are all but worthless cause Flash doesn't display any text at all. I solved that problem in ubuntu by installing ghostscript-fonts. Unfortunately they were already installed on fedora.

So I went hunting for the standard MS web core fonts... found several different RPMS of them. None worked. Lots and lots of research and editing of /etc/X11/fs/config later and still nothing... Going to fonts:/// in nautilus showed like 10 really basic fonts still. None of the standard ones I installed. Bummer. So I kept hunting. Finally I found that there's this fontconfig package installed. It has it's config in /etc/fonts/ but it doesn't include even some of the standard packages like the ghostscript or Type1 URW fonts that were installed with Fedora. What a crock. Somehow it finds the Bitstream ones in a subdir of /usr/share/fonts, but nothing else. So I added a local.conf with the following dirs:

/usr/share/fonts/webcore
/usr/share/fonts/default/Type1
/usr/share/fonts/default/ghostscript

Woohoo! Firefox now has a much better look. But still no text in flash on Google finance.

Oh well... it's 5am and I've been at this for like 10 hours now. I think I need to go to sleep. I hate Fedora now. I'll probably switch back to ubuntu on June 1 when the final badger comes out.