Saturday, September 20, 2008

ViEmu commands

If you use Ctrl-V or Ctrl-Q to enter visual block mode, and select a range, you can key in any operator directly and it will be applied to the range. Here are some samples:

d Deletes the block (and copies it to the default register for later pasting)
y Yanks the block (copies to the default register)
gU Makes all characters uppercase
gu Makes all characters lowercase
~ Toggles the case of all characters
c Change - deletes the region, enters insert mode, and then repeats the string input in all lines (if we were initially in block visual mode)
etc...

The docs have a complete list of ViEmu-supported operators.

'x' also works to delete a visual region.

Thursday, August 7, 2008

pthreads

To compile C++ code with pthread library on Linux

g++ --pthread main.cpp

Thursday, January 31, 2008

Making Microsoft Natural Ergonomic Keyboard 4000 Working

If your Windows XP doesn't recognize this keyboard saying something like "Cannot install this hardware" because of can't find the software etc, and you are absolutely certain that your USB ports (and HID-Human Interface Device drivers/services) are all working, then you may want to try what I did below.

At first I thought the keyboard was faulty, because all my other USB devices had no troubles whatsoever. But I decided to test and plugged it into my laptop which also runs Windows XP. Surprisingly it had no trouble at all to detect and install the right driver for this keyboard.

What I ended up doing was copy the working registry entry on my laptop to my desktop. The registry entry is under something like: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\
Vid_045e&Pid_00db\5&2e32ec62&0&1

One issue is the USB port you use on the desktop will definitely be different than the one you use on your laptop, so figure out which entry it's under and change the "working" entry's key name to the "non-working" entry's name and delete the "non-working" entry from the registry.

You may need to change the permission on these entries to Full Control to be able to delete them. Once that's done, unplug the keyboard and plug it back in, Windows XP should detect it and start to install the HID driver.

BIG WARNING: EDITING YOUR REGISTRY IS VERY RISKY, YOU MAY NOT BE ABLE TO BOOT BACK INTO WINDOWS IF YOU MESS SOMETHING UP. FIND SOMEONE WHO KNOWS WHAT THEY ARE DOING TO HELP YOU OR JUST USE ANOTHER KEYBOARD WITHOUT THIS PROBLEM.

Wednesday, January 30, 2008

VTK 5.04, libpng, and many others

VTK:
  • follow instruction on how to build VTK from source
  • get CMake
  • run CMakeSetup.exe from VS command line env
  • set the configurations
  • open the generated solution file and build from there
VTK python:
  • after compile and build, use the INSTALL project in the VS solution to install it to configured directory
  • to have vtkpython find these vtk packages add this to env:
    • PYTHONPATH=D:\VTK\bin;D:\VTK\lib\site-packages
    • rename all vtk*python.dll to vtk*python.pyd (python 2.5 only recognizes *.pyd files as packages)
libpng
  • convert solution files current VS
  • zlib project in the solution doesn't work well, just remove it
  • update zlib include and lib path in libpng and pngtest project config
libtiff 3.8.2
  • open nmake.opt and update the path to zlib and libjpeg
  • then open up VS command line env go to libtiff dir run "nmake /f makefile.vc"
  • read install instructions from the lib online for windows
libjpeg
  • read the install doc, basically copy jconfig.doc to jconfig.h then run "nmake /f makefile.vc"
zlib
  • if you use the prebuilt binary lib from zlib, put the dll file in the system directory so these libraries can find it

Monday, January 28, 2008

Building Boost 1.34.1 with Visual Studio 2008

At this point neither (CGAL 3.3.1 and Boost 1.34.1) provide project files for VS 2008 to compile them. Here are what I did to get them compiled. The main problem is they don't recognize VS 2008 version number in their compiler detection code. We just need to patch them.

Get the patch here:
http://stlab.adobe.com:8080/@md=d&cd=//adobe_source_libraries/tools/&c=KFx@//adobe_source_libraries/tools/boost_1_34_1_patch_01.txt?ac=22

Then use GNU patch tool to boost_1_34_1_patch_01.txt

Actually, Adobe's fix is more than what you probably needs, someone else made a simpler patch here:

http://www.mythicsoft.com/blogs/post/Compiling-Boost-with-Visual-Studio-2008-(VS2008).aspx

However, it's not complete. You may get errors from the signal library in boost, get my modified patch here:

http://www.box.net/shared/qxvyt41s0g

Run VS command line environment and follow build instruction here:
http://www.boost.org/more/getting_started/windows.html

Run with: bjam -a --build-dir=../boost-build --toolset=msvc stage

Sunday, January 27, 2008

Perforce SCM Failed To Load in Visual Studio 2008

This was odd but I found the cause: Qt dll conflicts.

When I tried to load source control in VS 2008, Perforce failed to load, without tell anything reason why.

After poking around and found no solutions on Google. I looked at one of the installation notes (sccpluginnotes.txt):

(Bug #14942)
P4SCC.initialization process fails with "Unspecified error" message due
to multiple QT dll conflicts found in the system path.
Workarounds:
Place the Perforce installation directory first in the system path
or rename or move the non-Perforce QT dlls.
So I moved perforce path to the first in the PATH variable, and it worked again!

Monday, January 7, 2008

Compileing CGAL 3.3 with Visual Studio 2008

This appears to be a pain in the ass, but I suppose it could have been worse.

Apparently, the hardest part is to get GMP compiled correctly. These are ran under cygwin.

Static linked debug version (see: http://gmplib.org/manual/Build-Options.html)
./configure --prefix=/d/gmp --enable-alloca=debug --enable-assert --disable-shared CFLAGS=-g ABI=32
Static linked release version
./configure --prefix=/d/gmp --disable-shared ABI=32 --enable-alloca=malloc-reentrant
Where /d/gmp is the install location on D:/ drive

Building mpfr

- in cygwin apply patches to version 2.3.0 (in source dir):
patch -N -Z -p1 < ../patches

- in msys
Release:
./configure --prefix=/d/mpfr-static-release --with-gmp-include=/d/gmp-static-release/include --with-gmp-lib=/d/gmp-static-releas
e/lib --with-gmp-build=../gmp-4.2.2-static-release --disable-shared

Debug
./configure --prefix=/d/mpfr-static-debug --with-gmp-include=/d/gmp-static-debug/include --with-gmp-lib=/d/gmp-static-debug/lib
--with-gmp-build=../gmp-4.2.2-static-debug --disable-shared CFLAGS=-g --enable-assert --enable-alloca=debug

Rename all the *.a files to *.lib.

Sunday, January 6, 2008

Setting up Cygwin and rxvt, tcsh, etc.

Create rxvt.bat:
@echo off
d:
chdir d:\cygwin\bin
set EDITOR=vim
set VISUAL=vim
set CYGWIN=codepage:oem tty binmode title
rxvt -e tcsh -l
In home directory, create a file ".Xdefaults", this is the configuration rxvt reads:
! ~/.Xdefaults - X default resource settings
Rxvt*geometry: 128x64
!Rxvt*borderColor: Blue
!Rxvt*scrollColor: Blue
!Rxvt*troughColor: Gray
Rxvt*scrollBar: True
Rxvt*scrollBar_right: True
Rxvt*font: -*-lucidatypewriter-medium-r-*-*-12-*-*-*-*-*-*-*
Rxvt*SaveLines: 2000
Rxvt*loginShell: True

Rxvt*background: #333333
Rxvt*foreground: #efefcf
!Colors
! Black
Rxvt*color0: #5A5A5A
Rxvt*color8: #3e3e3e
! Red
Rxvt*color1: #FF4747
Rxvt*color9: #FF6767
! Green
Rxvt*color2: #AFC81C
Rxvt*color10: #bFC81C
! Yellow
Rxvt*color3: #FDD338
Rxvt*color11: #F4D461
! Blue
Rxvt*color4: #619AF4
Rxvt*color12: #5496FF
! Purple
Rxvt*color5: #5F5A90
Rxvt*color13: #826AB1
! Cyan
Rxvt*color6: #47E0FF
Rxvt*color14: #2ED9FB
! White
Rxvt*color7: #FFFFFF
Rxvt*color15: #DEDEDE
! eof
Create .cshrc:
##### aliases #####
alias ls 'ls --color=auto';
alias ll 'ls -l';
alias dir 'ls --color=auto --format=vertical';
setenv PATH ".:${PATH}"


if ($?prompt) then
##### sets the prompt #####
set prompt = "[%n@%m:%c3]> "
endif
Configure bash with .bashrc:
set -o notify
export HISTCONTROL=ignoredups
alias less='less -r'
alias rm='rm -i'
alias whence='type -a'
alias ls='ls -F --color=tty'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
# set a nice looking prompt:
PS1='\u@\h:\W\$ '