- Open "Control Panel"
- Switch to "Category View"
- Open "Regional and Language Options"
- Switch to "Languages" tab
- Click "Install files for East Asian languages", and click "Apply".
- Switch to "Advanced" tab
- In the combo box "Language for non-Unicode programs", select "Chinese(PRC)"
- Switch to "Regional Options" tab
- Select "Chinese(PRC)" and "China" respectively for each of the two combo boxes.
- Click "OK"
Jun 29, 2009
解决英文版Windows的中文乱码问题
Jun 28, 2009
DocView Mode for Emacs
The wiki page.
Shift-+ to enlarge the displaying (.pdf)
C-c C-c to switch between docview mode and text mode
Shift-+ to enlarge the displaying (.pdf)
C-c C-c to switch between docview mode and text mode
Jun 23, 2009
Make Emacs Warns for Long Lines
On Linux, we can use function font-lock-set-up-width-warning to tell Emacs warning for too long lines in source code:
(add-hook 'c++-mode-hookOn Mac OS X, above method fails. However, With Carbon Emacs or Aquamacs, we can do as follows:
'(lambda () (font-lock-set-up-width-warning 80)))
(add-hook 'java-mode-hook
'(lambda () (font-lock-set-up-width-warning 80)))
(add-hook 'python-mode-hook
'(lambda () (font-lock-set-up-width-warning 80)))
; for CarbonEmacs (MacOSX)An easier solution for 80-column-rule is lineker. The usage is pretty simple (tested on my IBM T60p, Emacs for Windows): add the following into your .emacs file.
(defun font-lock-width-keyword (width)
"Return a font-lock style keyword for a string beyond width WIDTH
thatuses 'font-lock-warning-face'."
`((,(format "^%s\\(.+\\)" (make-string width ?.))
(1 font-lock-warning-face t))))
(font-lock-add-keywords 'c++-mode (font-lock-width-keyword 80))
(font-lock-add-keywords 'objc-mode (font-lock-width-keyword 80))
(font-lock-add-keywords 'python-mode (font-lock-width-keyword 80))
(font-lock-add-keywords 'java-mode (font-lock-width-keyword 80))
(require 'lineker)
(add-hook 'c-mode-hook 'lineker-mode)
(add-hook 'c++-mode-hook 'lineker-mode)
GCC Does Not Support Mutable Set/MultiSet Iterator
Although C++ STL standard requires that std::set and set::multiset supports both constant iterator and mutable iterator, but libstdc++ supports only the constant one. In /usr/include/c++/4.0.0/bits/stl_set.h (as well stl_multiset.h), we can see the following iterator typedefs:
// _GLIBCXX_RESOLVE_LIB_DEFECTSThis would lead many STL algorithms incompatible with set and multiset. For example, the following code does not compile in GCC 4.0.x:
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
setIt is notable that Microsoft Visual C++ 7.0 and later versions are more restrictive to the STL standard on above issue. Above code works with Visual C++.myset; // or multiset myset;
*myset.begin() = 100; // fails due to begin() returns const_iterator
remove_if(myset.begin(), myset.end(), Is71()); // remove_if invokes remove_copy_if, which requires mutable myset.begin().
Jun 22, 2009
Fast Approximate of 2D Water Ripples
Here is a very fast approximation algorithm. The author is really good at observing and finding highly effective approximations, in this case, the value of sine(x+o) is proportional to sine(x), where o is a small phase offset.
Jun 21, 2009
Useful Documents for CUDA Development
- Official Programming Guide from NVidia.
- CUDA Programming, a slides from Johan Seland.
Make CUDA Works on MacBook Pro
- Download and install CUDA toolkit and CUDA SDK.
- When installing the CUDA toolkit, click the Customize button on the Installation Type panel of the installer. Then be sure that CUDAKext is selected for installation. If we do not do this, CUDA applications will complain "no CUDA capable device".
- After installing add the following to .bash_profile.
export PATH=/usr/local/cuda/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH - After installing the CUDA SDK,
cd /Developer/CUDA/lib
Otherwise, we will get the following linker error when building CUDA applications:
ranlib *.lib
ld: in ../../lib/libcutil.a, archive has no table of contents - Build CUDA sample applications:
cd /Developer/CUDA
The result application binaries will be installed to /Developer/CUDA/bin/darwin/release.
make
A Good Xcode/C++/QuickDraw Tutorial
Xcode C++ Tutorials is a C++ tutorial using Xcode as the development tool and QuickDraw (the 2D graphics engine of Carbon under Mac OS X) as the basic framework. It is good for C++ beginners using Mac OS X, as well developers with experience with other platforms.
Jun 20, 2009
Mix Intel IPP with OpenCV
http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-open-source-computer-vision-library-opencv-faq/
Build OpenCV under Mac OS X
Install OpenCV on Mac OS X
- Install Xcode on Mac OS X computer.
- Download OpenCV source package (for Linux) from SourceForge.
- Unpack the source package
- Generate Makefile.in/am
autoreconf -i --force - Configure
./configure --prefix=/usr/local --with-python --with-swig - Build and test building result
make
make check - Install
make install - Building applications
g++ -o capcam main.cc -I /usr/local/include/opencv -L/usr/local/lib -lcxcore -lcv -lcvaux -lhighgui -lml
Package Management under Mac OS X
Under Windows, we can use Cygwin to manage software packages. Under Mac OS X, we can use Macports. Download and install the Macports dmg file, open a terminal window, and type commands like:
Note: To make Macports knows the most recent package list, type the following commands regularly:
Note: After installing Macports, open a new terminal windows (program), which will use the system environment variables newly updated by the installation program. Using a terminal window which had been opened before Macports installation will leads to an error complaining cannot find 'port'.
sudo port install cmakeMacports will download the source package and compile it for you.
Note: To make Macports knows the most recent package list, type the following commands regularly:
sudo port -v selfupdate
Note: After installing Macports, open a new terminal windows (program), which will use the system environment variables newly updated by the installation program. Using a terminal window which had been opened before Macports installation will leads to an error complaining cannot find 'port'.
Jun 18, 2009
ActionScript 3.0 Mode for Emacs
EmacsWiki suggests an actionscript mode which can be downloaded from a post at PetTomato. After download the .el file, I added the following lines into my .emacs configuration file. This works for my Aquaemacs for Mac OS X.
(load-file "~/.emacs.d/actionscript-mode.el")
(autoload 'actionscript-mode "javascript" nil t)
(add-to-list 'auto-mode-alist '("\\.as\\'" . actionscript-mode))
Jun 14, 2009
Gmsh: a three-dimensional finite element mesh generator
Gmsh is an automatic 3D finite element grid generator with a built-in CAD engine and post-processor. Its design goal is to provide a simple meshing tool for academic problems with parametric input and advanced visualization capabilities.
Jun 13, 2009
Fullscreen Mode of Aquamacs
We can type Command-Shift-Return to invoke the function aquamacs-toggle-full-frame, which switches between fullscreen mode. For your customization skills for Aquamacs, refer to http://www.emacswiki.org/emacs/CustomizeAquamacs.
Robust Ray Intersect with Triangle Test
Tomas Moller and Ben Trumbore proposed a robust algorithm in their paper, Fast, Minimum Storage Ray/Triangle Intersection. A reference implementation of this algorithm can be referred to as http://www.lighthouse3d.com/opengl/maths/index.php?raytriint, which implements the non-culling branch presented in that paper.
Alt and Meta in Aquamacs
The default Meta key in the Aquamacs distribution is Option (and also Esc). If this is unusable for you (your fingers are too well trained on other platforms), you can either press Apple-; (Options → Option Key → Option Key for Meta) to switch to Esc only.
For other interesting things about Aquamacs, refer to Aquamacs FAQ.
Jun 10, 2009
Jun 9, 2009
Password-less Login Using SSH
Consider we want to login from a MacBook Pro (mbp) to a remote Linux machine (tsingyi), where both computers have OpenSSH installed. In order to make tsingyi trust mbp, we use RSA cryptographic method to generate a public and a private key for mbp, which will be used to identify mbp during login.
To generate the pair of keys, on mbp, type
Here we are. We should be able to ssh to tsingyi from mbp without typing password now.
To generate the pair of keys, on mbp, type
ssh-keygen -t rsaAccept all default answers, and we get two files:
~/.ssh/id_rsa --- the private keyNow, copy the public key file to tsingyi by typing following command on mbp:
~/.ssh/id_rsa.pub --- the public key
scp ~/.ssh/id_rsa.pub wyi@tsingyi:/home/wyi/.ssh/id_rsa-mbp.puband add the public key of mbp to ~/.ssh/authorized_keys of tsingyi by typing following command on tsingyi:
cat ~/.ssh/id_rsa-mbp.pub >> ~/.ssh/authorized_keys
Here we are. We should be able to ssh to tsingyi from mbp without typing password now.
Buld OpenGL/GLUT Applications under Mac OS X
Xcode comes with all what we need to build a Cocoa application with OpenGL and GLUT and GCC. So, first of all, we need to install Xcode.
Writing Code
An GLUT C/C++ program for Mac OS X should include three header files:
Building Using GCC
The command line using GCC to build a program main.c is as follows:
Building Using Xcode IDE
We can also manage our OpenGL/GLUT projects using Xcode IDE. To create a project, select the project type of "Cocoa Application". To add/edit the code, remove the auto-generated main.m, add a new main.c, and write our code into main.c. To specify the frameworks in IDE, right click the project and choose "Add Exisiting Frameworks" to add OpenGL and GLUT.
Writing Code
An GLUT C/C++ program for Mac OS X should include three header files:
#includeNote that the locations of these header files in Mac OS X differs from where they are in Linux and Windows (e.g., GL/glut.h)// Header File For The OpenGL32 Library
#include// Header File For The GLu32 Library
#include// Header File For The GLut Library
Building Using GCC
The command line using GCC to build a program main.c is as follows:
gcc -framework GLUT -framework OpenGL -framework Cocoa main.c -o learningIt is notable here that MacOSX uses the concept of so called frameworks. Instead of adding include paths and library names yourself, you add a framework to your compiler call. This is a MacOSX specific extension to gcc.
Building Using Xcode IDE
We can also manage our OpenGL/GLUT projects using Xcode IDE. To create a project, select the project type of "Cocoa Application". To add/edit the code, remove the auto-generated main.m, add a new main.c, and write our code into main.c. To specify the frameworks in IDE, right click the project and choose "Add Exisiting Frameworks" to add OpenGL and GLUT.
Jun 8, 2009
Open Source Software on Mac OS X
http://www.opensourcemac.org/
http://www.freemacware.com/
http://www.linuxbeacon.com/doku.php?id=opensourcemac
http://www.freemacware.com/
http://www.linuxbeacon.com/doku.php?id=opensourcemac
Jun 7, 2009
Crystalization
- Stochastic and Deterministic Simulation of Nonisothermal Crystalization of Polymers
- The Structure of Crystals.
Subscribe to:
Posts (Atom)