Wednesday, August 10, 2011

Making a progress bar for long R programs

From : http://ryouready.wordpress.com/2009/03/16/r-monitor-function-progress-with-a-progress-bar/

total <- 20
# create progress bar
pb <- txtProgressBar(min = 0, max = total, style = 3)
for(i in 1:total){
Sys.sleep(0.1)
# update progress bar
setTxtProgressBar(pb, i)
}
close(pb)

Tuesday, August 2, 2011

How to concatenate a list of data.frames to obtain a data.frame in R

From http://stackoverflow.com/questions/2851327/r-converting-a-list-of-data-frames-into-one-data-frame :

df <- do.call("rbind", listOfDataFrames)

Monday, August 1, 2011

extract maps in sp format from the maps package in R

from the doc of the package spacetime :

library(maps)
states.m = map('state', plot=FALSE, fill=TRUE)
IDs <- sapply(strsplit(states.m$names, ":"), function(x) x[1])
library(maptools)
states = map2SpatialPolygons(states.m, IDs=IDs)
class(states)
[1] "SpatialPolygons"
attr(,"package")
[1] "sp"

Monday, July 25, 2011

reading numeric data from a string variable in R

use textConnection :

strin_var = readLines(textfle)
tc=textConnection(string_var)
df = read.table(tc,colClasses="numeric")


http://www.r-bloggers.com/example-8-27-using-regular-expressions-to-read-data-with-variable-number-of-words-in-a-field/

Friday, July 15, 2011

Backing up or moving a Silverstripe website

http://silverstripe.org/installing-silverstripe/show/4581#post251271

Thursday, July 14, 2011

Flushing cache in Silverstripe

go to the link http://silverstripe.website.org/?flush=1

Wednesday, July 13, 2011

Wednesday, June 29, 2011

Accessing a postgresql database in OpenOffice or libreoffice

If you have ubuntu, install :

sudo apt-get install libreoffice-sdbc-postgresql


In LibreOffice, create a new database. Then, in connection parameters, specify the URL : dbname=XXX host=abc.net and then the username and the password.

Monday, June 27, 2011

Graphical file diff editor for Linux

Meld is a wonderful little graphical program for Linux that helps differentiate between text files :

sudo apt-get install meld

Thursday, June 23, 2011

geodjango object has no attribute 'geo_db_type

Following the geodjango tutorial https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/

While building the application called world, one has to run the following command to initialise the database :

python manage.py sqlall world
....
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

The error is solved by editing settings.py and replacing the line
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2',
with
'ENGINE': 'django.contrib.gis.db.backends.postgis', # Add 'postgresql_psycopg2',

Thanks to http://stackoverflow.com/questions/3567352/geodjango-syncdb-errors-from-geodjango-tutorial

Saturday, June 18, 2011

GIMP: Replace image backgrounds with transparency

Save the image in a format that handles transparency (GIMP pcx or PNG).

Create an alpha channel : Layer-Transparency-Add Alpha Channel

To replace a single given color with transparency : Layer-Transparency-Color to Alpha

Thursday, June 16, 2011

Ubuntu : too many open files

From http://www.zimbra.com/forums/administrators/16066-solved-too-many-open-files-error.html

To set the maximum limit allowed for open files, as sudo or root, edit the /etc/security/limits.conf file. At the end of the file just above “# End of File” enter the following values:
* soft nofile 65535
* hard nofile 65535
Save the file. This will set the number of open files to unlimited.

An R package : sun-methods Methods for sun ephemerides calculations

sun-methods Methods for sun ephemerides calculations

Description :
Functions for calculating sunrise, sunset, and times of dawn and dusk, with flexibility for the various formal definitions. They use algorithms provided by the National Oceanic & Atmospheric Administration (NOAA).

Plotting error bar with polygons in R

A very nice presentation by Edzer Pebesma showing the spatio-temporal capabilities of R (spacetime package). Includes a nice way of plotting error bars as polygons :

http://ifgi.uni-muenster.de/~epebe_01/inpe.pdf

Saturday, June 11, 2011

Startup manager for Ubuntu for boot options

"sudo apt-get install startupmanager"

Wednesday, June 8, 2011

GuitarPro6 segmentation fault Ubuntu 64 bits

http://askubuntu.com/questions/41920/why-i-am-getting-a-segmentation-fault-opening-guitar-pro

mv ~/.ArobasMusic ~/.ArobasMusicbkp

If this does not work (Ubuntu 11.04), and the error is :

GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion `GDK_IS_PIXBUF (pixbuf)' failed
Segmentation fault

then downgrade the ia32-libs package :
(from http://getsatisfaction.guitar-pro.com/arobas_music/topics/after_ubuntu_11_04_upgrade_i_cant_open_gp6)

It seems a bug in the latest ia32-libs causes some trouble to applications that uses 32bit libraries (GP6 use 32 bit libraries too).

A workaround exists, simply downgrade the ia32-libs package.

Follow these guidelines to downgrade ia32:
- download the package from this page http://packages.ubuntu.com/maverick/amd64/ia32-libs/download
- execute this command line: sudo dpkg --force-downgrade -i ia32-libs_20090808ubuntu9.1_amd64.deb

Monday, May 30, 2011

Mounting SeaGate GoFlex from Linux

Download the driver from :
http://download.pogoplug.com/install/linux/pogopluginstall.tar.gz

Create a conf file .pogoplugfs.conf under the same directory as the driver :

svcuser=your_email_registered_with_pogoplug.com
svcpassword=PASS

To mount the file system in a non-empty direcory :
./pogoplugfs --mountpoint /home/acizmeli/Pogoplugfs/

Monday, May 16, 2011

use lapply to modify a list of lists in R

modifyList package:utils R Documentation

Recursively Modify Elements of a List

Description:

Modifies a possibly nested list recursively by changing a subset
of elements at each level to match a second list.

Sunday, May 8, 2011

querying a samba server and mounting a share

smbclient -L server

sudo /sbin/mount.cifs //server/Data /home/me/mountplace -o user=acizmeli%pass,rw

Saturday, May 7, 2011

Stream an image file from a web server and restore it to a partition:

Stream an image file from a web server and restore it to a Linux partition:

wget -qO - http://server/backup.img | \
ntfsclone --restore-image --overwrite /dev/hda1 -

Friday, April 29, 2011

python : To create a separate list

To create a separate list, you can use slicing or the list function to quickly create a copy:

L = []
M = L[:] # create a copy

# modify L only
L.append(obj)

grep with the find command with the Linux bash shell

use grep's command line option -H to print the filenames when used within the command "find"

find . -name \*.py -exec grep -Hn string_to_search {} \;

Monday, April 18, 2011

UbuntuOne client crashes with the non-UTF filenames

Detect the files with a bad name with : python /home/acizmeli/Downloads/utf8-filename-check.py

and rename the files


https://bugs.launchpad.net/ubuntuone-client/+bug/368626

Saturday, April 9, 2011

GuitarPro missing fonts

http://getsatisfaction.guitar-pro.com/arobas_music/topics/_font_missing_after_updating

Hi, try to remove these files :
C:\ProgramData\Guitar Pro 6\GuitarPro.dat
and
C:\Users\nmartin\AppData\Roaming\Guitar Pro 6\GuitarPro.dat

Linux :
sudo rm /opt/GuitarPro6/GuitarPro.dat

Tuesday, March 29, 2011

How to install Google Earth in Ubuntu 10.10 Maverick 64 bits

from http://www.ubun2.info/2010/10/how-to-install-google-earth-in-ubuntu.html?showComment=1287937450936

nstalling Google Earth in Ubuntu Maverick is very simple. For Ubuntu Maverick 64 bit users,they need to install the dependance package: ia32-libs and lib32nss-mdns.

Open up a terminal window from Applications -> Accessories menu and run:
sudo apt-get install ia32-libs lib32nss-mdns

After the installation of ia32-libs and lib32nss-mdns complete.
Then install googleearth-package from the default repository using this command:
sudo apt-get install googleearth-package

Then run the command:
make-googleearth-package --force

it will take a moment and finally generate a deb package.
Install the deb by the command (change the package name to yours):
sudo dpkg -i googleearth.deb

Finally,launch Google Earth from Applications – > Internet menu.

Sunday, March 27, 2011

How to Install GuitarPro6 on 64-bit Ubuntu

From http://ubuntuforums.org/showthread.php?t=1458626

How to Install Guitar Pro 6 on 64-bit install.
1) Download the latest .deb from Guitar Pro's website.
2) Goto http://frozenfox.freehostia.com/cappy/ and install getlibs-all.deb
3) Run this in terminal
Quote:
sudo dpkg -i --force-architecture Downloads/GuitarPro6-r7840.deb
You will get some errors but ignore.
4) Run this in terminal
Quote:
getlibs /opt/GuitarPro6/GuitarPro

Thursday, March 10, 2011

Moving a thunderbird profile to another machine

http://support.mozillamessaging.com/en-US/kb/Profiles#_Moving_a_profile

Friday, March 4, 2011

Installing Rstudio in Ubuntu : ignoring a depending package

The installer of rstudio complains : Package r-base is not installed. But in ubuntu, that package exists under the name r-base-core.

Simply install the package with the following command :

sudo dpkg -i --ignore-depends=r-base rstudio-0.92.23-i386.deb

Wednesday, February 23, 2011

To debug R code

Either :
* put the command browser() : will stop where the command "browser" was called
* or call the function debug : debug(name_function_to_debug) : will stop at the start of the script
* options(error=recover)

Type "Q" to exit the browser. Type "n" to execute the next line. Type "c" or ENTER to continue running and exit the function.

Monday, February 14, 2011

Installing RNetCDF (ncdf) in R

Taken from https://stat.ethz.ch/pipermail/r-help/2008-March/157089.html
This is ubuntu 10.4.

sudo apt-get install libudunits2-0 libudunits2-dev
sudo apt-get install libnetcdf4 libnetcdf-dev

Then in R :
install.packages("RNetCDF",configure.args="--with-netcdf-include=/usr/include")

Note : A regular install is unable to find netcdf.h, giving the error below. Use rather the install.packages command given above.

checking for netcdf.h... no
configure: error: netcdf header netcdf.h not found
ERROR: configuration failed for package ‘ncdf’

Thursday, January 27, 2011

ubuntu : installing ubuntugis and R

Add the following lines in /etc/apt/sources.list :

sudo vi /etc/apt/sources.list
deb http://cran.skazkaforyou.com/bin/linux/ubuntu maverick/
deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu maverick main
deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu maverick main

Then add the "canonical partners" software repository from "ubuntu software center-sofware sources" (for sun java jdk/jre)

Get the keys
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com D67FC6EAE2A11821
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable


sudo apt-get update
sudo apt-get install r-base-core libgdal1-dev libproj-dev libgdal1-1.7.0-grass qgis grass saga sun-java6-jdk

Saturday, January 1, 2011

qmail problem in plesk

Cannot send mail with qmail :

qmail-queue-handlers[xxxxxx]: cannot create temporary file - (13) Permission denied

I searched the web and there seems to be a solution. But it does not work :
http://forum.parallels.com/showthread.php?t=87344
http://forum.parallels.com/showthread.php?t=94593