2008年12月25日 星期四

Make SDL program to have console output instead of stdout.txt and stderr.txt under Windows

SDL_Init() routes stdout and stderr to the respective files. You can revert this by adding the following lines after the call to SDL_Init in your code:

freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );

* If that doesn't work try adding these 2 lines at the very beginning of your code (SDL_Init wrapper or in top of your main)

int main( int argc, char *argv[] )

2008年12月18日 星期四

Boot a Virtual Machine from command and Control it through Remote Desktop Protocol on Ubuntu

1. we will need VBoxHeadless command to run virtual machine in background, free version of virtualbox in ubuntu repository doesn't have it. so we need to install official version
from http://www.virtualbox.org/wiki/Linux_Downloads

complie VirtualBox Modules

sudo /etc/init.d/vboxdrv setup

2. set up your virtual machine completely through GUI, Applications -> System Tools -> Sun xVM VirtualBox. if you can't find the icon, just relog desktop environment after installed

change Settings -> Remote Display -> Enable VRDP Server
Authentication Method = Null

its unsafe but we will set something for security on windows later

3. command-line usage

start a virtual machine

VBoxHeadless -startvm "name"
or
VBoxHeadless -startvm "uuid"

poweroff a virtual machine

VBoxManage controlvm "name" acpipowerbutton

show info about a running virtual machine

VBoxManage showvminfo "name"

4. your login screen of guest windows has a shutdown button, it means anyone who connect to the right port can shutdown your machine. we have to hide it by changing the registry below

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\shutdownwithoutlogon -> 0

5. the last thing I must remind is remember to logout / switch user then windows will back to login screen. if you are afraid of forgetting to do so, try set screensaver with password protection. nobody can kick you if you are connecting and occupying the port.

2008年12月17日 星期三

Play restricted formats on Ubuntu

1. the package, ubuntu-restricted-extras supports for mp3 playback and decoding, various other audio formats, microsoft fonts, java runtime environment, flash plugin, lame, and dvd playback.

sudo apt-get install ubuntu-restricted-extras

2. about real media files like .rm .rmvb, you'll need w32 codecs because there is no native support in linux

adding the repositories

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list --output-document=/etc/apt/sources.list.d/medibuntu.list

3. add the gpg key

sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

4. install codecs

sudo apt-get install w32codecs

5. to play encrypted dvd, the libdvdcss2 package is essential. it is a simple library designed for accessing dvd without having to bother about the decryption

sudo apt-get install libdvdcss2

2008年12月13日 星期六

VirtualBox Open Source Edition on Ubuntu

1. install open source edition of virtualbox and its module

sudo apt-get install virtualbox-ose virtualbox-ose-modules-generic

2. from console output or /var/log/apt/term.log, you can see there is no matching virtualbox-ose module for kernel 2.6.24-22. virtualbox-ose-modules-generic is linked to kernel 2.6.24-21 so apt-get installs linux-image-2.6.24-21-generic automatically.

in short, we have to change default boot number of grub to kernel 2.6.24-21

sudo vi /boot/grub/menu.lst
--
default n

3. scim conflicts with virtualbox-ose. it results keyboard is locked in both host and guest os when you press key or mouse which is captuered in guest os. below is the solution

sudo apt-get install scim-bridge-client-qt
im-switch -z en_US -s scim-bridge

4. reboot then done

5. before sharing folders between host and guest, you must install Guest Additions. once installed it, go to Devices -> Shared Folders.. to set your sharing folders. if guest os is windows, run

net use x: \\vboxsvr\FolderName