0. useful tool to find packages of ubuntu
sudo aptitude
1. install some programming language and packages
for C++:
aptitude install g++
aptitude install build-essential
sudo apt-get install zlib1g-dev libssl-dev (for irstlm)
for Java:
sudo apt-get install sun-java6-jdk
and set environment variable
export JAVA_HOME="/usr/lib/jvm/java-6-sun;"
in ~/.bash_profile
2. install flash plugin for firefox
download flash player (.tar.gz for Linux version) from:
http://get.adobe.com/flashplayer/
decompression it, and copy the libflashplayer.so to /usr/lib/firefox-addons/
3. install Flock browser
sudo apt-get install libstdc++5
download Flock from:
http://www.flock.com/download/versions
tar xvf flock-2.5.en-US.linux-i686.tar.bz2
./flock-browser
install flash plugin to Flock:
just like the case of Firefox, copy the libflashplayer.so of flash player to flock/plugins/
4. instal Opera browser
download Opera 10.00b1 for Linux i386 (Download this package in TAR.GZ format) from:
http://www.opera.com/download/?os=linux-i386&ver=10.00b1&local=y
tar -xvzf opera-10.00-b1.gcc4-shared-qt3.i386.tar.gz
cd opera-10.00-4402.gcc4-shared-qt3.i386/
sudo ./install.sh
And then install flash plugin like the firefox case:
copy the libflashplayer.so to /usr/lib/opera/plugins
Saturday, July 11, 2009
Tuesday, July 7, 2009
In Java, how to get the OS type and OS name
String osName=null;
// get OS type
try
{
String osType = System.getProperty("os.arch");
System.out.println("Operating system type => " + osType);
osName = System.getProperty("os.name");
System.out.println("Operating system type => " + osName);
}
catch (Exception e)
{
System.out.println("Exception caught =" + e.getMessage());
}
// get OS type
try
{
String osType = System.getProperty("os.arch");
System.out.println("Operating system type => " + osType);
osName = System.getProperty("os.name");
System.out.println("Operating system type => " + osName);
}
catch (Exception e)
{
System.out.println("Exception caught =" + e.getMessage());
}
Set Netbeans user Interface language
Netbeans automatically uses the Windows system default language as the default user interface language. I believe that it means to be a nice feature for localization. But I personally find it uncomfortable because I have been used with English interface.
After I did some Google search, I learned a few tips to set the Netbeans UI language.
1. Temporary Solution
Add "--locale en:US" at the end of Netbeans startup command.
"C:\Program Files\NetBeans 6.0.1\bin\netbeans.exe" --locale en:US
2. Permanent Solution
Go to Netbeans installation directory, for example,
C:\Program Files\NetBeans 6.0.1\etc
Open "netbeans.conf" and find netbeans default option line
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
Add "-J-Duser.language=en -J-Duser.region=US" to the end of this line
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-Duser.language=en -J-Duser.region=US"
It would be nice that there is an option to allow me choose the user interface language in the next Netbeans release.
After I did some Google search, I learned a few tips to set the Netbeans UI language.
1. Temporary Solution
Add "--locale en:US" at the end of Netbeans startup command.
"C:\Program Files\NetBeans 6.0.1\bin\netbeans.exe" --locale en:US
2. Permanent Solution
Go to Netbeans installation directory, for example,
C:\Program Files\NetBeans 6.0.1\etc
Open "netbeans.conf" and find netbeans default option line
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
Add "-J-Duser.language=en -J-Duser.region=US" to the end of this line
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-Duser.language=en -J-Duser.region=US"
It would be nice that there is an option to allow me choose the user interface language in the next Netbeans release.
In python, how to read unicode or GBK files
import codecs
infile=codecs.open(infilename,"r","gbk")
line=infile.readline()
# all the lines which are read from infile are encoded in GBK
infile=codecs.open(infilename,"r","gbk")
line=infile.readline()
# all the lines which are read from infile are encoded in GBK
Saturday, July 4, 2009
In Java, how do I set a default character encoding for file I/O operations
The default encoding used by locale/encoding sensitive API in the Java libraries is determined by the System property "file.encoding". This system property is initialized by the JVM startup code after querying the underlying native operating system. For example on my English USA NT box it is initialized to:
Cp1252
It is generally recommended that you do not modify it. However if you know what you are doing you could override the system property either on the command line using the -
java -Dfile.encoding=GBK -jar Speech.jar
syntax or programmatically at startup.
Cp1252
It is generally recommended that you do not modify it. However if you know what you are doing you could override the system property either on the command line using the -
java -Dfile.encoding=GBK -jar Speech.jar
syntax or programmatically at startup.
Friday, July 3, 2009
Adding a DOS cmd prompt to the Windows right click menu
1.
Go to the HKEY_CLASSES_ROOT\Folder\shell node in the registry (note that Folder includes drives and directories).
2.
Create a new key (from the right-click menu), and call it "DOS prompt".
3.
Under that new key, create a sub-key named "command".
4.
Under that new key (i.e under HKEY_CLASSES_ROOT\Folder\shell\DOS prompt\command), edit the (Default) String value and give it the following value: "c:\windows\system32\cmd.exe %1" (or whatever the path to cmd.exe is on your system).
5.
Now, you can open a DOS window by right-clicking on any directory name in the Windows explorer.
Go to the HKEY_CLASSES_ROOT\Folder\shell node in the registry (note that Folder includes drives and directories).
2.
Create a new key (from the right-click menu), and call it "DOS prompt".
3.
Under that new key, create a sub-key named "command".
4.
Under that new key (i.e under HKEY_CLASSES_ROOT\Folder\shell\DOS prompt\command), edit the (Default) String value and give it the following value: "c:\windows\system32\cmd.exe %1" (or whatever the path to cmd.exe is on your system).
5.
Now, you can open a DOS window by right-clicking on any directory name in the Windows explorer.
Wednesday, July 1, 2009
In Java, how to change the encoding of files
These days, I have a task to change the file whose encoding is UTF-8 into a file with encoding of GBK.
I found a very useful tutorial at:
http://www.herongyang.com/unicode/jdk_encoding_conversion.html
As a summary, you can directly use the following Java code:
String cfilename="";
String outCnFileName="";
BufferedReader cfile = new BufferedReader( new InputStreamReader(new FileInputStream(cfilename),"UTF-8") );
BufferedWriter outcnfile = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(outCnFileName),"GBK") );
String line=cfile.readLine();
while( line!=null )
{
outcnfile.write(line+"\n");
}
cfile.close();
outcnfile.close();
I found a very useful tutorial at:
http://www.herongyang.com/unicode/jdk_encoding_conversion.html
As a summary, you can directly use the following Java code:
String cfilename="";
String outCnFileName="";
BufferedReader cfile = new BufferedReader( new InputStreamReader(new FileInputStream(cfilename),"UTF-8") );
BufferedWriter outcnfile = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(outCnFileName),"GBK") );
String line=cfile.readLine();
while( line!=null )
{
outcnfile.write(line+"\n");
}
cfile.close();
outcnfile.close();
Subscribe to:
Posts (Atom)