Tuesday, December 21, 2010
How to run a command in the background on Windows
There is a command, whose name is START, on Windows, and you can use it to start another command in a new command window. The option /B allows you to run a command without extra command window.
Monday, December 20, 2010
How to disable Windows auto restart after update
1. click the Start button.
2. Once the menu pulls up we can click on "Run", and if you do not have "Run" in your start menu, you can use the keyboard shortcut "Win + r" to open the "Run" window.
3. Now you should have a field to type in, let's type "gpedit.msc" and hit enter.
4. Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Windows Update -> No auto-restart for scheduled Automatic Updates Installations
5. Double click it and set it as enabled.
6. Now close the window, and a reboot is necessary for the policy to take effect.
2. Once the menu pulls up we can click on "Run", and if you do not have "Run" in your start menu, you can use the keyboard shortcut "Win + r" to open the "Run" window.
3. Now you should have a field to type in, let's type "gpedit.msc" and hit enter.
4. Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Windows Update -> No auto-restart for scheduled Automatic Updates Installations
5. Double click it and set it as enabled.
6. Now close the window, and a reboot is necessary for the policy to take effect.
Saturday, November 27, 2010
Intel laptop CPU comparison i5 VS. i7
The link of Intel official webpage:
http://ark.intel.com/Compare.aspx?ids=43125,43122,49666,43560,49652,
http://ark.intel.com/Compare.aspx?ids=43125,43122,49666,43560,49652,
Wednesday, November 24, 2010
How to enable MMS on Iphone
I am using an Iphone from Singtel, and by default the MMS (multimedia message service) is disabled. Thus, if you want to send/receive MMS, you must enable it in the menu:
Setting ->> Messages ->> MMS Messaging
Setting ->> Messages ->> MMS Messaging
How to use Windows batch script to rename multiple files
@echo off
FOR %%F IN (*.wav) DO (
FOR /F "tokens=1-5 delims=/: " %%J IN ("%%~tF") DO (
rename %%F %%L%%K%%J%%M%%N_%%~nF%%~xF
)
)
which renames all the files matching *.wav, and the new files are began with the year (%%L), the month (%%K), the day (%%J), the hour (%%M), and the minute (%%N) according to the file's creation time.
Here I also point out how to extract the file name without file extension (%%~nF), file extension (%%~xF) and file creation time (%%~tF).
For example, this batch file can rename 1.wav and aaa.wav as 201011240600_1.wav and 201011230630_aaa.wav, respectively.
Sunday, November 21, 2010
Linux binary/hex editor
xxd -b input-file
displays the input-file in binary format
xxd -u input-file
displays the input-file in hex format
displays the input-file in binary format
xxd -u input-file
displays the input-file in hex format
Friday, June 25, 2010
NTFS: How to delete files without permission as an administrator
1. To take ownership of the file, you’ll need to use the takeown command.
Here’s an example:
where /R means recursively taking ownership.
2. That will give you ownership of the files and folders, but you still have no rights to delete it. Now you can run the cacls command to give yourself full control rights to the file:
At this point, you should be able to delete the file.
If you still can’t do so, you may need to reboot into Safe Mode and try it again.
The following are some options about the two commands used above:
Here’s an example:
takeown /R /f D:\cygwin
where /R means recursively taking ownership.
2. That will give you ownership of the files and folders, but you still have no rights to delete it. Now you can run the cacls command to give yourself full control rights to the file:
cacls D:\cygwin /T /G YourUserName:F
At this point, you should be able to delete the file.
If you still can’t do so, you may need to reboot into Safe Mode and try it again.
The following are some options about the two commands used above:
TAKEOWN [/S system [/U username [/P [password]]]]
/F filename [/A] [/R [/D prompt]]
Description:
This tool allows an administrator to recover access to a file that
was denied by re-assigning file ownership.
Parameter List:
/S system Specifies the remote system to
connect to.
/U [domain\]user Specifies the user context under
which the command should execute.
/P [password] Specifies the password for the
given user context.
Prompts for input if omitted.
/F filename Specifies the filename or directory
name pattern. Wildcard "*" can be used
to specify the pattern. Allows
sharename\filename.
/A Gives ownership to the administrators
group instead of the current user.
/R Recurse: instructs tool to operate on
files in specified directory and all
subdirectories.
/D prompt Default answer used when the current user
does not have the "list folder" permission
on a directory. This occurs while operating
recursively (/R) on sub-directories. Valid
values "Y" to take ownership or "N" to skip.
/? Displays this help message.
NOTE: 1) If /A is not specified, file ownership will be given to the
current logged on user.
2) Mixed patterns using "?" and "*" are not supported.
3) /D is used to suppress the confirmation prompt.
Examples:
TAKEOWN /?
TAKEOWN /F lostfile
TAKEOWN /F \\system\share\lostfile /A
TAKEOWN /F directory /R /D N
TAKEOWN /F directory /R /A
TAKEOWN /F *
TAKEOWN /F C:\Windows\System32\acme.exe
TAKEOWN /F %windir%\*.txt
TAKEOWN /S system /F MyShare\Acme*.doc
TAKEOWN /S system /U user /F MyShare\foo.dll
TAKEOWN /S system /U domain\user /P password /F share\filename
TAKEOWN /S system /U user /P password /F Doc\Report.doc /A
TAKEOWN /S system /U user /P password /F Myshare\*
TAKEOWN /S system /U user /P password /F Home\Logon /R
TAKEOWN /S system /U user /P password /F Myshare\directory /R /A
NOTE: Cacls is now deprecated, please use Icacls.
Displays or modifies access control lists (ACLs) of files
CACLS filename [/T] [/M] [/L] [/S[:SDDL]] [/E] [/C] [/G user:perm]
[/R user [...]] [/P user:perm [...]] [/D user [...]]
filename Displays ACLs.
/T Changes ACLs of specified files in
the current directory and all subdirectories.
/L Work on the Symbolic Link itself versus the target
/M Changes ACLs of volumes mounted to a directory
/S Displays the SDDL string for the DACL.
/S:SDDL Replaces the ACLs with those specified in the SDDL string
(not valid with /E, /G, /R, /P, or /D).
/E Edit ACL instead of replacing it.
/C Continue on access denied errors.
/G user:perm Grant specified user access rights.
Perm can be: R Read
W Write
C Change (write)
F Full control
/R user Revoke specified user's access rights (only valid with /E).
/P user:perm Replace specified user's access rights.
Perm can be: N None
R Read
W Write
C Change (write)
F Full control
/D user Deny specified user access.
Wildcards can be used to specify more than one file in a command.
You can specify more than one user in a command.
Abbreviations:
CI - Container Inherit.
The ACE will be inherited by directories.
OI - Object Inherit.
The ACE will be inherited by files.
IO - Inherit Only.
The ACE does not apply to the current file/directory.
ID - Inherited.
The ACE was inherited from the parent directory's ACL.
Saturday, June 5, 2010
How to install Python to your local directory
1. download source tarball from official website:
http://www.python.org/download/releases/2.5/
2. decompress the tarball:
tar -zxvf Python-2.5.tgz
3. change prefix in file Python-2.6.5/configure:
change: ac_default_prefix=/usr/local
to: ac_default_prefix=/home/username/local/lib/Python-2.6.5
4. run the following commands:
./configure
make
make install
5. after all the commands above have been done,
you need to add /home/username/local/lib/Python-2.6.5/bin to your PATH environment variable, and add /home/username/local/lib/Python-2.6.5/lib/python2.6 to PYTHONPATH
http://www.python.org/download/releases/2.5/
2. decompress the tarball:
tar -zxvf Python-2.5.tgz
3. change prefix in file Python-2.6.5/configure:
change: ac_default_prefix=/usr/local
to: ac_default_prefix=/home/username/local/lib/Python-2.6.5
4. run the following commands:
./configure
make
make install
5. after all the commands above have been done,
you need to add /home/username/local/lib/Python-2.6.5/bin to your PATH environment variable, and add /home/username/local/lib/Python-2.6.5/lib/python2.6 to PYTHONPATH
Wednesday, May 19, 2010
Use binary/hex editor in vim
1. switch into hex mode
open a file in vim as usual,
and press Esc and type:
:%!xxd
2. switch to text mode
press escape again and type:
:%!xxd -r
open a file in vim as usual,
and press Esc and type:
:%!xxd
2. switch to text mode
press escape again and type:
:%!xxd -r
Tuesday, March 30, 2010
HTK bug of HHEd
Description:
When I run HHEd -T 1 -H lib/am/MMF44 -M classes regtree.hed MMF44.mlist
The output is as follows:
Bug:
I had checked for a long time to locate the problem.
Finally, I found that the last line of the regtree.hed file do not have a "\n" at the end of the line. If I added the "\n", everything is fine.
Thus, I think the HHEd of HTK can't read file without a terminator of the file, such as "\n".
When I run HHEd -T 1 -H lib/am/MMF44 -M classes regtree.hed MMF44.mlist
The output is as follows:
HHEd
65561/18300 Models Loaded [5 states max, 8 mixes max]
LS lib/am/stats.MMF44.S1.en
Loading state occupation stats
Stats loaded for 18300 models
Mean Occupation Count = 6833.864217
RC 32 rtree
Building regression tree with 32 terminals
Creating regression class tree with ident rtree.tree and baseclass rtree.base
▒
^
Error { expected
ERROR [+7230] EdError: item list parse error
FATAL ERROR - Terminating program HHEd
Bug:
I had checked for a long time to locate the problem.
Finally, I found that the last line of the regtree.hed file do not have a "\n" at the end of the line. If I added the "\n", everything is fine.
Thus, I think the HHEd of HTK can't read file without a terminator of the file, such as "\n".
Sunday, March 28, 2010
How to use screen command in Linux
$ screen //创建一个跑着shell的单一窗口
//在这个窗口中,你可以正常跑任何程序
//然后Ctrl+a d退出刚创建的窗口
//screen窗口都不会关闭,会在后台正常运行
//重复这样的步骤,可以建立多个独立的shell窗口
$ screen -ls //可以看所有的screen sessions' id
// screen session不再使用的时候
$ screen -r sessionid //输入exit就可以退出,关掉这个screen session
//在这个窗口中,你可以正常跑任何程序
//然后Ctrl+a d退出刚创建的窗口
//screen窗口都不会关闭,会在后台正常运行
//重复这样的步骤,可以建立多个独立的shell窗口
$ screen -ls //可以看所有的screen sessions' id
// screen session不再使用的时候
$ screen -r sessionid //输入exit就可以退出,关掉这个screen session
Thursday, March 11, 2010
How to change the NetBeans default JDK
change /etc/netbeans.conf file:
# Default location of JDK, can be overridden by using –jdkhome:
netbeans_jdkhome=”C:\Program Files\Java\jdk1.6.0_05″
# Default location of JDK, can be overridden by using –jdkhome:
netbeans_jdkhome=”C:\Program Files\Java\jdk1.6.0_05″
How to change NetBeans Interface language
Adding "--locale en_US" to the *netbeans_default_options* value in file:
/etc/netbeans.conf
Thursday, March 4, 2010
How to read Excel file in Java
1. you need to download org.apache.poi from:
http://poi.apache.org/download.html
2. then you can use the package just downloaded in Java, and of course you need to put the package in your own project
3. The following code showing you the simple procedure to read an Excel file:
http://poi.apache.org/download.html
2. then you can use the package just downloaded in Java, and of course you need to put the package in your own project
3. The following code showing you the simple procedure to read an Excel file:
//http://poi.apache.org/index.html
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
class sample
{
void readExcelFile(String excelFileName)
{
try
{
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFileName));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = null;
HSSFCell cell = null;
int count_rows; // NO of rows
count_rows = sheet.getPhysicalNumberOfRows();
int count_columns = 0; // NO of columns
int current_columns = 0;
// This trick ensures that we get the data properly even if it
// doesn't start from first few rows
for (int r = 0; r<10 && r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{
current_columns = row.getPhysicalNumberOfCells();
if (current_columns > count_columns)
count_columns = current_columns;
}
}
for (int r = 0; r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{// process one row
for (int c = 0; c < count_columns; c++)
{
cell = row.getCell(c);
if (cell != null)
{// main part of processing cells
System.out.print(cell.getStringCellValue()+" ");
}
}
System.out.println();
}
}
}
catch (Exception ioe)
{
ioe.printStackTrace();
}
}
}
Wednesday, February 3, 2010
How to compile HTK under Visual Studio 2008
This post describes how to compile HTK source code under Visual Studio 2008 on Windows.
0. Download HTK source code for Windows from:
http://htk.eng.cam.ac.uk/download.shtml
and decompress it, after which you can get the following folders:
1. Create a solution named "HTK-windows", and also a project named "HCopy" in VS2008:
and then in the configuration of project "HCopy", you need to click on the box of "Empty project" as follows:
2. Configure the project "HCopy"
You first need to copy the HTKLib folder to the root directory of your solution "HTK-windows", and then copy the file "HCopy.c" in the folder "HTKTools" to the root directory of your project "HCopy".
Right click the project "HCopy", and then click the "Properties" as follows:
In the "Properties" window, you need to add the "HTKLib" folder (or $(SolutionDir)\HTKLib) located in the root directory of your solution, to the "Additional Include Directories":
Then add /D "ARCH=WIN32" to the "Command Line":
3. Add the the files (*.c and *.h) except "HGraf.c" and "HGraf.null.c" in folder "HTKLib" into project "HCopy":
4. Finally, you can build your project "HCopy":
5. Of course, here I only present how to compile HCopy of HTK in VS2008, and you can follow more or less the same procedure to compile other tools of HTK. You just need to create new projects under the solution "HTK-windows" as follows:
PS: if you want to build HSLab.c, you need to exclude HFB.h and HFB.c;
if you want to build HDecode.c, you need to add an additional command line parameter /D "NO_LAT_LM", and also do not add HLM.h and HLM.c to your project "HDecode".
0. Download HTK source code for Windows from:
http://htk.eng.cam.ac.uk/download.shtml
and decompress it, after which you can get the following folders:
1. Create a solution named "HTK-windows", and also a project named "HCopy" in VS2008:
and then in the configuration of project "HCopy", you need to click on the box of "Empty project" as follows:
2. Configure the project "HCopy"
You first need to copy the HTKLib folder to the root directory of your solution "HTK-windows", and then copy the file "HCopy.c" in the folder "HTKTools" to the root directory of your project "HCopy".
Right click the project "HCopy", and then click the "Properties" as follows:
In the "Properties" window, you need to add the "HTKLib" folder (or $(SolutionDir)\HTKLib) located in the root directory of your solution, to the "Additional Include Directories":
Then add /D "ARCH=WIN32" to the "Command Line":
3. Add the the files (*.c and *.h) except "HGraf.c" and "HGraf.null.c" in folder "HTKLib" into project "HCopy":
4. Finally, you can build your project "HCopy":
5. Of course, here I only present how to compile HCopy of HTK in VS2008, and you can follow more or less the same procedure to compile other tools of HTK. You just need to create new projects under the solution "HTK-windows" as follows:
PS: if you want to build HSLab.c, you need to exclude HFB.h and HFB.c;
if you want to build HDecode.c, you need to add an additional command line parameter /D "NO_LAT_LM", and also do not add HLM.h and HLM.c to your project "HDecode".
Wednesday, January 20, 2010
How to set the locale environment variables under Linux
The locale environment variables can affect the encoding of Java applications.
Thus, sometimes if you do not set the variables correctly, you can't run your Java applications.
You can run command "locale" to display all the locale environment variables of current shell:
$ locale
LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=
You can see all the supported locale settings using:
$locale -a
The setting of LC_CTYPE seems to be decisive over all other variables except for LC_ALL. Setting LC_ALL overrides any other locale variable.
Thus, sometimes if you do not set the variables correctly, you can't run your Java applications.
You can run command "locale" to display all the locale environment variables of current shell:
$ locale
LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=
You can see all the supported locale settings using:
$locale -a
The setting of LC_CTYPE seems to be decisive over all other variables except for LC_ALL. Setting LC_ALL overrides any other locale variable.
Sunday, January 3, 2010
How to use the internal language model of moses on Windows
the Internal LM is meant to mimic SRILM,
and you need to use SRILM to train your language model under Linux first,
and then copy the trained language model files to Windows.
You also need to copy all the translation models, including phrase table, reordering model to Windows, and of course changing the moses ini file is needed, because the path names are different.
On Windows, you can use language models which are up to trigram.
Although the windows version of moses can run with 4-gram or higher language models,
but the translation results are incorrect.
and you need to use SRILM to train your language model under Linux first,
and then copy the trained language model files to Windows.
You also need to copy all the translation models, including phrase table, reordering model to Windows, and of course changing the moses ini file is needed, because the path names are different.
On Windows, you can use language models which are up to trigram.
Although the windows version of moses can run with 4-gram or higher language models,
but the translation results are incorrect.
Saturday, January 2, 2010
How to compile moses under Visual Studio 2005
Moses can be compiled under Visual Studio 2005.
Fortunately, moses provides all the necessary files for you including solution and project files.
However, you also need to download some source files and library files as described in:
http://www.statmt.org/moses/?n=Moses.LibrariesUsed
For me, I need to download VLD and zlib. They are both pre-compiled version, and what you need to do is to add the directories to your moses solution under Visual Studion 2005.
When you first open the solution of moses, you will see four projects as follows:
After that you need to download VLD and zlib, and I put the two downloaded folders under the solution directory of moses as follows:
For the project "moses", you need to add "Additional Include Directories" in the property of the project:
and you also need to add "Additional Library Diretories":
For the other three projects, you need to add "Additional Include Directories" and "Additional Dependencies" as follows:
Finally, you did it, and you can compile the whole solution now.
Fortunately, moses provides all the necessary files for you including solution and project files.
However, you also need to download some source files and library files as described in:
http://www.statmt.org/moses/?n=Moses.LibrariesUsed
For me, I need to download VLD and zlib. They are both pre-compiled version, and what you need to do is to add the directories to your moses solution under Visual Studion 2005.
When you first open the solution of moses, you will see four projects as follows:
After that you need to download VLD and zlib, and I put the two downloaded folders under the solution directory of moses as follows:
For the project "moses", you need to add "Additional Include Directories" in the property of the project:
and you also need to add "Additional Library Diretories":
For the other three projects, you need to add "Additional Include Directories" and "Additional Dependencies" as follows:
Finally, you did it, and you can compile the whole solution now.
Subscribe to:
Posts (Atom)