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

References

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) {
                indices[rightMostIndex]++
                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.

The second trailer for the next Star Trek movie is out. I looks like quite an exciting action movie. The trailer almost has the same tone as the Transformers movie. Definitely not the Star Trek I used to know and love, but hey, I'm open to a series "reboot".

Yet Another Groovy Spelling Corrector

I’ve taken some time implementing Peter Norvig’s spelling corrector in an attempt to learn Groovy, a dynamic language that compiles to bytecode and is compatible with standard Java classes and libraries.

There are a couple differences (most likely deficiencies) with my implementation. First, I use a list instead of a set when constructing the candidate word list. Second, I created a separate occurrence function in order to provide the smoothing capability for our occurrence distribution. Third, I didn’t really care much for a low line count. It’s not the LOC that matter in the end, it’s how easily you can comprehend the code! :)

public class SpellingCorrector {
  def wordoccur = [:]
 
  def words(File file) {
    Scanner scanner = new Scanner(file)
    def words = scanner.findAll{ x -> x.toLowerCase() ==~ ~/[a-z]+/  }
  }
 
  def train(List words) {
    words.each {
      wordoccur[it] = wordoccur.containsKey(it) ? wordoccur[it] + 1 : 1
    }
  }
 
  def edits1(String word) {
    def results = []
    int n = word.length()
    //Deletion. Remove a character.
    for (i in 0..<n)
      results << word[0..<i] + word[i+1..<n]
 
    //Transposition. Swap adjacent characters.
    for (i in 0..<n-1)
      results << word[0..<i] + word[i+1] + word[i] + word[i+2..<n]
 
    //Alteration. Change one character for another letter.
    for (i in 0..<n)
      for (c in 'a'..'z')
        results << word[0..<i] + c + word[i+1..<n]
 
    //Insertion. Add a letter in between the others.
    for (i in 0..<n)
      for (c in 'a'..'z')
        results << word[0..<i] + c + word[i+1..<n]
 
    return results
  }
 
  def knownedits2(String word) {
    def candidates = []
    edits1(word).each {
      candidates.addAll( edits1(it).findAll { wordoccur.containsKey(it) } )
    }
    return candidates
  }
 
  /**
   * Smoothing distribution. If the word hasn't been encountered (novel words),
   *  we give it an occurence value of 1.
   */
  def int occurrence(String word) {
    return wordoccur[word] == null ? 1 : wordoccur[word];  
  }
 
  def List known(List words) {
    return words.findAll { wordoccur.containsKey(it.toLowerCase()) }
  }
 
  def correct(String word) {
    def candidates = [word] + known([word]) + known(edits1(word)) + knownedits2(word)
    return candidates.max {  occurrence(it) }
  }
}

First, we don’t attempt to split words into two sub-words. For example, a common typo may be “Ihave” rather than “I have”. Second, the training and known function can definitely be improved to with support for proper nouns, stemming, and more. I think it would be a fun exercise to try and to create a simple implementation of these features, much like the SpellingCorrector.

So, Groovy has great support for regular expressions, list construction and compositions and best of all, closures! I also had a chance to play with the Groovy NodeBuilder (on a separate program), which is a great way for constructing tree structures. All said and done, I would hate to implement this in Java.

Phone Obsession

I think some of you can relate. I know I can, but which character? Maybe all three!

Dilbert.com

Sample Spaces and Feature Models: There and Back Again

I presented the paper “Sample Spaces and Feature Models: There and Back Again” by K. Czarnecki, S. She, and A. Wąsowski at this year’s Software Product Line Conference.

Update: The slides for my presentation have been uploaded. Download them here: SPLC 2008 Slides (96).

MMath Thesis: Feature Model Mining

Abstract

Software systems have grown larger and more complex in recent years. Generative software development strives to automate software development from a systems family by generating implementations using domain-specific languages. In current practice, specifying domain-specific languages is a manual task requiring expert analysis of multiple information sources. Furthermore, the concepts and relations represented in a language are grown through its usage. Keeping the language consistent with its usage is a time-consuming process requiring manual comparison between the language instances and its language specification. Feature model mining addresses these issues by synthesizing a representative model bottom-up from a sample set of instances called configurations.

This thesis presents a mining algorithm that reverse-engineers a probabilistic feature model from a set of individual configurations. A configuration consists of a list of features that are defined as system properties that a stakeholder is interested in. Probabilistic expressions are retrieved from the sample configurations through the use of conjunctive and disjunctive association rule mining. These expressions are used to construct a probabilistic feature model.

Read the rest of this entry »

MMath Thesis Presentation: Feature Model Mining

I will be holding a seminar describing my Master's thesis work. It is open to all, so please attend if you're interested. Feature Model Mining. Wednesday, August 6 at 1:30pm in EIT 3145. Update: Here are the slides that I've used for my presentation. More »

It seems that Adobe doesn't want to be left out of the Web 2.0 office application fad with it's Acrobat.com. It provides document writing, desktop sharing, PDF creation, and a neat online PDF reader. All of this was made possible by employing the formerly Macromedia's Flash technology. I was initially excited about the online Acrobat reader since the Linux reader is quite slow, and the other online solutions, such as Scribd are less than impressive. However, the Flash plug-in for Linux isn't very impressive either. Well, in any case, Adobe seems to have gotten the right idea, by starting work on an open-source Flash and certifying PDF as an ISO standard.

Phishing Terms of Agreement?

I’ve been recieving spam via Live Messenger and have mostly ignored them to-date. Feeling adventurous today, I decided to click and view one of these sites and noticed that they had a Terms of Use agreement. It’s actually quite a humourous read if you’re interested, so take a look below.

Read the rest of this entry »

The United States' Department of Homeland Security now has the power to detain a traveler's laptop indefinitely at the border, without any cause for suspicion. This is frightening, especially since all of my work and personal life is stored inside this machine. Not to mention that I use Linux, which might set off a cyber-terrorist alert, since it is the OS of hackers... apparently.

I was looking for traffic conditions prior to my drive to Toronto and found that the Ministry of Transportation uses Google Maps to display the location and images from the highway traffic cameras around Toronto. Very neat!

In anticipation for the Dark Knight, here is a clip of the dynamic duo from the original Batman starring Adam West and Burt Ward. A batcopter, a batladder, four cans of ocean repellent batspray... "Holy Sardines!" Source

Distributed Source Control using Mercurial

I’ve recently started to experiment with distributed source control systems for my personal repository. I had been using Subversion previously, but it had several issues with directories that bothered me. In addition, since my primary computer was a laptop, I also wanted to have full commit and change tracking when I was offline.

So distributed source control systems seemed to fit the bill. I looked at two systems in particular, Mercurial and git. Mercurial caught my eye because of its simplicity, and similarity with the traditional, centralized SCMs such as CVS and Subversion. However, I actually started using git first. The reason was that many open source projects had switched to git and I needed to compile several bleeding edge packages. So, I had no choice but to learn to use git. However, I couldn’t really wrap my head around it. While git is no doubt, a very powerful SCM, it was also a very complicated SCM. I took me a good hour or so before I understood how to track branches.

So, I settled for Mercurial. While I was worried that Mercurial was too immature, the fact that the Mozilla projects are also using Mercurial was very comforting.

Read the rest of this entry »

So the iPhone aka "something big" according to Roger's has been released, and one of its greatest strengths is it's extensible application platform. The iPhone SDK is available for free... but in order to have your application run on an actual iPhone, it will cost a developer $99 and an Intel powered Mac. Hmm.. great idea there, Apple. Charge the very people who might write applications promote the sales of the iPhone.

A visual comparison between using the PHP rand() pseudo-random generator and the numbers generated by random.org, a truly random generator.

We may have a celebrity moving into Waterloo... Stephen Hawking!

Older Page 1 of 3