Saturday, July 4, 2009

Ruby and OpenGL

I've decided to learn yet another new language, and this time the language of choice is Ruby. I've also been looking into eventually someday building my own little simple tile game engine which primary purpose will be a platform for AI testing and researching.

However I've never quite gotten the light bulb moment for the cognitive leap from simple OpenGL demo programs and an full-blown game/3d Engine. At-least till I finally found a few tutorial on actually building an functional 3d engine in Perl, and another simple C++ based tutorial on creating a simple 3d Tiling engine.

Once that light bulb came on in my head I've been working ever since on slowly building up the actual 3d Tiling engine in Ruby.

I figured I could kill three birds with one stone; learn Ruby, learn some more OpenGL, and also learning how to use the Ruby's C ext binding stuff for re-implementing the slow part of the engine in pure C/C++.

I've even posted up the source code for everyone to see at GitHub. Be careful its a work in progress and probably messed up massivly.

Anyway without additional ados here's some pictures of the latest render of the tiles in the 3d Engine.

Thursday, January 29, 2009

Hostname - DNS

Hostnames has always fasicated me, there are so many scheme out there for naming computers, and it ranges all the way from various fancy names to the useful but mundimate systemic naming schemes.

I have been naming my machines after forgotten realms cities, and realms that are more or less the lands of the wizards such as unther.

Anyway so far I have one laptop, one desktop, then one embedded router built with a Via C7 processor, and a tiny OpenVZ server machine running an Intel ATOM processor, and an old 366 mhz dell laptop serving as a server for a total of five physical machines. Then on the OpenVZ machine, there currently is two container running at the moment, but I'm planning on expanding it to about a dozen.

Anyway the names are the following:
amrutlar -- Router
unther -- Old laptop server, currently running cacti, dns, dhcp, ntp, logging server, and a few other daemons
mulhorand -- WRT54G Wifi AP
halruaa -- New server with OpenVZ
miyeritar -- OpenVZ Logging server, will latter expand to logging monitor and processing
raumathar -- OpenVZ Email server for the entire domain
imaskar -- My desktop
netheril -- My IBM laptop

Then there are a few new hostnames I'm thinking of allocating out such as:
yggdrasil
narfell
jhothun
coramsham
jhaamdath
athalantar
eaerlann
xothaerin
cormanthyr
guge
ilythiir
jastaath
aryvandaar
keltormir
illefarn

Wednesday, January 28, 2009

Protocol design is Hard!

Its surprisingly hard to design a reliable light weight protocol from the ground up, so I wanted to give kudos to the group of peoples who designed some of the earliest internet protocols such as IP, TCP, UDP, and etc... Its amazing how these protocol has been extended and reused over again for over thirty years, give or take a few years.

Anyway for my Senior Project (Software Engineering) I'm part of a team that is responsible for implementing and designing a "Workstation" API and the micro-code that will be running on a Freescale micro-controller on the robot that another engineering department borrowed to us for the Project.

Anyway I'm having to create a simple and reliable as possible protocol for communicating over any point to point connection from the workstation to the computer, which includes wireless, serial, and possibly in the future other connection options. Anyway due to the nature of wireless and serial connection, there is a decent chance of the data arriving at the destination scrambled or missing chunks of information, so my current struggle is on how to make sure that the header interpreter does not mis-interpret the data for a header. I've figured out a way of dealing with some degree of corruption by including a simple checksum.

One of the suggestion by one of my team mate is to ensure that all of the header values be in x-y range, while the data is in y-z range so there's no chance of mixing them up, but I'm not quite sure if I like that solution, but it could work, but still it fails to deal with the corruption issue.

Saturday, December 27, 2008

Support Wikipedia

Since Wikipedia has been such an awesome resource, I donated 20 dollars to Wikipedia. Sure it does have its own flaws and issues but it has been an excellent starting point on my own research and so forth.

Wikipedia Affiliate Button

Updated the post to use the square button

Monday, December 8, 2008

Update to the "Japanese IMS support in Gentoo"

This post is an update to the original "Japanese IMS support in Gentoo" post, this time I got assistance from zsitvaij on the Gentoo forums on getting SCIM to work with Qt4 and he also recommended me to ditch SCIM-UIM.

Due to the lack of time and the unstable nature of the packages I'm not going to implement this upgrade to my SCIM system, until I have time, but without additional adios here's the link to the post.

Wednesday, November 12, 2008

CJK-LaTeX Support

This post will document my adventure in getting Japanese support to work with LaTeX.

To begin, make sure you are using the latest version of LaTeX, at this time it would be TeXLive-2007/2008. I had to remove the old tetex installation which is explained in the TeXLive Migration Guide on the Gentoo project site. Just make sure that the cjk USE flag is enabled and that you have also added "ja_JP ja" to your LINGUAS var in /etc/make.conf which will then compile the TeXLive system with CJK and Japanese support included. Beware its a very large set of packages so it may take a while to download on a slow connection.

Install Cyberbit for X11: (This step is optional)
1) Download the Cyberbit font from Cyberbit.ZIP then unzip it to /tmp/ directory.

2) Execute the following commands:
sudo mkdir /usr/share/fonts/ttf-cyberbit
sudo chown root:root /usr/share/fonts/ttf-cyberbit
sudo cp /tmp/Cyberbit.ttf /usr/share/fonts/ttf-cyberbit/cyberbit.ttf
sudo mkfontdir /usr/share/fonts/ttf-cyberbit

3) Update the /etc/X11/xorg.conf to include the new font directory.

4) Restart the X11 server.

5) Finally update the font cache via sudo fc-cache -vf command.

Prepare Cyberbit for installation:
1) Create a temponary folder in /tmp directory and copy the cyberbit.ttf font from the previous step into that folder and rename it to cyberb.ttf.

2) Copy the subfonts.pe file, which can be found in the /usr/share/textmf/scripts/subfonts/ directory, to the temponary directory that was made in the previous step.

3) Download the Unicode.sfd file from this post in which the author has extended the file's Unicode listing to support more characters. Anyway the file that is downloaded will have the wrong extension, rename the .obj part of the file to .bz2 then bunzip the file to the temponary directory made in step 1.

4) To generate all of the needed files for LaTeX fontforge must be installed. To install it execute emerge media-gfx/fontforge

5) Once fontforge has been installed execute this command to generate all of the needed files, however be aware that depending on the computer's speed it could take several hours!
fontforge -script subfont.pe cyberb.ttf cyberb Unicode.sfd

6) Once all of the needed files has been generated by fontforge, create the cyberb.map file by executing this command:
for i in *.pfb
do
echo "$(basename $i .pfb) $(basename $i .pfb) <$i" >> cyberb.map
done


7) This step involves the creation of several directories, so here's the list of directories to generate:
mkdir -p ~/texmf/fonts/{afm, tfm, type1}/cyberb
mkdir -p ~/texmf/fonts/map/dvips/cyberb


Now copy all of the files generated by fontforge into the proper directory:
cd
cp *.afm ~/texmf/fonts/afm/cyberb/
cp *.tfm ~/texmf/fonts/tfm/cyberb/
cp *.pfb ~/texmf/fonts/type1/cyberb/
cp cyberb.map ~/texmf/fonts/map/dvips/cyberb/


8) Create a ls-R database in the ~/texmf/ directory so that LaTeX can find all the files that it needs to by executing texhash

9) Finally update the maps by executing updmap --edit which will open the mapfile in your $EDITOR which in my case is vim. Once the mapfile is opened in the $EDITOR add at the bottom of the file "Map cyberb.map" without the quotation then save the file and the command should automatically generate/update the mapping database.

10) Create a testing CJK LaTeX file to ensure that everything has been setup and installed properly, here's an example:
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{song}
オバマわたし
\end{CJK*} (this is a test)
\end{document}

Execute pdflatex on the test LaTeX file to generate a pdf, then open the pdf to see if the CJK characters were generated properly and are rendering properly in the pdf file. There should be no error on the output.

Optional:
If the ~/texmf/ in the home directory is bothersome, or if its desired to have CJK-LaTeX support for all of the users on the system, then the only part that has to be changed is to replace the ~ with /usr/share/texmf-site/ which is the site-specific directory for all of the extra TeXLive files that are specific to this computer. And also will need to execute the texhash and replace the updmap --edit command with updmap-sys --edit and run both command as root.


Update:
There has been some new information on how to do it properly in the Gentoo way, and it is instead executing texhash, and running updmap --edit, or updmap-sys --edit. It is better to instead create a new file named texlive-custom.cfg in the /etc/texmf/updmap.d/ directory and put "Map cyberb.map" in that said file then run texmf-update which will take care of generating all of the ls-R files, and updating the font map.

However one issue is that for the site wide settings to work it will be needed to wipe the .texmf-config/ and .texmf-var/ directory out of the user's home directory to make LaTeX pick up on the new system-wide settings.

Resources:

Japanese in LaTeX documents and in Unicode with MacTeX
cjk-latexでCyberbitフォントを利用してPDFを作成するテスト
[Cjk] full Unicode support added
TeX Live 2007 guide
TeXLive FAQ

Wednesday, October 22, 2008

Rikaichan

Rikaichan is a very nifty plug-in for Firefox, it enables you to hover your mouse over a kanji or a phase in katakana and it will pop up a tooltip box over the website with the definition of the kanji or the katakana phase. There is two dictionary, one which is the kanji dictionary, and the other is the Names in katakana, such as Toyota (トヨタ自動車株式会社).

So far the plug-in supports Japanese to English/German/French/Russian dictionary.

Without additional ados here's the link to Rikaichan: Rikaichan