2011年5月17日

2009年9月15日

Generate C++ Dll for Python

  1. download latest boost-jam from http://sourceforge.net/projects/boost/files/
  2. Unzip
  3. 以Boost.Python的tutorial為例說明
    1. 在個人的檔案夾(C:\Document And Settings\User Name)下,產生檔案user-config.jam
    2. 檔案內容
      #MSVC configuration
      using msvc : 9.0 ;

      #Python configuration
      using python : 2.6 : C:/Python ;
      (特別注意路徑的打法)
    3. 至boost python tutorial資料夾 Ex. boost\libs\python\example\tutorial\
    4. 輸入bjam
    5. 若順利,則在boost\bin.v2下,會產生dll檔及lib檔
    6. 把.dll檔、.lib檔、以及test_ext.pyd放在同個資料夾,即可使用Python呼叫

Using Boost.Python in Windows/Visual C++ 9.0

  1. 安裝Python
  2. 解壓縮Boost
  3. 設置目錄
    1. Visual Express->工具->選項->VC++目錄->顯示目錄選擇Include檔案
      • 加入Boost路徑 Ex. D:\Programming\Tools\boost
      • 加入Python Include檔路徑 Ex. C:\Python\include
    2. 加入程式庫檔
      • 加入Python Library檔路徑 Ex. C:\Python\libs
      • 加入Boost Compiler完成程式庫檔路徑 Ex: boost\bin.v2\libs\python\build\msvc-9.0\debug\threading\multi
  4. 重新建制,測試是否成功

2009年6月26日

Install Boost Spirit in Visual C++

  1. Download Boost Spirit from http://spirit.sourceforge.net/
  2. Unzipped
  3. Open Visual C++ Express
  4. Tools->Options->Projects->VC++ Directory->Show Directory with Include Files->Write in the directory of Boost Spirit

2009年5月8日

MySQL Character Set Command

SHOW NAMES 'character set'
SHOW VARIABLES LIKE 'character_set%'
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;

2009年4月3日

Java Read/Write File

Read File
private String readFile(String fileName, String fileCharacter)
{
String line = "";
try
{
FileInputStream fis = new FileInputStream(new File(fileName));
// java.io.FileNotFoundException
BufferedReader br =new BufferedReader(new InputStreamReader(fis,fileCharacter));
// java.io.UnsupportedEncodingException
   
// java.io.IOException
while(br.ready())
line += br.readLine();

    br.close();
}
catch (FileNotFoundException e)
{
System.out.println(e.getMessage());
}
catch (Exception e)
{
System.out.println(e.getMessage());
}

return line;
}
Write File
private void writeFile(String fileName, byte[] writeText)
{
try
{
// Create file
File file = new File(fileName);
FileOutputStream fout = new FileOutputStream(file);
fout.write(writeText);
fout.close();

}
catch (Exception e)
{
//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}