Simple object in R Project

Let’s create an “Account” class using R language RC object with two methods: displayBalance and add.

Account <- setRefClass("Account",
  fields = list(name = "character", total = "numeric"),
  methods = list(
    displayBalance = function() {
      paste0("The account of", name, "is ", total, "$")
    add = function(x) {
      total <<- total + x

Create an RC object, access it variable and call it methodes

myAccount <- Account$new(name="Martin Magakian", total=100)
balance <- myAccount$displayBalance()

will print on the screen:
The account of Martin Magakian is 200$

Simple S4 object with method in R Project

There is a better way to create a class in R using the RC method. Only if your object don’t interact with older (S3) object.

In this simple example I’m going to create an class “Person”, then create a methode “sayMyName” Continue reading

Docker install on Debian 7 Wheezy

Docker requirement for Debian

Docker is using the LXC – Linux Containers heavily.
Due to the lack of LXC on Debian 7 a newer Linux kernel is required.

I don’t advice installing a backported kernel on production. But I didn’t notice any bug on my personal Debian

This tutorial was made from Debian 7.4 and installed Docker 0.8
Continue reading

EMR command line for Linux and Mac OS X

Amazon Elastic MapReduce make running Hadoop clusters seamlessly.
As most AWS product it can be used in command line making it scriptable and flexible.
Continue reading

Installing Hadoop on Ubuntu

Hadoop is developed in Java and aim to run mainly on Linux.
In this tutorial I will demonstrate how to install and run Hadoop on Ubuntu 12.04. The setup will run Hadoop in a single node cluster.
Continue reading

Loading Java jars programmatically

How to import a Java Jar at runtime:

URLClassLoader child = new URLClassLoader (myJar.toURL(), this.getClass().getClassLoader());
Class classToLoad = Class.forName ("com.MyClassName", true, child);
Method method = classToLoad.getDeclaredMethod ("myMethodName");
Object instance = classToLoad.newInstance ();
Object result = method.invoke (instance);

Runnable Java Jar by hand

Ho dear, why would you want to do this boring task by hand?
Probably only for learning or scripting the process.

Continue reading

Runnable Jar using Maven with dependancy

Maven is a great tool when it come to repetitive task. Exporting a runnable jar with maven can be done thanks to the maven-assembly-plugin
Continue reading

Create runnable jar with Eclipse

Eclipse make the process of creating an executable file very easy.
Continue reading

What is a runnable jar file?

Is short it just a zip file, rename into a *.jar file.
It embed all compile java class file required for it execution.
Continue reading