Drawing Feature Models in PGF / Tikz

Here’s the code used to draw the feature model using PGF / TiKZ in LaTeX. Any suggestions for improvement are welecome!

    feature/.style={draw, inner sep=1.5mm, font=\small\sffamily, fill=white, drop shadow},
\begin{tikzpicture}[node distance=.8cm]
  \node[feature] (phone) {Phone};
  \matrix (sub)[matrix of nodes,
                below=of phone,
                column sep=3mm, row sep=0mm, nodes=feature]{
  Processor & %sub-1-1
  NFC & %sub-1-2
  Camera & %sub-1-3
  4G \\ %sub-1-4
  \matrix (group)[matrix of nodes, 
                  below=of sub-1-1,
                  column sep=3mm, row sep=0mm, nodes=feature]{
  ARM & %group-1-1
  OMAP & %group-1-2
  Snapdragon \\ %group-1-3
  \draw (phone.south) -- (sub-1-1.north);
  \draw (phone.south) -- (sub-1-2.north);
  \draw (phone.south) -- (sub-1-3.north);
  \draw (phone.south) -- (sub-1-4.north);
  \draw (sub-1-1.south) -- (group-1-1);
  \draw (sub-1-1.south) -- (group-1-2);
  \draw (sub-1-1.south) -- (group-1-3);
  %cross-tree constraint
  \draw[-triangle 45,dashed] (sub-1-4) |- (group-1-3)
    node[pos=.6,anchor=south east] {implies};
  %optional / mandatory
  \draw[opt] (sub-1-2.north) circle (.8mm); 
  \draw[opt] (sub-1-4.north) circle (.8mm); 
  \fill[draw] (sub-1-1.north) circle (.8mm); 
  \fill[draw] (sub-1-3.north) circle (.8mm); 
  %Group arc
    \path[clip] (sub-1-1.south) -- (group-1-1.center) -- (group-1-3.center) -- cycle;
    \draw (sub-1-1.south) circle (.5cm);

Ted, meet my Ted: Woggie

Meet Woggie. It might be hard to tell, but he’s a dog. I had him pretty much all my life… and this blog is named on his behalf!

Wicd template for eduroam at the University of Waterloo

Waterloo’s jumping aboard the eduroam bandwagon and is phasing out their uw-secure network on November 1st, 2010. Here’s the wicd template that you need connect to eduroam, just place it in the /etc/wicd/encryption/templates/ on Arch Linux and add your template to the active file in the same directory:

name = Eduroam UW
author = Steven She
version = 1
require username *Username password *Password

Converting PDFs to SWF

Update: This doesn’t work for Adobe Connect. I uploaded the converted SWF to Connect only to lose the keyboard input necessary for changing pages. I ended up using the old Macromedia FlashPaper on Windows to create a usable SWF. A basic SWFTools viewer with several mouse buttons for navigation would be a nice solution, but I haven’t found one just yet.

We’ve been using Adobe Connect in the lab recently, but, ironically, our version of Adobe Connect did not support PDFs (I suppose this is a remnant of the old Macromedia buyout). In any case, a nice solution is to convert the PDF to a SWF. Lucky for us, there is an OSS tool just for that. Enter, SWFTools. The suite contains the tool, pdf2swf designed just the purpose. The default settings for the tool progress through the pages in the PDF like a slideshow; definately not what we want for a presentation. We can, however, specify a viewer to use. SWFTools ship with a keyboard viewer that work great for presentations. Execute this command (on Arch Linux, change the location of keyboard_viewer.swf for other distributions accordingly) to convert a PDF:

pdf2swf -B /usr/share/swftools/swfs/keyboard_viewer.swf doc.pdf

Note to self: when working when multi-module maven projects, do not have a class with the same fully-qualified name in another module. Be prepared for obscure run-time errors causing immense frustration otherwise.

Fixing Skype lag with Pulseaudio 0.9.21

I had some trouble with my audio output lagging for a couple seconds when using my USB headset with Pulseaudio 0.9.21 on Arch Linux. It turned out to be a problem with the Pulseaudio suspending the USB headset when it was idle. Commenting out module-suspend-on-idle in /etc/pulse/system.pa and /etc/pulse/default.pa is a quick fix, but it removes support to USB suspend.

It turns out that there was a bug in Pulseaudio that’s fixed in git upstream, but not yet released. Apply the patch to 0.9.21 and re-compile to fix the problem.

A quick hint for compiling the LKC parser. The kbuild system requires that bison 2.3 is used. Newer versions (in my case, 2.4) generate code that throw a compilation error.

Goodbye Leipzig and Linz

In Linz

Arrived in Linz yesterday night by train. Getting from tram station to the hotel was difficult since the wheel’s didn’t really work with all the snow on the group. I had completely overlooked the fact that there might be snow when packing in Toronto. This shot was taken during the lunch break at the Vamos workshop today. The pond must have been deep since it was definitely below zero yet the water wasn’t frozen over.

The Monument of the Battle of Nations

Thorsten and Maria brought me to the Monument of the Battle of Nations today. I went with the expectation of seeing a statue, only to find this monolithic structure overlooking a frozen-over lake. It looked as if it could have been out of the Lord of the Rings.

Wicd Template for University of Leipzig

Here’s a wicd template for the EAP-TTLS + PAP setup at the University of Leipzig. This was just a small customization of the template from Shawn MacLean, so all credit goes to him. Create the file /etc/wicd/encryption/templates/eap-ttls containing:

name = EAP-TTLS with PAP
author = Shawn MacLean
version = 1
require identity *Identity password *Password ca_cert *Path_to_CA_Cert

Add eap-ttls to /etc/wicd/encryption/templates/active, restart the GUI and the settings should now appear in the dropdown menu.

In Leipzig

Learning Photography

I’ve been getting into photography lately, and it’s been quite an interesting process so far. It’s incredible how a photograph can capture all the little details that you just didn’t notice when you were there in person. I’m only at the start of this journey (or addiction)… it’ll be interesting to see where I end up a year from now.

Migrating to WordPress 2.9

I haven’t spent much time on this blog lately and now I’ve run into the classic migration problem. I’ll be slowly updating in the next couple days.

The Globe and Mail placed the Canadian Copyright reform bill on a wiki for users to edit. I think this is a great use of a wiki and gives us an opportunity to read up on our rights and (maybe) make a change.

Installing Confluence using Apache Tomcat 6 and Ubuntu

Here’s a short guide for installing Confluence on a shared Tomcat server instance on Ubuntu 8.10. Apache Tomcat 6 can be installed using a simple apt-get command:

sudo apt-get install tomcat6

Next, we’ll need to raise the Tomcat heap size for confluence. Edit /etc/default/tomcat6 and add the line:

JAVA_OPTS="-Xms128m -Xmx1024m -XX:MaxPermSize=256m $JAVA_OPTS -Djava.awt.headless=true"

Now, we’ll need to grant security permissions to the Confluence webapp. To do this, create a file /etc/tomcat6/policy.d/05confluence.policy and place the following text in it:

grant codeBase "file:${catalina.home}/webapps/confluence/-" {
permission java.security.AllPermission;

grant {
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.RuntimePermission "defineCGLIBClassInJavaPackage";

Finally, we can restart Tomcat using the command:

/etc/init.d/tomcat6 restart


I was debugging a seemingly random crash in some graph layout code. An hour later... feeling proud of myself for having fixed the problem, I wanted to file the problem in the bug tracker, only to find a bug report with the exact problem and resolution. Lesson learned: Always, always, check the bug tracker before trying to debug broken code yourself.

Computers fail again. The TSX halted its trading for an entire day due to problems with its data feeds. What sort of problem with data feeds could be so horrible to require an entire day to fix? Source.

Groovy Combinations Generator

Ever needed to find all  k-combinations of a set? Of course! I’m pretty sure everybody has run into this problem one way or another, as part of your development work, a combinatorics assignment (eek!) or in every day life. For me, I needed to implement this for generating association rules. What better way to prototype my eventual Java implementation than to use Groovy.

def choose(def itemset, int choose) {
    def choose(def itemset, int choose) {
    def results = []
    //Initialize indices
    int[] indices = new int[choose]
    for (i in 0..<choose) {
        indices[i] = i
    boolean hasMore = true;
    while (hasMore) {
        def combo = []
        for (i in 0..<indices.size()) {
            combo << itemset[indices[i]]
        results << combo
        hasMore = { /* Closure to move the right-most index */
            int rightMostIndex = { /* Closure to find the right-most index */
                    for (i in choose-1..0){
                        int bounds = itemset.size() - choose + i
                        if (indices[i] < bounds) return i
                    return -1
            }() // execute closure
            // increment all indices
            if (rightMostIndex >= 0) {
                for (i in rightMostIndex+1..<choose) {
                    indices[i] = indices[i-1] + 1;
                // there are still more combinations
                return true 
            // reached the end, no more combinations
            return false
        }() // execute closure
    return results

I’ve based my implementation off one from Applied Combinatorics by Alan Tucker. First, there is an indice array that stores the k positions in the itemset. The items at these index locations are the k-combinations. The algorithm increases the right-most index until it reaches the last element of the itemset, then increases, the second right-most index and so on.

I wouldn’t recommend this implementation when dealing with large itemsets. A deficiency with this one-method approach is that a single list is constructed containing all of the combinations. This list can grow to be very large, very fast. It can be easily adapted to provide one combination at a time by refactoring the hasMore check into a separate method. This way, it would act like an iterator. It’s too bad that Groovy doesn’t have support for the do-while loop as well, otherwise the hasMore closure could have been factored out into a really cool while check.

Opening a Marker in an Eclipse Java Editor

Markers are a great feature of Eclipse and there are some great articles on creating Markers. However, I couldn’t find a good article on opening markers in an editor. So, here’s the best call sequence that I could figure out:

IJavaElement element = ...;
IEditorInput input = EditorUtility.getEditorInput(element);
IEditorPart editor = getSite().getPage().openEditor(input,
    (input instanceof FileEditorInput) ? : JavaUI.ID_CU_EDITOR 
            : JavaUI.ID_CF_EDITOR);
IDE.gotoMarker(editor, sNode.getMarker());

EditorUtility is an internal JDT class, but I couldn’t find a better way of doing this. A check on the return type of the getEditorInput call is necessary to since it can return either a file editor (for compilation units) or a class file editor.