Wednesday, December 2, 2009

Reading File Line By Line Into Array

This coding read the string input from text file line by line and put them into an array and then just return the required string. I used this program to read the predefined parameter file into my program.
"
public static String readParameter(String fileName, int inputFileRequired) {
String strLine = null;
String sentLine = null;
int numParam=3; //number of parameter available
String strParam[]= new String[numParam];
try {
File inFile = new File(fileName);
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(inFile)));
int i=0;
while ( i < numParam)
{
strLine = br.readLine();
if (strLine != null)
{
strParam[i]=strLine;
if (i == inputFileRequired)
{
sentLine= strParam[i];
}
}
i++;
}

br.close();
} catch (FileNotFoundException ex) {
return (null);
} catch (IOException ex) {
return (null);
}
return (sentLine);
}
"
how I called it:

" String a = new String(readParameter(inputFileName,0));
System.out.println("Look what I've read" + a);
"

I like this coding better (see link) but run out of time to change mine.

http://stackoverflow.com/questions/285712/java-reading-a-file-into-an-array



"
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Vector;
import java.net.*;
import java.sql.*;
"

Thursday, November 26, 2009

Data Mining Tutorial

For beginners who interested to learn data mining in easy and fast way, I suggest that you can have a look at the tutorial materials from Prof Andrew Moore, Carnegie Mellon University. They are easy to understand and the algorithms were explained in a simple way. All the best...

http://www.autonlab.org/tutorials/

P2P

http://www.computerworld.com/s/article/9138958/House_bill_seeking_government_P2P_ban_gets_boost?taxonomyId=70

Wednesday, November 25, 2009

Google Wave in Malaysia

I've been on Google Wave for quite a while but didnt use it regularly since I only have two unactive contacts. Usually, people who got a wave invitation will receive an email saying that they can invite up to certain number of people but I didnt receive the email until today. So now I have 8 invites and planning to give them to people who I believe gonna use it to the fullest and be active to explore the wave with me. And today I've also found out that most of my colleague already on googlewave. Therefore, I'm thinking about giving the invites to my friends in Malaysia. However, I'm a bit doubt whether the wave works well or not on the slow internet connection in Malaysia.

I hope if anyone has came across this blog, from Malaysia and on googlewave.. please add me in your contact.

mizmieza@googlewave.com

Thursday, June 18, 2009

Get rid of unwanted lines using unix

There are two ways:
First method.
1. Open the text file: vi filename.dat
2. :1,$ s/.*keywordsofthelines.*//g --> from first line(1) to the last line($), substract all lines contain the keyword
3. :wq -->write and save
4. sort filename | uniq > t --> sort it and pipe to uniq and save it into temporary t
5. mv t filename --> move all the data from tempoprary t to the file.

Second.
1. Open the text file in vi: vi filename.dat
2.Delete all the start and bottom rubbish stuff. go to the line and type dd
3. :wq
4. grep -F "recalled" filename > outfile

tips from Kerri Morgan

Wednesday, June 17, 2009

Marsyas installation

1. Install cmake (version 2.6 and above)
2. $cd marsyas-0.1.19
3. mkdir build
4.cd build
5.~/cmake-2.6.2-Linux-i386/bin/ccmake ../src/
6.Edit cmake compatibility if required
7.On the libmad (make sure MAD library stored)
8. configure and generate
9.at build -> $ make
10.at build ->$ make install
11.at build ->$make test
12. $ cd bin
13. use all marsyas commands (pitchextract,bextract) here

For more info:
http://opihi.cs.uvic.ca/NormCutAudio/pdf/ISMIR2006_Tutorial.pdf
http://marsyas.sness.net/docs/manual/marsyas-user/Available-tools.html#Available-tools

using marsyas:

1) creating
ls /home/amiza/song/Rock.wav > rock.mf
2) bextract -sv /home/amiza/song/rock -w rock.arff -p rock.mpl -cl GS

Installing cmake on Linux

(source: www.kdedevelopers.org/node/3754)

$wget http://www.cmake.org/files/v2.6/cmake-2.6.2-Linux-i386.tar.gz
$tar -zxvf cmake-2.6.2-Linux-i386.tar.gz


then use it:
cd myprojectdirectory
mkdir build
cd build
~/cmake-2.6.2-Linux-i386/bin/cmake ..

* for marsyas use
~/cmake-2.6.2-Linux-i386/bin/ccmake ../src/

Tuesday, March 3, 2009

Linux ref

1. To remove whole directory --> rm -rf (directoryname)
2. Check the different between files --> diff fileA fileB
3. sudo apt-get update
4. sudo apt-get upgrade
5. du -s // to know the size of folder
6. du -sh // the size of folder
7. df // the memory being used
8. tar zcvf * // copy all the files in the folder into tarfile
9. tar zcvf cinta // copy all files in folder cinta into tarfile
10. cat fileA fileB > fileC // copy file A and file B intttto file C
11. grep "aku" - r // searching for the word aku recursively
12. ls -l | wc -l // display the number of files in a directory
13. ls -n // list and sort by name all the files in the directory
14. ls | sort -n //display all the files and sort by number
15. ls | sort -n > mija.txt // put the result in mija.txt
16. man sort // get list of sort utility


Useful links
Linux command : ls
http://linux.about.com/od/commands/l/blcmdl1_ls.htm

Thursday, February 19, 2009

OverSim Installation

1. Download OverSim_20070926.tgz from http://www.oversim.org/.
2. Download INDET_20061020_OverSim_3.tgz to /home/amiza/
3. tar xvzf INET_20061020_Oversim_3.tgz
4. cd INET_20061020_OverSim_3
5. nano .inetconfig
5. Edit ROOT=$(HOME)/INET_20061020_OverSim_3
6. Compile ./makemake
7. make
8. Put OverSim_20070926.tgz in /home/amiza/
9. tar xvzf OverSim_20070926.tgz in
10. Compile
cd /home/amiza/OverSim_20070926
./makemake
make

OMNET++ Installation

1. Download OMNET++ from http://www.omnetpp.org/index.php
2. Put the downloaded file at /home/myhomefolder/
3. tar xvzf omnetpp-3.3-src.tgz
4. Edit .bashrc
export PATH=$PATH:/home/amiza/omnetpp-3.3/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/amiza/omnetpp-3.3/lib
export TCL_LIBRARY=/usr/lib/tcl8.4
5. Close the terminal and reopen it.
6. cd omnetpp-3.3
7. ./configure
8. make
9. cd /samples/dyna
10. make clean
11. make
12. ./dyna

MPICH Installation

1. Download mpich -*****.tar.gz
2. tar xvzf
3. cd mpich-****
4. configure
./configure --prefix=/home/myhomefolder/MPI --disable -f77 --with-pm=gforker --enable-romio --with-file-system=ufs+nfs
5. make
6. make install
6. Add MPI path at .bashrc file
export PATH=/home/myhomefolder/MPI/mpich-*****/bin:$PATH