środa, 25 lipca 2012

Ohloh code

When I heard that Google Code Search is going to be closed i started to look for it's alternative. I used it on a routine basis - looking for spring solutions, gwt tricks or some xml hibernate configurations.

The best alternative was koders.com, but it was lacking some features - for example searching in xml language(!).

Now, the Koders project is merging with Ohloh in the form of code.ohloh.net. The Ohloh code is great. I can look for gwt examples, spring xml configuration files or hibernate tricks. The left panel is perfect. The code preview is optimal for me. A look of the tool is clean and nice.

poniedziałek, 23 lipca 2012

Installing latest R version under Ubuntu

Ubuntu does not come with the recent R version. Below is the solution. Mind that you can choose different cran mirror. I use wroclaw/poland cran mirror to do this. My Ubuntu version is 11.10 -> oneiric. Keep in mind that. For 12.04 you should use -> precise
sudo apt-get install python-software-properties
sudo add-apt-repository "http://r.meteo.uni.wroc.pl/bin/linux/ubuntu oneiric/"
sudo apt-get update
You will get: W: GPG error: http://r.meteo.uni.wroc.pl oneiric/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9
sudo apt-get install r-base-dev 
And we are done.

wtorek, 17 lipca 2012

Spring examples #1 - beginning with spring


I decided to prepare for Spring certification. Therefore, in the series of 'Spring examples' posts I will introduce and clean up the most important Spring concepts.

The source code for this post is available at:
git clone git@bitbucket.org:marpiech/iseqspringcore.git

Prerequisities:
- eclipse: download 'Eclipse IDE for Java EE Developers' from http://www.eclipse.org/downloads/
- maven: download it from http://maven.apache.org/download.html or by sudo apt-get install maven2 
- m2eclipse: in eclipse Help -> Marketplace -> Maven integration for Eclipse -> install
- SpringSource Tool Suite: in eclipse Help -> Marketplace -> STS -> install

First, we have to create directory structure. bash
mkdir iseqspringcore
cd iseqspringcore
mkdir -p src/{test,main}/{java,resources}
Next, we need to set up maven.
nano pom.xml
and paste:


 4.0.0

 com.intelliseq
 spring-tutorial
 1.0

 Spring Tutorial Part 1
Now, we have to prepare eclipse project. bash
mvn install
mvn eclipse:eclipse

Let's switch to eclipse.
File -> Import -> General -> Existing Projects into workspace
RightClick on Project -> Configure -> Convert to maven project

Add maven repository to pom.xml

 
       central
       Maven Repository Switchboard
       default
       http://repo1.maven.org/maven2
       
         false
       
   

RightClick on Project -> Maven -> Add Dependency -> org.springframework, spring-context
Have a look at pom.xml and in project at Maven Dependencies set of libraries.

In src/main/java create package com.intelliseq.springexamples.core Create application-context.xml in the com.intelliseq.springexamples package. There are two two types of bean instantiation through setters: classic one and modern one (see below).


 
  
  
 

 

 
  
 
Let's create Person class in the com.intelliseq.springexamples.core package.
package com.intelliseq.springexamples.core;

public class Person {
 
 private String firstName;
 private String familyName;
 
 public void setFirstName(String firstName) {
  this.firstName = firstName;
 }

 public void setFamilyName(String familyName) {
  this.familyName = familyName;
 }

 @Override
 public String toString() {
  return firstName + " " + familyName;
 }
}
And finally let's create application runner class SpringApp in the com.intelliseq.springexamples.core package. The SpringApp class uses application-context through ClassPathXmlApplicationContext class.
package com.intelliseq.springexamples.core;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringApp {

 public static void main (String[] args) {
  ApplicationContext context =
       new ClassPathXmlApplicationContext(new String[] {"com/intelliseq/springexamples/application-context.xml"});
  Person person = (Person) context.getBean("person");
  System.out.println(person);
  Person modernPerson = (Person) context.getBean("person-modern");
  System.out.println(modernPerson);
 }
 
}
Run Spring App and voila.