Life of the IT-Drummer

A web log from Tobias Rusås Olsen.

Denver Mini live at Hulen - 2009

My friend Peder recorded another video of one of our live gigs. It’s by coincidence the same song as last time, but still .. entertaining? We were booked the same day as the concert took place, and hadn’t rehearsed for months, and our guitar player had to play bass. Still loads of fun though.

No comment
taintedsong.com taintedsong.com taintedsong.com

Combining Ruby (or Groovy/BeanShell) and Java with Spring Framework.

To combine Ruby and Java might seem like a challenge, but it’s actually quite easy using the Spring Framework. Feel free to follow along with my simple step by step instructions. I make programming FUN! These examples are collected from Spring In Action - Second Edition and uses Spring Framework 2.0.8.

1: Define a regular java interface.

public interface Lime {
void limeIsNoCrime();
}

2: Then we define a ruby class with a matching method:

class Lime
  def limeIsNoCrime
    puts "To put lime in your drink is no crime"
  end
end
Lime.new

It’s important to notice the “Lime.new” at the end, this means that we will return a new lime object from this piece of code.

3: Add all needed dependencies to your build path.

I needed these:

  • jruby.jar
  • cglib*.jar in some version.
  • commons-logging.jar
  • spring.jar

If you download the spring framework with dependencies package, you should be able to find all these in there, somewhere.

4: Put this “magic” code in your applicationContext.xml:

<lang:jruby id="lime" script-interfaces="path.to.the.right.package.Lime" script-source="classpath:path/to/the/right/package/Lime.rb" />;

The “script-interfaces” attribute should link to the interface we created in step 1, the script-source should link to the ruby source code we created in step 2.

If you want to use groovy or beanshell scripts instead, you just change lang:jruby to lang:groovy or lang:bsh.

Here’s an example of a very clean applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:lang="http://www.springframework.org/schema/lang"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd">
<lang:jruby id="lime" script-interfaces="Lime" script-source="classpath:Lime.rb" />
</beans>

This is how it would be if you don’t use packages. Which you should.

5: Now, lets test this thing. Make a regular java class like this, and run it:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		Lime lime = (Lime) ctx.getBean("lime");
		lime.limeIsNoCrime();
	}
}

Run the program and it should write “To put lime in your drink is no crime” to the console. We did it! There’s also a fairly good build in conversion of types, so if you change the return type to “List”, and return a ruby-list which will be a List in your Java-application. Nice!

2 Comments
taintedsong.com taintedsong.com taintedsong.com

Amazing video.

“By using a Google Streetview-like camera, a system with six lenses, not as a photo but as a video camera, an all-encompassing picture is captured. […]
From the point where the images were recorded, the viewer can look in any direction, let his eyes wander through the crowd, or stare at the ground or the air, which makes viewing a video an experience without boundaries.” - Yellow Bird press release

Awesome! Would be cool if someone made a music DVD with this stuff.

No comment
taintedsong.com taintedsong.com taintedsong.com

Cool trick in Eclipse IDE -> Go into.

I’ve been using Eclipse for some time now, but just recently discovered this trick by accident.

This trick concerns views like Navigator or Package Explorer. If you have lots of projects, it might be annyoing to have open projects over and under the package you’re working in. You can of course use the “close all unrelated projects”-function to close them, but that’s hard to remember, and it costs you resources to close and reopen them (but by all means, do it when you remember it!)

When you know what package you will be working on, you can simple choose that package by using the “Step into” function located right below “new” as the second alternative when you right click on a package. This is like moving into that folder, and it hides everything outside that package. Neat!

If you want to go back to “every project”, press the back-button on the top.

The “Link with editor” is also a great function. When this is “on”, and you press a tab, it will also be selected in the tree-structure. (Thanks to JosteinB for this tip)

Before:

Eclipse IDE before using the \"going into\" function

After:

Eclipse IDE after using the \"going into\" function

The link with editor-button:

Eclipse IDE - link with editor

No comment
taintedsong.com taintedsong.com taintedsong.com

Sasquatch music festival 2009 - Guy starts dance party

I have no idea how this happened, but it’s pretty darn funny. :)

The summer is here! Big thanks to tgodag for the link. And it’s his birthday today. Hurray!

No comment
taintedsong.com taintedsong.com taintedsong.com

Amazing Spring MVC Tutorial - simple.

I found this great step-by-step tutorial on Spring MVC today. It helps you build a very simple web application using Spring MVC. It takes care of all the steps required in order to have a simple web application where all the fundamentals are in place. Perfect for everyone interested in using Spring MVC.

The tutorial is fairly simple, first you are told what you are supposed to do, then you get all the code needed. For me, almost everything worked as it was explained.

Visit this page to download the spring distribution. I went for the 2.5.5 release with all dependencies.

Heres the link to the tutorial: static.springframework.org/docs/Spring-MVC-step-by-step/part1.html

1 Comment
taintedsong.com taintedsong.com taintedsong.com

iPod Shuffle Third Generation - Review

[All images are taken from Syl2m (http://www.flickr.com/photos/syl2m/), except the one with the generation-comparison - it's from digitalbear (http://www.flickr.com/photos/minami/), both on a Creative Commons license]

iPod Shuffle Third Generation

A couple of days ago my Creative Zen Stone mp3-player called it a day, and stopped working (with a high pitched noise). The Zen Stone is a competitor of Apples iPod Shuffle second generation, a small mp3-player without display. I was forced to buy a new mp3-player, and I thought I’d give Apple another go (I have owned two 20 gig 4th generation iPod (”classics”) before) with their beautiful new iPod Shuffle third generation. The big disadvantage choosing the shuffle is that you’ll have to use the accompanying headphones, because the headphones has the controls. More discussion about this feature later. I needed headphones as well, so for me, it felt like a good choice.

Read the rest of “iPod Shuffle Third Generation - Review” »

10 Comments
taintedsong.com taintedsong.com taintedsong.com

Spring Tutorial,Java Spring Tutorials,Spring 2.5 Beginners Tutorial

Truben linked to a great page for Spring. Check it out!

http://truben.no/journal/spring-tutorialjava-spring-tutorialsspring-25-beginners-tutorial/

No comment
taintedsong.com taintedsong.com taintedsong.com

Simple learning script

It’s exam time for me, and both Peder, Jostein and myself must learn things. Therefore me and Peder decided to make programs to help us learn things. He wrote his program in Java and I choose Python as my language.

The program is fairly simple. You select a text file containing lines with topics you want to learn, and then you have to type inn all of them. The program writes how many topics are left, and can also give you hints if you need it. You are finished when you have written all topics, or have given up by typing “stop”. Then it writes out how long time you used.

Press read more to .. read the code!

Read the rest of “Simple learning script” »

No comment
taintedsong.com taintedsong.com taintedsong.com

Video of Denver Mini live at Garage.

truben recorded a video of the Denver Mini (whom I play for) song “A Couple is Not a Pair” (The title is not yet confirmed) played live at Garage in Bergen. I’m behind the drum kit:

We warmed up for “My Little Pony”, a great band from Oslo. :-) Pictures from the event will most likely be posted or linked to from here in near future.

No comment
taintedsong.com taintedsong.com taintedsong.com