Djihed Afifi

Archive for September, 2006

tclgeoip: GeoIP TCL extension

12th September 2006

GeoIP is a technology developed by MaxMind for geographical and organisational lookup of IP addresses and hostnames. Maxmind provides an LGPL licensed API written in C. The API pulls the data from database files. MaxMind gets its income by selling updated at frequent time intervals.

Many packages have been built on top of the C API to allow GeoIP calls from different languages, like PHP (frequently used in CMS’s) and even an Apache module.

I wrote a TCL extension on top of this C API. It has been accepted by MaxMind and is sitting here. It currently compiles without tweaking on Solaris systems. There will be an update soon to make it compile on most other UNIX system automagically.

Note that you need Tcl dev files and the GeoIP C API to compile this.

Posted in Linux, tclgeoip | 2 Comments »

The bash clown prompt

8th September 2006

My favourite UNIX shell is bash, or the Bourne Again Shell. Its syntax is neat and clean, I find it cleaner than most other shells, and it is available on most UNIX variants. its customisability is also very good. I’ve customised the default prompt to a colourful joyful and informative message. I call it the clown prompt. Here is a screenshot of how it looks like in putty, note that I have slightly changed the blue colour on putty to make it more readable.

Clown Prompt on Putty

To make it the default prompt, copy these lines to the end of your ~/.bashrc file. If there is not one, create it.

# Term settings
TTYTEMPNAME=$(tty)
CHOMPED=${TTYTEMPNAME:5}
PS1="[33[1;33m][[33[1;32m]t[33[1;33m]]
[33[1;33m][[33[1;31m]u[33[1;33m]:
[33[1;31m]h[33[1;33m]]
[33[1;33m][[33[1;36m]$CHOMPED
[33[1;33m]:[33[1;36m]#[33[1;33m]]
[33[1;33m][[33[1;35m]w[33[1;33m]]
[33[1;34m]#[33[0m] "

The first two lines grab the name of the current tty, line 3 prints the time, lines 4,5 print the username and the name of the machine, lines 6,7 prints the name of the tty along with the command number, line 8 prints the current working directory. I find all of this information valuable offhand sometimes. To apply changes, source your ~/.bashrc file by issuing: source ~/.bashrc

For peace of mind, insert this line into your ~/.bashrc file, after the previous code. It solves a problem where long lines would wrap to the same current line.

shopt -s checkwinsize

Posted in Linux | 3 Comments »

poc

5th September 2006

poc stands for PO check. PO (for Portable Object) is a file standard used to compile translations.

The script checks these files individually one by one using msgfmt, and commits them (using cvs) with the commit message being the statistics output by msgfmt, it was wrote for the Arabeyes translation team.

Get poc.

Posted in Tools | 1 Comment »

Lexicons

4th September 2006

Arabising all terms from English to Arabic individually is cumbersome: it’s waseful in terms of resources and it opens the door wide to repetitions and mistranslation. A Better solution would be to translate terms collectively: collecting terms that relate to a particular subject by brainstorming and observation, thus forming lexicons, or probably more accuratly mini-lexicons. After making a lexicon, we could ‘’mass'’ translate it, in other words, collectively translate the words by relating the meaning of each set to the most suitable counterparts, while observing small differences in the meaning of each word. This amongst various other techniques can help us to write more accurate and understandable translations.

According to Chambers, here is the definition of a lexicon:

1 a dictionary, especially one for Arabic, Greek, Hebrew or Syriac. 2 the vocabulary of terms as used in a particular branch of knowledge The word…

This is comparable to مُعْجَم in arabic. Albeit it’s a small one for each of the topics we want. An example would the one I used in the the previous article, the lexicon of exiting an application or a process, comprising of: lose, quit, exit, kill, terminate, end, finish, go out, stop, shut down, leave, discontinue, cancel, refuse, skip, break, abandon, give up, suspend, stand by, hibernate, crash. The list can go on and is still open.

There will be a coherent list of lexicons in the wiki.

Posted in Arabisation | No Comments »