Sunday, February 26, 2006

A change-gas

The danger of reading Randall Hyde’s book, The Art of Assembly is that it contains addictive substances. Yesterday, I have decided to



joset@kee $ su -c "emerge -C nasm"

After cleaning up, a tune-up followed



.data

msg:
.ascii "A small step for me is a big leap for... me!\n"
len = . - msg

.text

.global _start

_start:

# write string to stdout

movl $len, %edx
movl $msg, %ecx
movl $1, %ebx
movl $4, %eax
int $0x80

# exit

movl $0, %ebx
movl $1, %eax
int $0x80

Now I have finally made a change-gas. Expecting a lot of maintenance work to follow.

Thursday, February 23, 2006

ADZU openlab scutworks

I really do not enjoy network administration a lot but the tasks listed below are rewarding. Let optimism light the path.


0] Tweak and secure box
1] Video screen capture
2] ADZU Debian repository
3] OpenAFS and Kerberos
4] IPv6
5] Honeypot
6] SETI


Expect postponement of blog posts. Everything will be documented here upon completion.


Signing off through a quote by Mr. Oscar Wilde


Experience is one thing you can’t get for nothing.

Sunday, February 19, 2006

Verify user in /etc/passwd

This is a product of wonder.


In file verify.c



#include <stdio.h>
#include <string.h>

#define MAX_LENGTH 1024

int is_local(char *user)
{
FILE *fd;
char line[MAX_LENGTH];
int local = 0;

if(!(fd = fopen("/etc/passwd", "r"))) {
puts("Can't read /etc/passwd, exiting.");
exit(1);
}

while(fgets(line, MAX_LENGTH, fd) > 0) {
if(!strncmp(line, user, strlen(user))) {
local = 1;
break;
}
}
fclose(fd);
return local;
}

Use at your own risk.


Disclaimer: Please refer to my first post ‘General notice’


Posted using Scott Yang’s mtsend.py python script. Thanks to Niel for his cool vim mappings.

Saturday, February 18, 2006

A hidden post made visible

I was afraid to make this available in public. When I tried to browse some counterpart of it in other distros, I have realized that there are a lot of similar topics found even in the official forums of major distros. There are many people doing this already. So for people ranging from lowerclass to middleclass, who can not afford a digital subscriber line, here is a wiser alternative.


If you have a Smartlink chipset winmodem in possession, then you are a bit luckier than those who own a Conexant chipset winmodem. Smartlink drivers are available for free eversince. Conexant drivers (lin*xant) were freely distributed during the 2.4 series era. This means, 2.4 kernels can still abuse the driver’s full-functionality.


Bad news for 2.6 starters, 2.4-2.6 shifters, and 2.4 starters who hold Conexant chipset winmodems. Why?


1. Free drivers for 2.4 series are no longer available in the official repository.
2. Drivers for 2.6 are free but limit your bandwidth to 14.4kbps. Free isn’t it?


So keep your 2.4 kernels, move to 2.6, and enjoy the modem’s irregulated downstreams and upstreams. Here is how:


Whip up a hexeditor and do stuffs below the belt.

Tuesday, February 14, 2006

Test mtsend

mtsend.py is a command line tool written in python. It uses Movable Type’s XML-RPC interface. It appears that it also works with WordPress’ XML-RPC interface. So I have decided to give it a try.


In file ~/.mtsendrc



[global]
default=eradicus

[site-blogsome]
url=http://eradicus.blogsome.com/xmlrpc.php
username=*****
password=*****
encoding=UTF-8

[blog-eradicus]
site=blogsome
blogid=1

It works!



joset@kee$ ./mtsend.py -B blogsome
+----+-----------+-------------------------------+
| ID | Blog Name | URL |
+----+-----------+-------------------------------+
| 1 | Sophie | http://eradicus.blogsome.com/ |
+----+-----------+-------------------------------+

joset@kee$ ./mtsend.py -C
+----+----------------------+
| ID | Category Name |
+----+----------------------+
| 5 | Healthy Vices |
| 2 | Of Love and Romance |
| 1 | Progressive Studies |
| 3 | Uncategorized |
| 6 | Unsolicited Opinions |
+----+----------------------+

joset@kee$ ./mtsend.py -V
Version 1.1

Massive blogging ahead!

Sunday, February 05, 2006

Queued tasks

Hopefully these features would be added on the game soon.


1. Nick completion
2. Default turn time limit 300/150
3. Display number of players
4. Notify if a player leaves
5. Sortable columns in lobby


The root of all evil in programming starts at early optimization in coding.
- Donald E. Knuth

Thursday, February 02, 2006

Wesnoth terrain

How are maps created? How are terrains organized? These questions are no way different from asking how GNU/Linux works. The brief explanation is, it is very complicated!


Conceptually it works like this:


Terrains are defined in terrain.cfg. They get assigned ID, name, char, etc.


A snippet of terrain.cfg



# Terrain configuration file. Defines how the terrain _work_ in the game. How
# the terrains _look_ is defined in terrain_graphics.cfg .

# NOTE: terrain id's are used implicitly by the in-game help:
# each "[terrain] id=some_id" corresponds to "[section] id=terrain_some_id"
# or "[topic] id=terrain_some_id" identifying its description in [help]

[terrain]
symbol_image=void
id=shroud
name= _ "Shroud"
char=" "
[/terrain]

[terrain]
symbol_image=fog
id=fog
name= _ "Fog"
char="~"
[/terrain]

[terrain]
symbol_image=ocean
id=deep_water
name= _ "Deep Water"
char=s
submerge=0.5
unit_height_adjust=-3
[/terrain]

[terrain]
symbol_image=coast
id=shallow_water
name= _ "Shallow Water"
char=c
submerge=0.4
unit_height_adjust=-4
[/terrain]

--snip--

In terrain-graphics.cfg the char gets assigned to the actual gfx files and given rules for how it is to be placed, layered, transitioned, etc. A normal type terrain gets a base image assigned and optionally several alternative tiles which will be distributed according to a given percentage. Then, it will be fed into the macro responsible for layering and transitioning against other terrains. Multihex terrains use their own custom macros to be assembled and placed (either on top of other terrains or with no background). Castles have their own macros, some terrains are also drawn using the castle macro.


A snippet of terrain-graphics.cfg



# The following flags are defined to have a meaning
#
# * base : the corresponding tile has already graphics for the terrain
# base. No other one should be added.
# * transition-$direction : the corresponding tile already has the transition
# in the given direction (or should not have one). No other one should be
# added.
# * keep-of-$castle : castle being a tile letter. The corresponding tile is the
# keep correspoding to the given castle tile

# The following should be kept on top of the file {terrain-graphics}
#-----------------------------------------------------------------
# Forest< ->Castle|Encampment special cases
#-----------------------------------------------------------------

#define FORESTADJCASTLEA FID ID PROB TILE
[terrain_graphics]
map="
1
* 1
2
* *
*"

[tile]
pos=1
type={ID}
[/tile]

[tile]
pos=2
type={FID}
no_flag="overlay"
set_flag="overlay"
[/tile]

probability={PROB}
rotations=n,ne,se,s,sw,nw

[image]
name={TILE}
position=vertical
base=90,144
[/image]

[/terrain_graphics]
#enddef

--snip--

All sorts of stuff like rotation, precedence, mutual-exclusiveness, ordering, layering, positioning, etc. are the macro’s area of responsibility. You have total control of the game’s interface using the right macro. Ayin made a very powerfull and flexible system, but very complex indeed!


Thanks to freim for the help.