Information wants to be free...

OpenTTD music files in other formats.

OpenTTD is a multi-platform clone of the classic game Transport Tycoon.

Normally, the original midi files are used, and requires a midi player to play the music. The default midi player is "timidity", which produces excellent sound, but seems to use a lot of CPU, so I want to use something else.

It is actually possible to use other formats (and players) than midi, due to the way the music system is currently implemented in OpenTTD. When a music track is started; OpenTTD fork()s and starts the music player as a separate process with the music filename as an argument.

I have successfully managed to use "ogg123" (part of the vorbis-tools package from xiph.org) to play the music files, by converting all the midi files to Ogg Vorbis format and perform a single configuration change. In the configuration file "openttd.cfg", there is a section named "[music]", where a option named "extmidi" resides. Simply change the option value to "ogg123" or the name of the player you want to use. When converting the midi files to a different format, make sure the filenames of the new files are exactly the same as the old ones.

I tested this with OpenTTD version 0.5.3 under Linux.

Topic: Configuration, by Kjetil @ 31/12-2007, Article Link

Leetspeak Converter

You can never have access to enough leetspeak converters/generators. That's why I have written one in C. This one works as a filter; reading from standard input and writing to standard output. Some randomization code is included since characters can be written in many different ways.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char *leet[26][5] = {"4", "/\\", "@", "/-\\", "^",
                     "8", "13", "|3", "!3", "(3",
                     "[", "<", "(", "{", "",
                     ")", "[)", "I>", "|>", "|)",
                     "3", "&", "", "", "[-",
                     "|=", "|#", "/=", NULL, NULL,
                     "6", "9", "(_+", "(y,", "(_-",
                     "#", "/-/", "[-]", "]-[", ")-(",
                     "!", "|", "]", NULL, NULL,
                     "_|", "_/", "</", "(/", NULL,
                     "X", "|<", "|{", NULL, NULL,
                     "1", "1_", "|_", NULL, NULL,
                     "|v|", "]V[", "|\\/", "/\\/\\", "^^",
                     "/\\/", "[\\]", "<\\>", "{\\}", "^/",
                     "0", "()", "[]", "", NULL,
                     "|*", "|\"", NULL, "|7", "", "",
                     "()_", "0_", "<|", NULL, NULL,
                     "|?", "|2", "|^", "12", "",
                     "5", "$", "z", "", NULL,
                     "7", "+", "-|-", NULL, NULL,
                     "(_)", "|_|", "v", "L|",
                     "\\/", NULL, NULL, NULL, NULL,
                     "\\/\\/", "vv", "\\|/", "\\^/", "\\V/",
                     "%", "><", "}{", ")(", "*",
                     "j", "`/", "", NULL, NULL,
                     "2", ">_", "7_", NULL, NULL};

int main(void)
{
  int c, ci;
  char *cp;

  srandom(time(NULL));

  while ((c = fgetc(stdin)) != EOF) {
    if (c >= 0x41 && c <= 0x5a) { /* A-Z */
      ci = c - 0x41;
      while ((cp = leet[ci][random() % 5]) == NULL);
      fputs(cp, stdout);
    } else if (c >= 0x61 && c <= 0x7a) { /* a-z */
      ci = c - 0x61;
      while ((cp = leet[ci][random() % 5]) == NULL);
      fputs(cp, stdout);
    } else
      fputc(c, stdout);
  }

  return 0;
}
          


1[-37 \V/|?|>$ [/\/\/ !3 &}{|7|^$z[-) |^/ /-/v{\}I>12[) ()|= \V/^j5.

Topic: Scripts and Code, by Kjetil @ 07/12-2007, Article Link

One-Time Pad Communicator

In times of overwhelming paranoia and government conspiracies, secure communications is vital. I have made a ncurses based communication program that utilizes one-time pads to encrypt textual communication transferred over a TCP/IP network (like the Internet). The program is simply named "otp".

As long as the pads contain totally random data, and they are transferred safely, it is impossible to crack the encryption by eavesdropping on the communication.

For the system to be secure, the pads should be transferred on physical medium like a CD or a USB pen-drive instead of over the network. They should also be disposed of after use.

A screenshot of the program in action:

One-Time Pad Communicator screenshot


I have released the source code under the GNU GPL version 3, and it can be downloaded here. You will need the ncurses library in order to compile it (as usual :-) ). I have only tested the program on Linux, but it should be compilable on most POSIX platforms I believe.

More detailed information can be found in the README file in the archive.

If you do not trust this program, (For all you know, I could be a sinister government agent.) you are free to look at the source code to verify its functions, and possibly correct them. That's the beauty of open source.

Topic: Open Source, by Kjetil @ 18/11-2007, Article Link

M80 Framework

A long time ago I found an old DOS application on scavenged 386-based computer. The name of the application was "Micro 80", and it was meant to be (I think) some kind of small-business CRM system. I liked the interface the application was using and decided to recreate it on Linux using the ncurses terminal handling library. The result is "M80".

The M80 Framework is made up of a "main framework manager" which is the executable file and a lot of modules that are shared libraries/objects. The modules are loaded dynamically, and are therefore not compiled into the framework manager.

Here is a screenshot of M80 in action, showing some modules loaded:

M80 Framework screenshot


I have released the source under the GNU GPL version 3, and it can be downloaded here. You will need ncurses to compile it. Note that if ncurses has mouse support, M80 will also get mouse support.

For more information, please consult the README file in the archive.

Topic: Open Source, by Kjetil @ 26/10-2007, Article Link

Block Edit

After having trouble finding a program I needed for a special task (To be honest, I did not search very thorough.), I decided to create it myself. The result is "Block Edit", as it is called in lack of a more descriptive (and complicated?) name.

It is basically a special purpose text editor. Instead of working on lines (like most normal text editors) this program sees the text as one large block/rectangle. All editing happens "in place" and no text is shifted in any direction. It's task area is limited I think, and the only things I can imagine it being used for is ASCII art/graphics or specially formatted data files for certain applications.

Here is a screenshot of the program in action:

Block Edit screenshot


You will need the ncurses library in order to compile it and the source can be found here. There is no Windows binary to get this time since curses programs require special treatment on that OS.

I must warn that you use this program at your own risk and take backup of the files you are trying to edit. Files will be heavily mangled when loaded (in case they do not have static line widths, or have strange characters) and may not look like you expect after saving them back to disk.

Topic: Open Source, by Kjetil @ 08/10-2007, Article Link

Linux towels

My sister and I got a tip from a friend that someone were selling Linux towels at a nearby store. We had high hopes of finding Tux the Penguin everywhere, but instead we found this:

Linux towel

Better than nothing I guess. :-)

But I am wondering if their design department (or whatever they have) is aware of their product naming? Are they aware of the reference to an operating system kernel, or is it pure coincidence?

Topic: Mundane, by Kjetil @ 21/09-2007, Article Link

SDL Pong

After experimenting with SDL, I created a pong clone. (For those who do not know, "Pong" is a very classic computer game.)

I have released it under the GPL, and you can download the source here. I also compiled a windows binary that you can download here. (The zipfile also contains SDL.dll which is required to run the game on windows.)

Here is a small screenshot:

sdl-pong screenshot


Enjoy!

Topic: Open Source, by Kjetil @ 15/09-2007, Article Link

Attoscript

Attoscript is a very small programming language and interpreter (only 15K of source) that I designed myself. It is severely limited in many ways, but is intended for one task; running other programs.

Since the names microscript, nanoscript etc. are taken, I choose attoscript as the name for the language. "Atto" is the SI-prefix for Quintillionth/Trillionth.

The reason I actually created this language, was to have an alternative to batch files.
These are some of the improvements in the language over batch:
* Sleep instruction, to halt execution. (Ping trick anyone?)
* Creating random numbers.
* Reading user input into variables. (No hacks like generating and reading other batch files needed.)
* IF-construct that makes sense. (No strange "errorlevel" stuff.)

Here is a sample of what the language looks like:

var count
set count 10
label loop
echo "There are $count$ bottles of prune juice on the wall."
decr count
if count ne 0 loop
          


The interpreter is written in C, and the source can be downloaded here. (Licenced under GNU GPL version 2.)
I have also created a windows binary that can be downloaded here. (Compiled with Dev-C++.)

More information about the scripting language can be found in the README file in the source tarball.

Topic: Open Source, by Kjetil @ 19/08-2007, Article Link

TrueType fonts in Linux.

The GIMP was used to create the header logo on this site, and I used an old TrueType font I had lying around in it. But anyway, how does one install such fonts under Linux?

The answer is simple. Just copy the font file (as root) into the fonts directory with a command like this:
cp file.ttf /usr/share/fonts/corefonts/

Topic: Configuration, by Kjetil @ 29/07-2007, Article Link

New website.

Welcome, reader.

The purpose of this website is for me to spread technical information about stuff that I discover or work with. Hopefully this information will be of benefit for you.

I have decided to write in English, to make the content available to everyone. Please correct me if you see any spelling errors, so I can fix it and learn from the failure. :-)

My plan is to write about one or more of the following topics:
* Configuration and application tips/tricks.
* (Useful?) scripts in languages like Perl and Bash.
* Reviews of literature, applications, etc.
* Computer programs that I have made, complete with source code.

I may also write something mundane (Non-technical) topics, if I find it appropriate or useful to inform about.

This website is based on the ideas from the "Uplink Center" located here, which was an experiment.

Technical details about this website:
* All source files was written with the vi editor.
* Content (XHTML) and style (CSS) is completely separated, and therefore validated as "strict" by the W3C.
* There are no HTML tables used, only CSS "div" tags.
* PHP code is used for the front-end.
* Perl/CGI code is used for the back-end.
* A MySQL database stores the articles and comments.

Topic: General, by Kjetil @ 28/07-2007, Article Link