How to create a basic Spring MVC web

How to createa Spring MVC web application using maven. We will start from scratch creating the project with maven, then we will add some depencencies and create the java code. Finally we will build the .war file.

Continue reading

Advertisements

How to compile the linux kernel

Download a kernel source from kernel.org and let’s suppose that it is extracted in the directory ~/linux-x.yy.zz

Sometimes it can be a good idea to start with a current kernel configuration. You can get this configuration from the text file /boot/config-xx.yy.zz or a compressed version from /proc/config.gz. Copy the text file into ~/linux-x.yy.zz/.config.

Now you can start configuring the new kernel by executing inside the dir ~/linux-x.yy.zz/:

make menuconfig

Then compile the kernel, the modules and the image:

make
make bzImage

If everything it’s ok the new kernel will be in ~/linux-x.yy.zz/arch/x86/boot/bzImage. Copy this file to the boot directory in the desired machine:

cp ~/linux-x.yy.zz/arch/x86/boot/bzImage /boot/vmlinuz-x.yy.z

Now you have to compile and install the modules:

make modules 
make modules_install

This will copy all the firmware and modules to /lib/firmware and /lib/modules/x.yy.z. If you want to change the directory you can do it by defining the INSTALL_MOD_PATH environment variable.

After install all the modules you have to go to /boot directory, create the initramfs and update the grub.

update-initramfs -c -k x.yy.zz
update-grub

How to create virtualbox by commandline

First create the virtual machine called myVirtualHost and register it:

VBoxManage createvm --name myVirtualHost --register

Then create a hard disk of 10Gbytes:

VBoxManage createhd --filename myhdd1.vdi -size 10240

This will create the file ~/.VirtualBox/HardDisks/myhdd1.vdi

Add an ide controller and the hard disk:

VBoxManage storagectl myVirtualHost --name "IDE Controller" --add ide
VBoxManage modifyvm myVirtualHost --hda .VirtualBox/HardDisks/myhdd1.vdi

You can add more disks with these commands:

VBoxManage modifyvm myVirtualHost --hdb .VirtualBox/HardDisks/myhdd2.vdi
VBoxManage storageattach myVirtualHost --storagectl "IDE Controller" --device 1 --port 0 --type hdd --medium .VirtualBox/HardDisks/myhdd3.vdi 

Now I will give this machine 512Mbytes of RAM:

VBoxManage modifyvm myVirtualHost --memory 512 --acpi on

You have different network options. If you want to give your virtual machine its own IP addpress you have to use the bridged mode:

VBoxManage modifyvm myVirtualHost --nic1 bridged

If you want to use the same IP address than your host machine you can use NAT. In this case you can configure NAT port forwarding to access to some services, for example with these lines you can access the SSH service of our virtual machine by connecting to the port 2222 from your host.

VBoxManage modifyvm myVirtualHost --nic1 nat
VBoxManage modifyvm myVirtualHost --natpf1 "guestssh,tcp,,2222,,22"

To launch the virtual machine and leave it in background you can use one of the following lines:

nohup VBoxHeadless -s myVirtualHost --vnc --vncpass mys3cr3t &
nohup VBoxHeadless -s myVirtualHost --vrde off &

The first one will enable VNC and also terminal server.
The second one will disable both, VNC and terminal server.

R packages

Part of this post is extracted from R-admin and R manual.

A package is loaded from a library by the function library(). Thus a library is a directory containing installed packages; the main library is R_HOME/library, but others can be used, for example by setting the environment variable R_LIBS or using the R function .libPaths():

> .libPaths()
[1] "/home/jose/R/x86_64-redhat-linux-gnu-library/3.1"
[2] "/usr/lib64/R/library"                            
[3] "/usr/share/R/library"

The set of packages loaded on startup is by default:

> getOption("defaultPackages")
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods" 

To install a new package write:

> install.packages("PackageName", repos = "http://repository_url", dependencies = TRUE)

install.packages can install a source package from a local .tar.gz file by setting argument repos to NULL: this will be selected automatically if the name given is a single .tar.gz file.

install.packages can look in several repositories, specified as a character vector by the argument repos: these can include a CRAN mirror, Bioconductor, Omegahat, R-forge, rforge.net, local archives, local files, …). Function setRepositories() can select amongst those repositories that the R installation is aware of.
The available packates ready to install are shown by calling available.packages().

The command installed.packages finds details of all packages installed. The return value is a matrix with one row per package, row names the package names and column names (currently) “Package”, “LibPath”, “Version”, “Priority”, “Depends”, “Imports”, “LinkingTo”, “Suggests”, “Enhances”, “OS_type”, “License” and “Built”. To see only the name of the installed packages write:

> rownames(installed.packages())

To remove an installed package use the command remove.packages:

> remove.packages("MBCluster.Seq")

To load a package use the command library:

> library("MBCluster.Seq")

The attached packages and extra info can be asked by sessionInfo() command.

source causes R to accept its input from the named file or URL or connection. Input is read and ‘parse’d from that file until the end of the file is reached, then the parsed expressions are evaluated sequentially in the chosen environment.