Archive for the ‘groovy’ Category

Podcasts for Developers

April 29th, 2011

Until I started to travel on a regular basis I haven’t been aware of the value and information that can be found audio podcasts for developers. I thought, “Come on, what can you learn from listening to a radio?”.

Nevertheless, since I had to fulfill my time with something other than staring at empty space (I travel by night) I tried listening to some podcasts and since then I haven’t stopped to follow the ones that I liked the most.

In my opinion (being a Java developer most of the time), Java posse is the best podcast around. The guys behind it are very amusing, have different characters (opinions), and often make a roundups on hot topics where they include more people in discussions. For example, episode #337 they made together with guys from .net rocks which is I guess the best podcast for .net developers.

Apart from Java posse I like listening to grails podcast although they are not as regular with new stuff as Java posse is.

In near future I plan to check some python or ruby podcasts and compare their awesomeness to Java posse.

Try listening to any podcast for developers and you won’t regret. The feeling you’ll probably have is like you have found yourself a good developer friend who is willing to share his personal insights and programming knowledge with you. At least that is how it was in my case.


General, Java, fun, groovy, ruby , , , , ,

Griffon eclipse support plugin

December 3rd, 2010

Recently I was playing  with griffon which I used together with jung library to visualize binary decision diagrams. In this regard, I had to make several small projects. Since I do that in my spare time, at the moment I start a new project I forgot how I managed to integrate previous griffon project with eclipse IDE (actually I am using Spring Tool Suite with Groovy and Grails support but I guess it’s the same as with eclipse) so that IDE doesn’t pop up nasty message similar to:

The project was not built since its build path is incomplete.
Cannot find the class file for groovy.lang.GroovyObject.
Fix the build path then try building this project.
The type groovy.lang.GroovyObject cannot be resolved.
It is indirectly referenced from required .class files 
Config.groovy    /myprojectname/griffon-app/conf    line 1

I used: griffon integrate-with -eclipse command which actually allowed me to import griffon project to eclipse but that wasn’t enough.

The solution was eclipse support plugin.

Having that written down I hope I won’t forget it again. :)


Java, groovy , , ,

Groovy blob and mysql

September 20th, 2009

In certain occasions e.g. when you want to save scrapped html page or just a specific part of it (e.g. div with its contents) the recommendation I found is to use the blob type and save xml document as binary stream.

In groovy, this is achieved in a rather simple way:

class Document {
  int id
  String title
  String xmlContent
Sql sql = Sql.newInstance(
          "user", "pass", "com.mysql.jdbc.Driver")
// We assume db table similar to:
      `id` bigint(32) NOT NULL AUTO_INCREMENT,
      `title` varchar(500) NOT NULL,
      `xmlContent` blob,
      PRIMARY KEY (`id`)
def saveDocuments(def docs) {
  println "Saving documents to database..."
  def documents = sql.dataSet("document")
  docs.each {Document doc ->
    documents.add(title: doc.title, xmlContent: doc.xmlContent)

When you want to retrieve data, with Groovy this is not much complicated either:

def loadDocuments() {
  def list = []
  sql.eachRow("SELECT * FROM document") {
    Document doc = new Document(it.toRowResult())
    if (it['xmlContent'] != null) {
      doc.xmlContent = new String(it['xmlContent'])
  println "Loaded ${list.size()} documents from database"

I tried the code with mysql database but I assume that you can achieve the same with any other database.

One hint for mysql blobs and utf-8: although utf-8 charset behaves very well with other database table fields (if you add useUnicode=true and characterEncoding=UTF-8 parameters to your connection string), in order to work with utf-8  blob fields you should adjust one more parameter: useBlobToStoreUTF8OutsideBMP=true. With this parameter set, your utf8 encoded xml documents will behave well with mysql database.


Java, groovy , , ,

Groovy meliorates and dries

June 12th, 2009

Dynamic languages are very popular at this time and you probably had insight into at least one of them (Ruby, Python, Groovy).

If you are bound to Java platform the best way to “be dynamic” IMHO is to work with Groovy.

Apart from the where you can find documentation, getting started examples etc. there are many blogs around that blog about groovy.

My favorite (although very slow) is Andres Almiray’s blog. He mostly blogs about griffon and groovy and has nice tutorials and examples. There I found info about many open source libraries I never heard of but which are quite useful, for example: FEST, Glazed list, Swing clarity, etc.

Try Groovy cause it’s groovy :)

I felt like when I run my first program at elementary school and it wrote “Ninja” on the screen :)


Java, groovy ,