Thursday, January 22, 2009

Debian /etc/alternatives

'/etc/alternatives' shows, using symbolic links, which programs are executed as default. For example, '/usb/bin/java' may have different versions, but by default, we can select one of them.

To edit (select, update, remove) this, we'll use 'update-alternatives'.

For selecting which version of java we want to use:
$ update-alternatives --config java

For adding an alternative version of java:
$ update-alternatives --install java java /usr/java/jre1.6.0_11/bin/java 0

Monday, January 19, 2009

Dirty searches in MLDonkey

When you do a search in MLDonkey, and you get dirty reply like *.exe, *.zip ... or old searches, with big sources, it could be due to fake-servers.

If you didn't update the server list since too much time, maybe you will have fake-servers. Moreover when you boot mlnet, it used to load servers, but the problem is that you have old servers in the cache, so the server list is not updated.

You can search which are the fake-servers, or remove all servers from the server list and then add the good ones. The best way (for me) is to remove each server by one, and then shutdown mlnet server and boot it again.

In the downloads.ini file (more or less in the line 220), there is the web_infos option. There you can change from where to get the server.met file when mlnet is booted. However, if you type the command vwi in the MLDonkey web gui, you can see which files are loaded in the boot time. You can add more server.met files too.

After searching in the web, i have find some webs to download "good" server.met.

http://peerates.net/servers.php (MLDonkey default)
http://edk.peerates.net/

Monday, January 12, 2009

SLOC (Source Lines of Code)

Reading comments about Software Enginering, I have found a web based CocomoII (COnstructive COst MOdel II), which allows one to estimate the cost and effort when planning a new software development activity.

I have programmed a little bash program which counts the source lines of a forlder. It skips new lines and php comments (/* */) when counting.

Code
#!/bin/bash

# SLOC (Source Lines of Code)
# This application is used to count the source lines of code
# of a project
# usage: sloc /home/pron/myphpproject
# http://www.cms4site.ru/utility.php?utility=cocomoii

# awk usage
# http://www.liamdelahunty.com/tips/linux_ls_awk_totals.php
# sed usage
# http://www.gnulamp.com/sed.html
# http://www.grymoire.com/Unix/

# if $1 parameter is a folder,
# will show recursively the lines that have the files
# but will exclude lines that contents any special character:
# * : initially used to delete comments like /* or */
# ^$ : ^ means beginning of line and $ means end of line,
# so it deletes lines when only appears '/n'

function count_lines {
if [ -d $1 ]
then
for j in $1/*
do
if [ -f $j ]
then
sed -e '/\/\*/ d' -e '/\*\// d' -e '/^$/ d' $j | wc -l
fi
if [ -x $j ]
then
$0 $j
fi
done
fi
}

count_lines $1 | awk '{ SUM +=$1 } END { print SUM} '