04 Apr

Sequence Streams for Java 8

Since Java 8 was introduced last week, I started playing around with the new features it provides, e.g. lambda expressions, streams, …

After taking a closer look at the streaming API, I noticed that there was no out-of-the-box support for generating number sequences. Thus, I created this little project on GitHub: https://github.com/jakobk/sequence-streams.

Using the class Sequence, you can improve classic for-loops by making use of the new streaming API of Java 8. Consider the following example:

List<Person> persons = new ArrayList<Person>(100);
for (int i = 0; i < 100; i++) {
    persons.add(new Person(i));
}
// use persons ...

The same can be accomplished using Sequence in combination with the new streaming API:

List<Person> persons = Sequence.stream(0, 100)
    .mapToObj(Person::new).collect(Collectors.toList());
// use persons ...

The class Sequence provides various methods for generating all kinds of integer sequence streams, e.g. sequential or parallel streams, using different step sizes, counting up or counting down, etc.

After some further research, I found out that Tomasz Nurkiewicz created something similar to my Sequence class, however, much more powerful. His project LazySeq is also hosted on GitHub: https://github.com/nurkiewicz/LazySeq. Using LazySeq you can easily create various number sequences, including infinite ones. This is very similar to what already exists in clojure: lazy-seq.

10 Mrz

Google Software Engineering Internship in Kirkland, Seattle, WA

I am thrilled to announce that I will be joining Google this summer for a Software Engineering internship in Google’s Kirkland office in Seattle, WA. At Google, I will be part of the DevTools team, working on various development tools for all kinds of Google products.

My internship will start in July, and will end in October 2014. I am unbelievably happy and excited about my internship, and I am really looking forward to facing new challenges this summer at Google.

10 Mrz

Generate DDL script of JPA persistence unit in Maven using hbm2ddl

Recently, I was facing the task of generating the DDL script of a JPA domain model in a Maven build. Of course, there is Hibernate’s hbm2ddl to actually perform the DDL generation, however, I did not know any Maven plugin capable of invoking hbm2ddl. After some research, I found out that this is achievable via an Ant task (i.e. use the Ant plugin for Maven), or via the hibernate3-maven-plugin. I decided to go with the hibernate3-maven-plugin, although all it does is to create a respective Ant task and invoke Ant on this task. Here is my Maven configuration for generating the DDL of my persistence unit during the Maven build:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>3.0</version>
    <executions>
        <execution>
            <id>generate-ddl</id>
            <goals>
                <goal>hbm2ddl</goal>
            </goals>
            <phase>process-classes</phase>
        </execution>
    </executions>
    <configuration>
        <hibernatetool>
            <jpaconfiguration persistenceunit="my-persistence-unit"/>
            <classpath>
                <path location="${project.build.directory}/classes" />
            </classpath>
            <hbm2ddl
                    export="false"
                    update="false"
                    drop="false"
                    create="true"
                    outputfilename="my-persistence-unit.ddl"
                    delimiter=";"
                    format="true"
                    haltonerror="true" />
        </hibernatetool>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
    </dependencies>
</plugin>

This configuration invokes hbm2ddl with the correct classpath and parameters during Maven’s process-classes phase, and creates the file target/sql/hibernate3/my-persistence-unit.ddl containing all DDL scripts of the configured JPA persistence unit.

24 Mai

TinyOS syntax highlighting in BBedit

If you are working with TextWrangler (or BBedit) on TinyOS files (*.nc), you can use the following file to get correct syntax highlighting: TinyOS.plist

To install it for TextWrangler, copy the .plist file to the following directory:

Username/Library/Application Support/TextWrangler/Language Modules

Then restart TextWrangler and you should have a language module called “TinyOS”, which will be automatically applied to *.nc files.

23 Mai

Pong on ATmega1280 dev board

This video shows my implementation of Pong on an ATmega1280 dev board (AVR 51 microcontroller). The game uses the accelerometer of the respective Wii mote to calculate the racket position of player 1 or 2. To communicate with the Wii motes, it uses a bluetooth module. Furthermore a bundled MP3 and SD-card module is used to play sounds from unreal tournament (stored on the SD-card), each time a player scores a point.

This game was an exercise of the microcontroller course at TU Vienna in 2012S.

17 Mai

“CDI für Rich Clients” in Eclipse Magazin

I am very happy to announce that the current issue (4.2012) of the german Eclipse Magazin (http://eclipse-magazin.de) includes my article “CDI für Richt Clients”, which is about the integration of Apache OpenWebBeans into Eclipse RCP.

After publishing my blog entry Apache OpenWebBeans meets Eclipse RCP, I was contacted by Claudia Fröhling asking if I wanted to write about this topic for the Eclipse Magazin. I was very glad to get this offer and, of course, agreed to write the article. Authoring such an article was a quite new experience for me, and I really enjoyed it. Hopefully it will not be the last one.

You can obtain a copy of the current Eclipse Magazin here or you can download the iPad app of the magazine.

10 Mai

Web security workshop @ confess 2012

Yesterday was the workshop day of CONFESS 2012. My workshop was called “How to exploit and fix typical web application vulnerabilities” and that was what we did. I provided two JSF web applications, some PHP scripts and some C files, which all were vulnerable. At the workshop, we tried to break them in as many different ways, as possible.

At the beginning we did a lot of SQL injection exploits, at first manually and later using sqlmap. Then we looked into XSS, XSRF and poor session management. And last but not least we took a look at buffer overflows, using metasploit as shellcode generator. Unfortunately, we did not have time to check out the jsf-security web application, which would have shown some vulnerabilities of (old versions of) JSF 2.

The workshop HOW-TO and all the source files used at the workshop are available at github: https://github.com/jakobk/confess-2012

07 Mai

Web security session @ confess 2012

Today I spoke at the conference for enterprise software solutions (CONFESS) in Leogang, Austria. My session was called “Introduction to web security” and it explained attacks like SQL injection, XSS, XSRF or buffer overflows. It was quite well-attended and I got lots of positive feedback, which I was really happy about.

As promised at the session, here are the slides as PDF: Web_Security_jakobk.pdf

I really enjoyed speaking at CONFESS, and now I am looking forward to my workshop (again about web security) on Wednesday.

Edit 2012-05-15: The slides are now also available on slideshare:

09 Mrz

Apache OpenWebBeans meets Eclipse RCP

Last year I had to do a project at university using Eclipse RCP. Frankly, the Eclipse framework kinda sucked. Thus I tried to pimp Eclipse RCP a little bit, which means I wanted to use OWB and CODI.

After some time I figured out how to combine OWB and Eclipse RCP thanks to the excellent plugin system of OWB. Now I finally found some time to put the relevant classes online. You can find the project at apache-extras: http://code.google.com/a/apache-extras.org/p/openwebbeans-eclipse-rcp/

Please note: Although this is a maven project, I was not able to really build it with maven, b/c I couldn’t find a way to get all the relevant eclipse jars into a maven repo. If you want to use it, the best way is to copy the source files directly into your Eclipse RCP project.

If anyone is interested in getting this stuff running in his/her Eclipse RCP project, just ping me and I can help you with the pitfalls.