char charArr[100];
CComBSTR aComBSTR;
strcpy_s(charArr, comBSTR.Length()+1, aComBSTR);
ref:http://msdn.microsoft.com/en-us/library/ms235631(v=vs.80).aspx
Any IT knowledge
Wednesday, February 29, 2012
Thursday, February 10, 2011
How to convert file with comma separator (CSV) to arff
My condition data file with comma separator that will be used with Weka program, one file is data another file is attributes name. Even java source code for this job was available at https://list.scms.waikato.ac.nz/pipermail/wekalist/2008-October/014671.html but sometime I still wanna coding sine my computer that I used didn't install java sdk. So, here is my step.
First, let's create header for arff using Notepad++.
Replace current attribute name to weka format for example attributes name in text file is
--------------attributeNames.txt------------------
0,1,2,3,4,5,6,7,8,9,10,11,12
a1: -1,1
a2: -1,1
----------------------------------------------------
but arff format should be something like
--------------data.arff----------------------------
@relation mydataset
@attribute a1 {-1,1}
@attribute a2 {-1,1}
@attribute class {0,1,2,3,4,5,6,7,8,9,10,11,12}
@data
1,-1,2
-1,1,10
----------------------------------------------------
1. Add line @relation follow dataset name
2. Replace "a" with @attribute a
3. Replace ": -1,1"
4. Copy the first line as it is class label to the last line of attribute and put @attribute in front of its.
5. Add line @data
After that we have to added this arff header to the data file there quite tricky step (I describe in term of using Ms windows)
1. Open data.txt in "notepad"
2. Copy the header that we just finished and paste in front of the data file
3. Save file in arff extension
Test with weka if it work .. let's use it.
But if not, weka might display error dialog about incorrect header at some token.
4. Reopen your data.arff with "notepad".
5. Copy the newline character that you might not seen but you can select by using keyboard cursor move between @relation mydataset and @attribute and paste behind @data
It should be work right now. ^ ^
Thursday, July 15, 2010
How to get parameters from command-line in MFC
after reviewing many method that I found such a override CommandLine Handling Class
But I think it should something easier finally I found. Thanks Google and Viorel from http://www.windows-tech.info/17/9c91f002ea72ac3d.php
>>>Here is one solution, using CommandLineToArgvW command
for MFC in class ....App there is function InitInstance() that will be called first when program start. Before line
INT_PTR nResponse = dlg.DoModal();
added code
LPWSTR *szArglist;
int nArgs;
int i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if( NULL == szArglist )
{
wprintf(L"CommandLineToArgvW failed\n");
return 0;
}
else
{
for( i=0; i
{
printf("%d: %ws\n", i, szArglist[i]);
}
}
Friday, July 2, 2010
How to run .jar file with specific classpath
simply but not easy as I google many sites 'til I found this ...
$ java -cp [jarfilename].jar [MainClass]
MainClass is class that contain 'public static void main(String args[])' which entry point for this jar file
Thursday, February 4, 2010
How to setup Thai LaTex in Windows
This article is gather information for setup Thai LaTex from sites in the bottom of page (most of article translate from this). I try to explain step by step with image description for newbie who want to used greatest typeset software, Thai LaTex. You haven't spend any penny to use this software but for you might spend a lot of time instead. So, I hope is article would save someone time for setup Thai LaTex.
Because my first time set it up questions are on Cygwin, so in this article I try to more describe step on Cygwin. For setup ThaiLaTex most of it I gather from this which great describe but I gather to one place to easier follow.
Step 1 Download Miktex latest version from http://miktex.org/, currently last stable version is 2.8. Install Miktex to default folder such as c:\Program Files\MiKTeX 2.8 for version 2.8. It might take quiet long installation time because it have to transfer a lot of package files.
Step 2 Download Cygwin and install
2.1 Go to http://www.cygwin.com/ and download setup.exe
2.2 Run setup .exe
2.3 Select "Install from Internet"

2.4 Select path for install Cygwin currently I used "C:\Program Files\Cygwin"
* if you got warning dialog "You should not choose a root path that include spaces in directory names. Proceed anyway?" click Yes
2.5 Select local package directory, this folder is where downloading package stored.

2.6 Select Direct Connection

2.7 Choose available download site, normally the first one is ok. Click Next

2.8 It will start downloading setup.ini which kept information about package for CygWin

2.9 In select packages page, type 'make' to search dialog. It will filter package which contain 'make' program, which are Devel and X11.


2.10 Click on 'Default' text after 'Devel' heading. Wait for a few seconds, text will be changed to 'Install'. Click on plus button '+' in front of Devel, will show program those will be installed.

2.11 Again type 'tetex' to search dialog and click on 'Default' text next to 'Text' heading. Text after 'Text' will be changed from 'Default' to 'Install'.
*note: TeTex is obsolete use texlive instead

2.12 Click Next button it will downloading the 'make' and 'tetext' program and install to your computer.
Step 3 Download Thailatex fonts from http://tug.ctan.org/tex-archive/language/thai/thailatex/
3.1 Extract this folder to C:\thailatex
3.2 Open Cygwin by go to start > Program > Cygwin Bash Shell
3.3 Browse to thailatex folder by type command
cd /cygdrive/c/thailatex

3.4 Type command
make
3.5 Type command
make install
3.6 Close Cygwin
Step 4
4.1 Go to c:\thailatex\fonts\ and copy files
Ithuni.enc , thailigs.enc to C:\Program Files\MiKTeX 2.8\dvips\base
thai.map to C:\Program Files\MiKTeX 2.8\dvips\config
thai.map to C:\Program Files\MiKTeX 2.8\fonts\map\dvips
4.2 Go to c:\thailatex\babel copy files .fd, .def, .ldf and .sty to C:\Program Files\MiKTeX 2.8\tex\generic\babel

*Tip: to copy selected file type I suggest to use window search and look for *.fd, *.def, *.ldf, *.sty in current folder to avoid mistake.
4.3 Go to c:\thailatex\fonts\ coply files (create sub-folder 'thai' for target)
to searching files using search in windows is suggestion because there are a lot of files
*.afm to C:\Program Files\MiKTeX 2.8\fonts\afm\public\thai
*.tfm to C:\Program Files\MiKTeX 2.8\fonts\tfm\public\thai
*.pfb to C:\Program Files\MiKTeX 2.8\fonts\type1\public\thai
*.vf to C:\Program Files\MiKTeX 2.8\fonts\vf\public\thai
4.4 Go to windows command line (start > run > type 'cmd')
4.5 Type command
initexmf --edit-config-file updmap
and insert text 'Map thai.map' and save file
4.6 Update Miktex , type command
initexmf -v --mkmaps -u
Step 5 Test
5.1 open notepad copy and paste below code, when 'norasi' is font name there are another font name that you can used see example http://thailatex.files.wordpress.com/2009/08/thaitest.pdf
\documentclass{report}
\usepackage[thai]{babel}
\usepackage{thswitch}
\begin{document}
\usefont{LTH}{norasi}{m}{n}
สวัสดีชาวโลก
\end{document}
5.2 Create new folder c:\testlatex
5.3 Saved file to c:\testlatex\simple.tex
5.4 Go to windows command line type
latex simple
you should got simple.dvi, double click or open it by Yap. Yap is program to view file .dvi and normally Yap was installed from Miktex package.
5.5 Type command
dvipdfm simple.dvi
now you got simple.pdf to used
Step 6 Using SWATH (Smart Word Analysis for THai) which is a word segmentation for Thai.
6.1 Download swath from http://swath.googlecode.com/files/swath.zip
6.2 Extract to C:\swath
6.3 Open notepad and type
c:\swath\swath -f latex -d c:\swath\swath < %1.ttx > %1.tex
saved as sw.bat
6.4 Renamed file c:\testlatex\simple.tex to simple.ttx. *This is convention to create file in format .ttx and convert to .tex using SWATH.
6.5 Go to windows commandline type
sw simple
6.6 Type command
latex simple
you will got simple.dvi those segment word by SWATH
Saving your time instead of using two (or more) commands each time by create batch file name thailatex.bat
c:\swath\swath -f latex -d c:\swath\swath < %1.ttx > %1.tex
latex %1
makeindex %1
bibtex %1
latex %1
latex %1
and save to C:\Program Files\MiKTeX 2.8\miktex\bin\thailatex.bat (makeindex and bibtex is another program to manage index and reference)
next time you create new filename.ttx you just type command
thailatex filename
and you will got filename.dvi
Thanks so much to
http://thailatex.wordpress.com/latex-%E0%B8%AD%E0%B8%A2%E0%B9%88%E0%B8%B2%E0%B8%87%E0%B9%84%E0%B8%A3%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%9B%E0%B8%A7%E0%B8%94%E0%B8%AB%E0%B8%B1%E0%B8%A7/miktex-25-26-with-thai/
http://www.bloggang.com/viewblog.php?id=suntrust&date=22-04-2008&group=3&gblog=1
http://ichris.ws/latex-5
http://physics3.sut.ac.th/miktexthai.html
http://linux.thai.net/~thep/
http://code.google.com/p/swath/
Because my first time set it up questions are on Cygwin, so in this article I try to more describe step on Cygwin. For setup ThaiLaTex most of it I gather from this which great describe but I gather to one place to easier follow.
Step 1 Download Miktex latest version from http://miktex.org/, currently last stable version is 2.8. Install Miktex to default folder such as c:\Program Files\MiKTeX 2.8 for version 2.8. It might take quiet long installation time because it have to transfer a lot of package files.
Step 2 Download Cygwin and install
2.1 Go to http://www.cygwin.com/ and download setup.exe
2.2 Run setup .exe
2.3 Select "Install from Internet"
2.4 Select path for install Cygwin currently I used "C:\Program Files\Cygwin"
2.5 Select local package directory, this folder is where downloading package stored.
2.6 Select Direct Connection
2.7 Choose available download site, normally the first one is ok. Click Next
2.8 It will start downloading setup.ini which kept information about package for CygWin
2.9 In select packages page, type 'make' to search dialog. It will filter package which contain 'make' program, which are Devel and X11.
2.10 Click on 'Default' text after 'Devel' heading. Wait for a few seconds, text will be changed to 'Install'. Click on plus button '+' in front of Devel, will show program those will be installed.
2.11 Again type 'tetex' to search dialog and click on 'Default' text next to 'Text' heading. Text after 'Text' will be changed from 'Default' to 'Install'.
*note: TeTex is obsolete use texlive instead
2.12 Click Next button it will downloading the 'make' and 'tetext' program and install to your computer.
Step 3 Download Thailatex fonts from http://tug.ctan.org/tex-archive/language/thai/thailatex/
3.1 Extract this folder to C:\thailatex
3.2 Open Cygwin by go to start > Program > Cygwin Bash Shell
3.3 Browse to thailatex folder by type command
cd /cygdrive/c/thailatex
3.4 Type command
make
3.5 Type command
make install
3.6 Close Cygwin
Step 4
4.1 Go to c:\thailatex\fonts\ and copy files
Ithuni.enc , thailigs.enc to C:\Program Files\MiKTeX 2.8\dvips\base
thai.map to C:\Program Files\MiKTeX 2.8\dvips\config
thai.map to C:\Program Files\MiKTeX 2.8\fonts\map\dvips
4.2 Go to c:\thailatex\babel copy files .fd, .def, .ldf and .sty to C:\Program Files\MiKTeX 2.8\tex\generic\babel
*Tip: to copy selected file type I suggest to use window search and look for *.fd, *.def, *.ldf, *.sty in current folder to avoid mistake.
4.3 Go to c:\thailatex\fonts\ coply files (create sub-folder 'thai' for target)
to searching files using search in windows is suggestion because there are a lot of files
*.afm to C:\Program Files\MiKTeX 2.8\fonts\afm\public\thai
*.tfm to C:\Program Files\MiKTeX 2.8\fonts\tfm\public\thai
*.pfb to C:\Program Files\MiKTeX 2.8\fonts\type1\public\thai
*.vf to C:\Program Files\MiKTeX 2.8\fonts\vf\public\thai
4.4 Go to windows command line (start > run > type 'cmd')
4.5 Type command
initexmf --edit-config-file updmap
and insert text 'Map thai.map' and save file
4.6 Update Miktex , type command
initexmf -v --mkmaps -u
Step 5 Test
5.1 open notepad copy and paste below code, when 'norasi' is font name there are another font name that you can used see example http://thailatex.files.wordpress.com/2009/08/thaitest.pdf
\documentclass{report}
\usepackage[thai]{babel}
\usepackage{thswitch}
\begin{document}
\usefont{LTH}{norasi}{m}{n}
สวัสดีชาวโลก
\end{document}
5.2 Create new folder c:\testlatex
5.3 Saved file to c:\testlatex\simple.tex
5.4 Go to windows command line type
latex simple
you should got simple.dvi, double click or open it by Yap. Yap is program to view file .dvi and normally Yap was installed from Miktex package.
5.5 Type command
dvipdfm simple.dvi
now you got simple.pdf to used
Step 6 Using SWATH (Smart Word Analysis for THai) which is a word segmentation for Thai.
6.1 Download swath from http://swath.googlecode.com/files/swath.zip
6.2 Extract to C:\swath
6.3 Open notepad and type
c:\swath\swath -f latex -d c:\swath\swath < %1.ttx > %1.tex
saved as sw.bat
6.4 Renamed file c:\testlatex\simple.tex to simple.ttx. *This is convention to create file in format .ttx and convert to .tex using SWATH.
6.5 Go to windows commandline type
sw simple
6.6 Type command
latex simple
you will got simple.dvi those segment word by SWATH
Saving your time instead of using two (or more) commands each time by create batch file name thailatex.bat
c:\swath\swath -f latex -d c:\swath\swath < %1.ttx > %1.tex
latex %1
makeindex %1
bibtex %1
latex %1
latex %1
and save to C:\Program Files\MiKTeX 2.8\miktex\bin\thailatex.bat (makeindex and bibtex is another program to manage index and reference)
next time you create new filename.ttx you just type command
thailatex filename
and you will got filename.dvi
Thanks so much to
http://thailatex.wordpress.com/latex-%E0%B8%AD%E0%B8%A2%E0%B9%88%E0%B8%B2%E0%B8%87%E0%B9%84%E0%B8%A3%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%9B%E0%B8%A7%E0%B8%94%E0%B8%AB%E0%B8%B1%E0%B8%A7/miktex-25-26-with-thai/
http://www.bloggang.com/viewblog.php?id=suntrust&date=22-04-2008&group=3&gblog=1
http://ichris.ws/latex-5
http://physics3.sut.ac.th/miktexthai.html
http://linux.thai.net/~thep/
http://code.google.com/p/swath/
Monday, December 14, 2009
Convert wchar_t* to LPCSTR
wchar_t *fname;
//wchar_t name;
//wcscpy(name, fname);
//const int max = wcslen(name);
char cTemp[MAX_PATH];
sprintf(cTemp,"%S",*fname);
fp = CreateFile((LPCSTR)cTemp, ......);
From : http://forums.ps3scene.com/lofiversion/index.php/t231454.html
//wchar_t name;
//wcscpy(name, fname);
//const int max = wcslen(name);
char cTemp[MAX_PATH];
sprintf(cTemp,"%S",*fname);
fp = CreateFile((LPCSTR)cTemp, ......);
From : http://forums.ps3scene.com/lofiversion/index.php/t231454.html
Tuesday, November 24, 2009
Invert an image in OpenCV
IplImage *input, *output;
cvXorS(input, cvScalar(255), output)
http://ioctl.eu/blog/2009/05/04/opencv_invert
Subscribe to:
Posts (Atom)