Immersion

December 9th, 2008 by Guille Carlos 2 comments »

[youtube=http://www.youtube.com/watch?v=3gu0iu0xwls]

This an amazing video by photographer Robbie Cooper. It shows just how focused (or strange/creepy) young people can be while playing video games. Check out their game faces! Do you have a game face?

  • Share/Bookmark

Groovy + Ant = GANT

December 3rd, 2008 by Guille Carlos No comments »

gantVenkat Subramaniam has a theory about XML. He says:

Like humans, XML starts out cute when it’s small and gets annoying when it becomes larger.

If you have the same sentiment as Venkat, you will appreciate Gant. Gant is a powerful tool for scripting Ant task by writing Groovy code instead of XML. Below you will find samples from a Gant script and a explanation on what the code does. I wont go through the entire script but you can get it here.

Notice: The script calls a property file that you will need to create. The property file specifies locations for different directories. If you downloaded the script and you want to run it, make sure you change the file name to build.gant. To run the script, navigate to the location of the file and type gant.

In a nutshell, you write a Gant script by:

1. Declaring a target:

target ( ‘nameOfTarget’ : ‘ Description of Target ‘ ) {

}

2. Adding tasks inside the target:

targer ( ’sampleTarget’ : ‘This is a sample target’) {

ant.doSomething(more code)

ant.doSomething(more code)

}

Lets start examining and explaining the script:

First two lines of the script:

Ant.property(file: ‘build.properties’)
def antProperty = Ant.project.properties

These are the first two lines of the script and they are simply saying, “Hey! I have a file called build.properties that I will be using during this process and I will refer to it with the word antProperty. So whenever you see the word antProperty, I want you to look inside the build.properties file for the value”. This is the file that you will need to create in order to build your project.

First target definition in the script:

target( ‘build’ : ‘This target build the project’) {
ant.echo(’Hello I am starting the build process now please be patient’)
depends(resources)
depends(webcontent)
depends(compile)
depends(war)
}

This is the first target of many for the script. This section of code simply creates a target called build. The first task in this target is to print out a line. This is done with the echo command, ant.echo. Just like Ant, it simply prints out the statement declared inside the quotes. Finally we are saying, “Hey! This target depends on the completion of other targets called resources, webcontent, compile and war!”

First path definition in the script:

target( ‘resources’ : ‘Grabs resources such as the property files’) {
ant.echo(”I am grabbing all the resources”)
ant.mkdir(dir: antProperty.’dumpPropertiesHere’)
ant.copy(todir: antProperty.’dumpPropertiesHere’) {
path(refid: ‘properties’)
}
}
def properties = ant.path(id: ‘properties’) {
fileset(dir: antProperty.’getPropertiesFiles’) {
include(name: ‘*.properties’)
}
}

This piece of code has another target and a extra path definition. The resources target is going to copy some files into a specified location. Again, the first line simply prints the string inside the quotes.

The second line is simply creating a directory with the ant.mkdir task. The name for the directory is specified by calling the properties file.

The third line is going to copy files into the directory we created with the ant.mkdir task. The ant.copy(todir: antProperty.’dumpPropertiesHere’) is saying, “Yoooo machine, dump some stuff in here! You can find the files I need in a place called properties

Finally we define where this properties location is. We accomplish this by using the ant.path task. In the first line we give it an id. The fileset task is simply saying “The files that I want are in here and please include all files ending in .propeties“.

These tasks that I just described above cover about 70% of the code that you will find in my script. The following tasks will describe other important actions you will need to build your project.

Compiling your code:

ant.javac(srcdir: antProperty.’getSrc’, destdir: antProperty.’setClassesHere’) {
classpath() {
path(refid: ‘buildCP’)
}
}
}

The task ant.javac is the command you use to compile your Java code. In this task you are passing two parameters, the first parameter tells the system where to find the source code you want to compile, while the second parameter tells the application where to set the classes after they are compiled.

The classpath() task is basically just telling the system where you find the classes it will need in order to compile your code.

Creating a war file:

target ( ‘war’ : ‘Creates the .war’) {
ant.echo(’Starting a war!’)
ant.jar(destfile: antProperty.’gant.war.file’, basedir: antProperty.’buildWarWith’, includes: ‘**’)
}

Here we call the ant.jar task in order to create the war file. The first parameter is the name of the .war file. The second parameter points the system to the location where it will find all the files that it needs. Finally, we tell the system to include all the files in that base directory.

setDefaultTarget(build)

Finally setDefaultTarget tells the system which target to start with.

As you probably noticed, one of the advantages of using Gant over basic Ant is the expressiveness you can achieve by using Groovy instead of XML. I originaly wrote this Gant script to begin my training in Groovy syntax, after a couple of minutes I found myself mostly copying and pasting the code since I had so many targets. So even thougth I think this is a good way of learning the basics of Groovy syntax the biggest benefit was being able to use this script on other projects and not having to look at XML. Please let me know know if you have any questions or comments about the script, or if you have any feedback on how I could make it better.

  • Share/Bookmark

Programming Groovy

November 30th, 2008 by Guille Carlos No comments »

proggroovyJust finished reading Programming Groovy by Venkat Subramaniam.

This is a great book for anyone interested in learning about Groovy. As a beginner Groovy programmer, this book helped me understand all the benefits of using Groovy over plain old Java. Venkat also does an amazing job of explaining the metaprogramming features of Groovy in a way that is both fun and easy to comprehend.

If you are interested in Groovy, I recommend you get a copy of this book. I know I will keep referring to it as I get more experience with Groovy.

println ‘Thanks Venkat!’

  • Share/Bookmark

Who needs a Crackberry when we got AwayFind?!

November 21st, 2008 by Guille Carlos No comments »

AwayFindOne common argument in favor of a blackberry (or iphone) is that it calms your nerves about checking email since you can access it anywhere. On the other hand, this is also the problem with these devices. Well here is the cool solution, AwayFind.

I first learned about it from Zvi Band’s post and I think its a great idea! AwayFind, in a nutshell, relieves you from constantly checking your email by giving email senders the option of contacting you immediately, only if needed. Now, you dont have to worry about missing that all important email and you dont have to check for it every 5 minutes!

Now don’t get me wrong, I am still getting that blackberry (or iphone, still debating), but this is something I could use, regardles of what I have.

Check out my AwayFind link, remember to use it only if you have to.

  • Share/Bookmark

Satches for Kids (Week One)

November 19th, 2008 by Guille Carlos No comments »

oneweek1 So it has been a week and as you can see my stache is rocking!! I am actually surprised, I didn’t think I could grow this much! Anyways now to the frustrating news, my donations are still at a big fat $0.00. Are you feeling bad yet? Good go here donate something!

Check out how the others growers are doing!

  • Share/Bookmark