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. ★
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. ★
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.
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.
Published on
January 20, 2010 in
Linux.
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
-----
network={
ssid="$_ESSID"
scan_ssid="$_SCAN"
proto=WPA
key_mgmt=WPA-EAP
pairwise=TKIP
group=TKIP
eap=TTLS
ca_cert="$_CA_CERT"
identity="$_IDENTITY"
password="$_PASSWORD"
phase2="auth=PAP"
}
Add eap-ttls to /etc/wicd/encryption/templates/active, restart the GUI and the settings should now appear in the dropdown menu.
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.
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. ★
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. ★
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.
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". ★
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.
I think some of you can relate. I know I can, but which character? Maybe all three!
