guillec’s blog

Immersion

Posted in Internet, Media, Technology by guillec on December 9, 2008

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?

Tagged with: ,

Groovy + Ant = GANT

Posted in Gant, Groovy, Technology, Tutorial by guillec on December 3, 2008

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.

Tagged with: , , , ,

Programming Groovy

Posted in Book Reviews, Groovy, Technology by guillec on November 30, 2008

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!’

Who needs a Crackberry when we got AwayFind?!

Posted in Internet, Technology by guillec on November 21, 2008

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.

Satches for Kids (Week One)

Posted in Internet by guillec on November 19, 2008

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!

Mustaches for Kids and Donors Choose

Posted in Internet by guillec on November 13, 2008

clean

Take a good look at this picture, next time you see a picture of me I will have a new addition. That is correct I am growing a mustache!! I have joined the Mustaches For Kids army!

You ask yourself, “What is Mustaches for Kids?” and I will tell you. Basically I grow a sweet stache, people come up to me ask me why am I growing a mustache, and then I explain to them that I am doing it for the kids. I will let them think about it for a second, then I will clarify… The stache is pretty much just a conversation starter, my real intention is to get people to donate money for kids and schools.

This year I am part of the Mustaches 4 Kids in Baltimore and we will be supporting the Donors Choose organization. Each of the growers has a “Giving Page” on the Donors Choose site where donors can go and choose (ha! clever name) a project to support, there is no limit and there are plenty of projects to choose from. So please take a look at my Giving Page and donate whatever you can. Also if you have a project you want me to support let me know.

Installing Groovy on Ubuntu

Posted in Groovy, Technology by guillec on November 11, 2008

This is how I installed Groovy on Ubuntu. (Notice I run everything as sudo on my laptop)

The first step in this process is to get all the necessary files.

  1. If you dont have a Java JDK you will need to download one (I am using JDK 6).
  2. Download Groovy .zip file.

The second step is to install the files

  1. For java just place the JDK in the directory that you want, navigate to the directory you dumped the file and then run sh jdk-6u10-linux-i586.bin (Remember I am using Java 6 so the name of the file might be different for you.)
  2. For groovy, again place the downloaded file in the directory that you want. unzip the file by typing unzip groovy-binary-1.5.7.zip. (Again name of the file might change depending on the version that you downloaded.)

The third and final step in this process is to modify the PATH environment variable and add the JAVA_HOME and GROOVY_HOME to the environment variables.

  1. Edit the environment file by typing gedit /etc/environment
  2. Add and modify as necessary the following lines to the /etc/environment file.
  3. Modify the Path variable by adding the Groovy bin directory:

    PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
    /usr/<locationOfGroovy>/<groovyVersion>/bin”

    Add the following variables:

    GROOVY_HOME=”/usr/<locationOfGroovy>/<groovyVersion>/”
    JAVA_HOME=”/usr/<locationOfJava>/<jdkVersion>

This is what my /etc/environemnt file looks like:

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/tools/groovy-1.5.7/bin”
LANG=”en_US.UTF-8″
GROOVY_HOME=”/usr/tools/groovy-1.5.7/”
JAVA_HOME=”/usr/tools/jdk1.6.0_10″

Once you are done, save the file, log out and log back in, change to sudo (remember I run everything as sudo) and now groovy should work. And if it doesn’t YOU messed up, because my instructions are never wrong (kidding).

You can test by typing groovyConsole in the terminal. A console should come up where you can start writting groovy code. But you should know this console is NOT and IDE, this is just a place to type and test code if needed.

Tagged with: ,

No FLuff Just Stuff take 3 GROOOOVY

Posted in Technology by guillec on November 10, 2008

Yay! for day 3 of the No Fluff Just Stuff software symposium.

Let me start by saying that I should have attended other sessions not related to Groovy and Grails but I just couldn’t get away. This time Jeff Brown was the speaker. As a little background Jeff works at G2One, this is only the company behind the magic that is Groovy and Grails. So once I heard this I knew I couldn’t pass up on these talks and let me say Jeff delivered.

The first session was a thorough look into Groovy. Lots of code examples and comparisons between Java and Groovy. Very nice! The second session was a lecture on the benefits of Groovy when unit testing (yes developers we are supposed to do unit testing, maybe I will start trying this one day). This was actually a interesting point in my fascination with Groovy.

Jeff mentioned that when comparing dynamic languages with static languages it is extremely important that we conduct unit testing. This makes sense, when coding in static languages such as Java, we have the compiler who can tell us if we have code, notice I am not saying good code. With dynamic languages such as Groovy we don’t have the compiler to tell us if a method is not found or a class is not found… So basically we HAVE to write test cases!!! What?!! This is horrible!!! not really. This, is actually one of those negative positive thing, like when people try to impress a interviewer when they say that one of their weaknesses is that they work tooo hard.

Third session was more interesting meta programming with Groovy, I promise one day I will understand it all. Finally I got another demo of Grails.

Over all this was a magnificent symposium and I recommend that everyone tries to attend! I am looking forward to the next one in VA! April 24-26!!!!

No Fluff Just Stuff Part Dos

Posted in Technology by guillec on November 10, 2008

Day two of the No Fluff Just Stuff software symposium was good but not as good as day one. Again I attended the sessions by Scott Davis. The first session was about making your web site faster. Scott showed us a very cool plugin called YSlow for another plugin called Firebug. Both of these tools can be used to analyze the content of your site. YSlow will actually grade your site and give you reasons for why the site is slow. I was really impressed with the plug in and I recommend it everyone else. Much of the criteria used by this plugin can be described in the High Performace Web Sites book.

The second session was a summary for Scott Davis’s GIS for Web Developers book. It was an interesting lecture and Scott again did an amazing job at simplifying everything…now I know the basics behind sites like google maps!

I was really looking forward to my third session which was all about JVM garbage collection. The presenter for this lecture was Brian Goetz. Brian did a good job presenting about garbage collection but although some of us seemed interested I was still drolling and anxious about Groovy and Grails. He did talk about jconsole and other utilities we can use as java developers to identify memory leaks, but this just wasn’t as fun.

Finally I decided to attend a lecture titled 7 Habits of Highly Effective Developers. I dont remember anything about it, I was just tooo tired by the end of the day.

I will never write another line of Java again…(maybe)

Posted in Technology by guillec on November 8, 2008

Back from the first day of the No Fluff Just Stuff Java symposium. It was a great day and I cant wait for tomorrow.

Although there were many session to choose from I spent most of the day learning about Groovy and the Grails framework with Scott Davis. I am sold, as soon as I got back I pulled out my laptop and started coding with Groovy.

Setting up was easy just download the zip file, set the PATH environment variable and code.

So my first two sessions were on Groovy, the first session was an intro to showing how Groovy and Java can interact, you can literally copy Java code paste it into a .groovy file and it will compile. The second session got into meta programming, whatever that is…I saw some very cool things but stuff that I had never dealt with since basic Java doesn’t deal with. I am talking about, creating pointer, closers?, and something else that I don’t remember the name of. So as Scott liked to describe the two languages. Java is the cake and Groovy is the frosting on the cake. If you are a Java coder I definitely recommend you looking into Groovy. Stay posted I will be adding some tutorials soon.

Grails! The third session of the day was all about Grails. What an amazing, technology/framework/platform. I havent been able to play with Grails yet but I will soon. What is amazing to me is that I am currently developing an application that uses Spring, Hibernate, Log4j, Tomcat……. and basically it took me a couple of days to configure, so that I could then start coding. Scott, with a little help from Grails, was able to do all this and build a webapp in less than one hour and maybe typed 10 lines of code.

Groovy and Grails learn it!