Wednesday, May 30, 2007

Ruby: Separete OA and Control data

Separete OA and Control date from txt files.

#!/usr/bin/env ruby
sfh ='~/myruby/lud/pairs.txt','r')
sfh.each_line {|line| nameA.push line.chomp; }


fbase=ARGV[0] if ARGV.length>0'.txt','r').each_line {|l|
dataF[fname.chomp]= l.chomp;

nameA.each {|l|
if oaData!=nil
dataOA.push oaData
puts oa.chomp
if oaC!=nil
dataC.push oaC

puts dataOA.length, dataC.length

open(fbase+'_OA.txt', 'w') do |f|
dataOA.each { |i| f << i <<"\n" }

open(fbase+'_Control.txt', 'w') do |f|
dataC.each { |i| f << i << "\n" }

Example usage:
divOAvsControl.rb Sta_fs.txt
divOAvsControl.rb Str_fs.txt
divOAvsControl.rb Std_fs.txt

Source in: ~/myruby/lud/.

Tuesday, May 29, 2007

rar: compress and divide large file to bunch of small ones

rar a -s -v30000 -m5 test.rar test/*where 30000 means 30MB.
Uncompress:rar x dvd1.part001.rar

Thursday, May 17, 2007

VirtualBox, Intel Mac X, Ubuntu (Ubuntu Server Edition)

Having Mac X at work is really nice thing. However sometimes one would like to use something else like Linux or Windows or whatever. I'm one of those guys that needs usually more than one operating systems, just to test something, or just because there is some feature that is present in e.g. Linux which is not available in Mac X. I decided to try VirtualBox beta for Intel Mac X, and to install Ubuntu. My choice of Ubuntu was driven only because where I work, Ubuntu is Ubuntu available at local ftp i.e. do not need to download it form the Internet.

Even thought VirtualBox for Intel Mac X is in beta stage, the installation was smooth, installation of Ubuntu also. Ubuntu on VirtualBox had out-of-the box internet and network working. In other words, there was no problems in installing, running, and using virtual Ubuntu.

The only problem there was/is with shearing folders. This is not VitualBox fold (I thinks so), but Ubuntu's mounting schema. What I mean is, that after mounting share folder, only root can write to it. Unfortunately it is not possible to set up umask=000 (everyone can read/write).

Below some screens of Mac and Ubuntu.

Share folders:mount -t vboxsf [-o OPTIONS] sharename mountpoint

As a matter of fact, I would prefer to have Windows XP on Virtual Box, but to install it, first I have to talk with our IT manager, because he has Windows installation cd-rom.

What about Ubuntu Server Edition? I wander if it was possible to install Ubuntu Server Edition on VirtualBox on Mac X, and use it just like server i.e. to set up an internet website on a virtual server. To check it, and to check Ubuntu Server Edition I decided to install this os on VirtualBox and try to set up a working, virtual LAMP server.
Unfortunately the answer to the above question is: Installation of Ubuntu Server Edition failed. In fact installation went fine, but first booting just after the installation resulted in:

I decided to check something else also. I was wandering if I can copy virtual Ubuntu created in Mac X to Windows XP and run in successfully there.

Wednesday, May 16, 2007

Mac X: Project-R

The problem with Intel Mac is that there are no software for it. Since maybe two months there is Matlab, thanks God, but I still miss SPSS, or any other statistical software different than Excel!. I have just receive an email about something called project R. I was interested by the mail; hence, I found out that it is a statistical program. I hope that it is what I was looking for, or at least will be easy to learn, on the condition that it will be nice. At the moment I'm waiting, because installation through DarwinPorts takes ages, thus I have time to write something (in fact, I have not time, but checking this new soft is just excuse from work). As soon as the installation succeed I will check it, whether it was worth installing or not.

Installation has just succeeded, although it was very, very long. Just to check it, I used an example (creation of box plots) available in a official manual:
A <- scan()
79.98 80.04 80.02 80.04 80.03 80.03 80.04 79.97
80.05 80.03 80.02 80.00 80.02

B <- scan()
80.02 79.94 79.98 79.97 79.97 80.03 79.95 79.97

boxplot(A, B)

One can see that it was very easy, and this fast test is quite encouraging to spend some more time with this R.

95% confidence interval in R:
>X1 <- scan()
1: 205 179 185 210 128 145 177 117 221 159
2: 205 128 165 180 198 158 132 283 269 204
> a <- mean(X1)
> s <- sd(X1)
> n <- length(X1)
> errZ <- qnorm(0.975)*s/sqrt(n)
> errT <- qt(0.975,df=n-1)*s/sqrt(n)
>left <- a-errT
>right <- a+errT

Saturday, May 12, 2007

Latex: font sizes


or to change font in larger text part:\begin{small}
something something ...

Double spacing\usepackage{setspace}
or arbitrary spacing e.g.:\setstretch{2.5}
Two column article:\documentclass[twocolumn,11pt]{article}
In a text, to switch from one to two column use \onecolumn and \twocolumn.
in two-column documents, \begin{figure*} \end{figure*} provides a floating page-wide figure (and \begin{table*} \end{table*} a page-wide table). The "*"ed float environments can only appear at the top of a page, or on a whole page - h or b float placement directives are simply ignored.

Monday, May 07, 2007

Latex: too many unprocessed floats

If you have it, it means that you have put to many figures or tables one next to each other, and Latex cannot locate them all. The quick solution to this is to add:\clearpage or \cleardoublepage command between your float objects. I does not give blank page in our documents, it just give one more page for latex to put your objects on it.

Sunday, May 06, 2007

100% CPU usage by spoolsv.exe in Win XP

Spoolsv.exe is a windows server application to manage printing queue. My friend had problem in his laptop becuase this application was using 100 % CPU; hence, computer was very slow. If you kill it, it will start again in a few minutes.
The problem was caused by the fact, that there were few files in a queue to print, but no printer. Hence, he went to C:\windows\system32\spool\PRINTER and deleted everything what was there. Sometimes you must first kill spoolsv.exe in task manager prior to removing files. This helped.