Digital Stronghold


March 24, 2011

Fiddler Web Debugging Proxy

Filed under: Blog Post

I just want to share this useful tool for debugging web apps specifically running in IE versions 8 and below. This is not just limited to applications running on the browser though, it can listen to any application utilizing HTTP / HTTPS. You do not need to configure your proxy settings to redirect traffic, it just works on the fly.

IE 9 has Developer Tools in it, more info [here] just like FireBug for Firefox and Chrome Developer Tools.

It does not mean that we can not use it though. I would still recommend it for debugging HTTP / HTTPS communication to avoid looking at 3 different tools.

March 23, 2011

Number of Simultaneous Connections in IIS

Filed under: Blog Post

So I have reached the testing phase of the anti CSRF / CSS / SQL Injection fixes for a classic ASP web application at work. Luckily it didn’t take me long enough to learn the language. My machine will be used for quality assurance purposes. I have encountered an error regarding the number of simultaneous connections made to my local IIS webserver while running OWASP CSRFTester Project.

The fix is simple; just increase the number of simultaneous connections for IIS using the command below:

Assuming your PWD is inetpub\adminscripts

cscript adsutil.vbs set w3svc/MaxConnections 40
iisreset

March 20, 2011

Repair Windows 7 System Files

Filed under: Blog Post

8 out of 10 average PC users have their box’s system files altered by malwares, viruses, etc. We usually reinstall the OS if the antivirus and anti malware software did not perform their job well. Here’s one way to fix the corrupted system files without the need of restarting your Windows 7 box.

1. Run the Command Prompt as Administrator
2. Type the following command

C:\Windows\system32\> sfc /scannow

repairsystemfiles

3. After the verification phase, you will receive a message about your system files’ integrity

Windows Resource Protection did not find any integrity violations.

March 19, 2011

Android Intent

Filed under: Blog Post

What is an Android Intent?

- functions like a verb
- something like “open contacts manager”, “search contacts”, “call contact”, and etc.
- I see it something like a description of a method / action to be performed
- used for starting other Activities

You can read more about this here: Android Intent

March 14, 2011

Android Activity

Filed under: Blog Post

What is an Android Activity?

- one of the building blocks of an Android application
- used for rendering user interfaces that can respond to events
- a single screen
- can return a value to the previous activity
- pushed into a stack every time a new activity starts

You can read more about this here: Android Activity

Let’s help Japan

Filed under: Blog Post

Help The Victims of the 8.9 Earthquake in Japan by Spreading Awareness and Aid. Visit http://goo.gl/wjZQz to donate.

February 16, 2011

HTTPS in Tomcat 6.0 Server

Filed under: Blog Post

1. Create a self-signed server certificate using keytool. Take note of the keystore password, you will need it later on for setting up the server.

keytool -genkeypair -alias tomcat -keyalg RSA -keysize 1024
-dname "CN=localhost, OU=Group, O=Company Name, L=City, S=Region,
C=PH" -validity 365 -keystore keystore

2. Move the generated certificate file (keystore) to Tomcat’s conf directory.

3. Modify conf/server.xml

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https"
secure="true" clientAuth="false"
sslProtocol="TLS"
keystoreFile="conf/keystore" keystorePass="your password" />

4. Restart Tomcat.

5. Visit this link https://localhost:443/. You will receive a warning about the self-signed certificate. If you want to get away with this warning, purchase a commercial certificate.

February 7, 2011

My New Android 1.6 / Debian Tablet Splash Screen

Filed under: Blog Post

Logos are registered trademarks of their respective owners.
splash
Created using The GIMP.

January 18, 2011

MD5 Hash Function for Oracle

Filed under: Blog Post

Basically there are 2 functions needed. Some people prefer the raw hash instead of the hex equivalent.
1. md5raw - for encoding text in raw md5 hash
2. md5 - for converting raw md5 hash to hex.

Here’s the code for the md5raw function.

create or replace
function md5raw (text in varchar2)
return varchar2 is
hash_value varchar2(20);
begin
   hash_value := dbms_obfuscation_toolkit.md5 (input_string => text);
   return hash_value;
end;

and the code for the md5 function.

create or replace
function md5(text in varchar2)
return varchar2 is
hash_value varchar2(32);
begin
    select lower(rawtohex(md5raw(text)))
    into hash_value
    from dual;
    return hash_value;
end;

Now you can do something like this.

select md5('koala') from dual;
	
|---------------------------------------|
|MD5('koala')                           |
|---------------------------------------|
|a564de63c2d0da68cf47586ee05984d7       |
|---------------------------------------|

January 5, 2011

Access VirtualBox Shared Folder in Ubuntu Guest

Filed under: Blog Post

I have been doing this for quite some time now but I failed to document it. First, install the VirtualBox Guest Additions on your host. Then you create a mount point (assuming it is /media/shared).

$ sudo mkdir /media/shared

You may change the path if you want. Mount the shared folder using the command below.

$ sudo mount -t vboxsf <folder> /media/shared

Replace the <folder> above with the correct shared folder name. Enjoy.

January 1, 2011

Welcome 2011!

Filed under: Blog Post

Happy New Year! Prospero Ano Nuevo!

December 14, 2010

Play Low Quality Videos in Gome Flytouch

Filed under: Blog Post

One of the common problems of Gome Flytouch is its inability to play high quality videos. Here is a trick by Kiarov for converting videos to a lower quality in order to be playable - Gome Flytouch Video Encoding Tutorial. Do not forget, you must have your tablet overclocked to 400MHz.

The software used for conversion was HandBrake but you can use any converter of your choice. The converted videos work well with Meridian Player.

Here’s the settings:

Type: MP4
Size: 480x320
Video Bit Rate: 384 kbps
Frame Rate: 25 fps
Video Encoder: XVid
Audio Encoder: AAC
Sample Rate: 44.1 KHz
Audio Bit Rate: 64 kbps

December 9, 2010

G Sensor and Camera Fix for Gome Flytouch

Filed under: Blog Post

Some Gome Flytouch tablets have their G sensors and cameras inverted by default. There are two ways to fix these.

1. If you’re creating your own firmware, it’s better to include the fix right on the scriptcmd file.

For the G sensor, add this line:

setenv gsensor_axis 0,-1,1,1,2,1

and for the camera:

setenv camera_rotate 270

2. If you had your device rooted, just execute the commands above on any Android terminal as root.

December 5, 2010

Run Android Apps in Windows using YouWave

Filed under: Blog Post

Now you can test run apps in your Windows machine before installing them in your device or perhaps you don’t want to miss the fun playing Robo Defense. This is best for extending the battery life of your device if you are just testing apps.

Watch the demo [here]. Click [here] to download. Enjoy!

December 4, 2010

Gome Flytouch Android Tablet

Filed under: Blog Post

Gome Flytouch

Gome Logo
Gome Flytouch

Model: generic
Manufacturer: generic
Device: generic
Product: generic
Brand: generic
CPI ABI: armeabi
Kernel Version: 2.6.29-00236-g4f8dbbb-dirty howayhuo@szmce12(MontaVista)
Build No: Donut.eng.howayhuo.20100910.134417
Release: 1.6
SDK: 4
	
Processor: ARM926EJ-S rev 5 (v5l)
BogoMIPS: 174.48
Features: swp half thumb fastmult edsp java
CPU Implementer: 0x41
CPU Architecture: 5TEJ
CPU Variant: 0x0
CPU Part: 0x926
CPU Revision: 5
	
Hardware: WMT
Revision:0000
Serial: 000000000000000
	
Type: Touchscreen Tablet
Materials: Plastic
Colors: White
Camera: 0.3 Megapixel
Screen: 7" Resistive Touchscreen at 800*480(16:9)
CPU: VIA WM8505 (350MHz)
RAM: 256MB DDR2
Flash ROM:2GB
Expansion Memory: SD/SDHC/MMC up to 32GB
Network Connectivity: WiFi or Ethernet (RJ45)
Sensors: Accelerometer (supports rotation)
Vibration: Yes
Battery Capacity: 2400mah
Ports: USB 2.0 Host /USB 2.0 Device Port/3.5 mm Headphone Jack
Sound: Internal Microphone and Speakers

If you are buying from the Philippines you can get this one for PHP 3,300 (USD 75) at 168 Mall, Divisoria.

Android 1.6 Firmware Default Wallpaper

Filed under: Blog Post

The default wallpaper file is:

/data/data/com.android.settings/files/wallpaper

It is a JPEG file format without the .jpg extension.

December 2, 2010

My Android Splash Screen

Filed under: Blog Post

I just want to share my Android Splash Screen. Credit goes to the original artist. I just modified some part of it.

Android Splash Screen

If you have an 800x480 pad, make sure your bitmap is 24-bit and of course the resolution must be 800x480.

mkimage for Windows

Filed under: Blog Post

Even if you do not use Linux, you can still roll your own Android firmware update on Windows. Click [here] to download mkimage for Windows.

December 1, 2010

update.sh for Android

Filed under: Blog Post

After scriptcmd (previous blog post), the next to be called is the update.sh script. The script will setup the file system, data partition, cache partition, and user space. It will install BusyBox for you.

height=22
pointX=30
pointY=100
	
SDCARD=/mnt/mmcblk0p1
	
string="Good luck!"
echo $string
gui-echo $pointX $pointY "$string"
	
if [ -x /mnt/mmcblk0/script/update.sh ] ; then
    SDCARD=/mnt/mmcblk0
fi
	
if [ -f ${SDCARD}/script/android_fs.tar ] ; then
    string="Updating file system..."
    echo $string
    gui-echo $pointX $pointY "$string"
else
    string="--- File not found - script/android_fs.tar"
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height + $height))
    string="Failed updating file system!"
    echo $string
    gui-echo $pointX $pointY "$string"
    exit 0
fi
	
# FILE SYSTEM SETUP
	
pointY=$(($pointY + $height + $height))
string="Cleaning up file system..."
echo $string
gui-echo $pointX $pointY "$string"
	
flash_eraseall /dev/mtd9
if [ $? -ne 0 ] ; then
    pointY=$(($pointY + $height + $height))
    string="--- Failed cleaning up file system!"
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height))
    string="Kernel doesn't support NAND flash?"
    echo $string
    gui-echo $pointX $pointY "$string"
    exit 0
else
   string="Done cleaning up file system..."
   echo $string
   gui-echo $pointX $pointY "$string"
fi
	
mount -t yaffs2 /dev/mtdblock9 /mnt/mtd
if [ $? -ne 0 ] ; then
    pointY=$(($pointY + $height + $height))
    string="--- Failed mounting file system!"
    echo $string
    gui-echo $pointX $pointY "$string"
    exit 0
else
    string="File system is now mounted..."
    echo $string
    gui-echo $pointX $pointY "$string"
fi
	
pointY=$(($pointY + $height))
string="Now copying system files..."
echo $string
gui-echo $pointX $pointY "$string"
	
tar xvf ${SDCARD}/script/android_fs.tar -C /mnt/mtd
chmod 777 -R /mnt/mtd
string="Files were copied successfully..."
echo $string
gui-echo $pointX $pointY "$string"
pointY=$(($pointY + $height))
	
if [ -d ${SDCARD}/script/driver ] ; then
    echo "Now copying device drivers..."
    if [ ! -d /mnt/mtd/.driver ] ; then
        mkdir /mnt/mtd/.driver
    fi
    cp -a ${SDCARD}/script/driver/* /mnt/mtd/.driver
	
    string="Files were copied successfully..."
    echo $string
    gui-echo $pointX $pointY "$string"
fi
	
boardID=`getenv wmt.model`
if [ $? -eq 0 ] ; then
    if [ $boardID = "8088b_90_20k" ] || [ $boardID = "8088b_90_1k" ] || [ $boardID = "8088b_90_1k" ] ; then
        boardID=8088b
    fi
    special_driver=${SDCARD}/script/driver_$boardID
    if [ -d $special_driver ] ; then
        echo "Now copying special device drivers..."
        if [ ! -d /mnt/mtd/.driver ] ; then
            mkdir /mnt/mtd/.driver
        fi
        cp -a ${special_driver}/* /mnt/mtd/.driver
        string="Done copying special device drivers..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
fi
	
if [ -f ${SDCARD}/script/busybox_1.17.tar ] && [ ! -x /mnt/mtd/system/bin/sh-org ] ; then
    string="Now copying BusyBox..."
    echo $string
    gui-echo $pointX $pointY "$string"
    tar xvf ${SDCARD}/script/busybox_1.17.tar -C /mnt/mtd
    string="Done copying BusyBox..."
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height))    
	
    if [ -x /mnt/mtd/busybox/bin/ash ] ; then
        mv /mnt/mtd/system/bin/sh /mnt/mtd/system/bin/sh-org
        ln -s /busybox/bin/busybox /mnt/mtd/system/bin/sh
	rm /mnt/mtd/system/bin/busybox
        cp /busybox/bin/busybox /mnt/mtd/system/bin/
        if [ ! -d /mnt/mtd/bin ] ; then
            mkdir /mnt/mtd/bin
        fi
        ln -s /busybox/bin/busybox /mnt/mtd/bin/sh
    fi
fi
	
if [ -d ${SDCARD}/script/pre_root_disk ] || [ -f ${SDCARD}/script/data.tar ] || [ -f ${SDCARD}/script/cache.tar ] ; then
    string="Now copying additional files..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    if [ -d ${SDCARD}/script/pre_root_disk ] ; then
        cp -a ${SDCARD}/script/pre_root_disk/*  /mnt/mtd
        if [ -d /mnt/mtd/restore ] ; then
            if [ -d /mnt/mtd/.restore ] ; then
                cp -a  /mnt/mtd/restore/*  /mnt/mtd/.restore/
                rm -rf /mnt/mtd/restore
            else
                mv /mnt/mtd/restore /mnt/mtd/.restore
            fi
        fi
    fi
	
    if [ -f ${SDCARD}/script/data.tar ] ; then
        if [ ! -d /mnt/mtd/.restore ] ; then
            mkdir /mnt/mtd/.restore
        fi
        cp -rf ${SDCARD}/script/data.tar /mnt/mtd/.restore
	
        if [ -d ${SDCARD}/script/pre_data_disk/app ] ; then
            cp -rf ${SDCARD}/script/pre_data_disk/app /mnt/mtd/.restore
        fi
    fi
	
    if [ -f ${SDCARD}/script/cache.tar ] ; then
        if [ ! -d /mnt/mtd/.restore ] ; then
            mkdir /mnt/mtd/.restore
        fi
        cp ${SDCARD}/script/cache.tar /mnt/mtd/.restore
    fi
	
    if [ -d /mnt/mtd/.restore ] ; then
        if [ -f ${SDCARD}/script/etc/touchcal ] ; then
            cp -a ${SDCARD}/script/etc/touchcal /mnt/mtd/.restore/
        fi
        boardID=`getenv wmt.model`
        if [ $? -eq 0 ] ; then
            special_touchcal_file=${SDCARD}/script/etc/touchcal_$boardID
            if [ -f ${special_touchcal_file} ] ; then
                cp -a ${special_touchcal_file} /mnt/mtd/.restore/touchcal
            fi
        fi
    fi
	
    string="Done copying additional files..."
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height))
fi
	
string="Setting file system permissions..."
echo $string
gui-echo $pointX $pointY "$string"
	
    chmod 755 -R /mnt/mtd
    chmod 750 /mnt/mtd/init.rc
    chmod 750 /mnt/mtd/init.goldfish.rc
    chmod 750 /mnt/mtd/init
    chmod 644 /mnt/mtd/default.prop
    chmod 700 /mnt/mtd/root
    chmod 750 /mnt/mtd/sbin
    chmod 751 /mnt/mtd/bin
    chmod 751 /mnt/mtd/busybox
    chmod 750 /mnt/mtd/lib
	
string="File system permissions were set..."
echo $string
gui-echo $pointX $pointY "$string"
pointY=$(($pointY + $height))
	
if [ -f /mnt/mtd/system/bin/preboot ] ; then
    chown root:0 /mnt/mtd/system/bin/preboot
    chmod a-w /mnt/mtd/system/bin/preboot
    chmod a+rxs /mnt/mtd/system/bin/preboot
fi
chmod 777 -R /mnt/mtd
mv /mnt/mtd/busybox/bin/su /mnt/mtd/busybox/bin/su.bak
chown root:root /mnt/mtd/system/bin/su
chmod 4777 /mnt/mtd/system/bin/su 
	
sync
umount /mnt/mtd
	
if [ $? -ne 0 ] ; then
    pointY=$(($pointY + $height))
    string="Failed dismounting file system!"
    echo $string
    gui-echo $pointX $pointY "$string"
    exit 0
fi
	
# DATA PARTITION SETUP
	
if [ -d ${SDCARD}/script/etc ] || [ -f ${SDCARD}/script/data.tar ] || [ -d ${SDCARD}/script/pre_data_disk ] ; then
    string="Erasing data partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    flash_eraseall /dev/mtd10
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed erasing data partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        pointY=$(($pointY + $height))
        string="Kernel doesn't support NAND flash?"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
       string="Done erasing data partition..."
       echo $string
       gui-echo $pointX $pointY "$string"
    fi
	
    mount -t yaffs2 /dev/mtdblock10 /mnt/mtd
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed mounting data partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        string="Data partition mounted successully..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
    pointY=$(($pointY + $height))
	
    string="Now copying files to data partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    if [ -f ${SDCARD}/script/data.tar ] ; then
        tar xvf ${SDCARD}/script/data.tar -C /mnt/mtd
    fi
	
    if [ -d ${SDCARD}/script/etc ] ; then
        if [ ! -d /mnt/mtd/wmtpref ] ; then
            mkdir /mnt/mtd/wmtpref
        fi
        cp -a ${SDCARD}/script/etc/* /mnt/mtd/wmtpref/
	
        boardID=`getenv wmt.model`
        if [ $? -eq 0 ] ; then
            special_touchcal_file=${SDCARD}/script/etc/touchcal_$boardID
            if [ -f ${special_touchcal_file} ] ; then
                cp -a ${special_touchcal_file} /mnt/mtd/wmtpref/touchcal
            fi
        fi
    fi
	
    if [ -d ${SDCARD}/script/app ] ; then
        if [ -d /mnt/mtd/app ] ; then
            echo "The app folder exists in the data partition. We don't want it there!"
        else
            cp -a ${SDCARD}/script/app  /mnt/mtd/
        fi
    fi
	
    if [ -d ${SDCARD}/script/pre_data_disk ] ; then
       cp -a ${SDCARD}/script/pre_data_disk/*  /mnt/mtd
    fi
	
    if [ -d ${SDCARD}/script/pre_root_disk/restore/etc ] ; then
       cp -a ${SDCARD}/script/pre_root_disk/restore/etc  /mnt/mtd/wmtpref/
    fi
	
    string="Done copying files to data partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height))
	
    chmod 777 -R /mnt/mtd
    sync
    umount /mnt/mtd
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height))
        string="Failed to dismount data partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    fi
fi
	
# CACHE PARTITION SETUP
	
if [ -f ${SDCARD}/script/cache.tar ] || [ -d ${SDCARD}/script/pre_cache_disk ] ; then
    string="Erasing cache partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    flash_eraseall /dev/mtd11
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed to erase cache partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        pointY=$(($pointY + $height))
        string="Kernel doesn't support NAND flash?"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
       string="Done erasing cache partition..."
       echo $string
       gui-echo $pointX $pointY "$string"
    fi
	
    mount -t yaffs2 /dev/mtdblock11 /mnt/mtd
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed mounting data partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        string="Cache partition mounted successfully..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
    pointY=$(($pointY + $height))
	
    string="Now copying files to cache partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    if [ -f ${SDCARD}/script/cache.tar ] ; then
        tar xvf ${SDCARD}/script/chache.tar -C /mnt/mtd
    fi
	
    if [ -d ${SDCARD}/script/pre_cache_disk ] ; then
       cp -a ${SDCARD}/script/pre_cache_disk/*  /mnt/mtd
    fi
	
    string="Done copying files to cache partition..."
    echo $string
    gui-echo $pointX $pointY "$string"
    pointY=$(($pointY + $height))
	
    chmod 777 -R /mnt/mtd
    sync
    umount /mnt/mtd
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height))
        string="Failed to dismount cache partition!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    fi
fi
	
string="File system updated successfully!"
echo $string
gui-echo $pointX $pointY "$string"
pointY=$(($pointY + $height + $height))
	
# USER SPACE SETUP
	
if [ -f ${SDCARD}/script/driver/g_file_storage.ko ] ; then
    string="Erasing user space..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    flash_eraseall /dev/mtd12
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed to erase user space!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        string="Done erasing user space..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
    mount -t yaffs2 /dev/mtdblock12 /mnt/mtd
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed to mount user space!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        string="Done mounting user space..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
	
    pointY=$(($pointY + $height))
    string="Creating loop file..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    create_loopfile mtd12 /mnt/mtd/vfat.bin bs=524288
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed to create loop file!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        if [ -f /mnt/mtd/vfat.bin ] ; then
            string="Loop file created..."
            echo $string
            gui-echo $pointX $pointY "$string"
        else
            pointY=$(($pointY + $height + $height))
            string="Failed to create loop file!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
    fi
    pointY=$(($pointY + $height))
	
    string="Formatting loop file..."
    echo $string
    gui-echo $pointX $pointY "$string"
	
    mkdosfs /mnt/mtd/vfat.bin
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed formatting loop file!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    else
        string="Loop file formatted..."
        echo $string
        gui-echo $pointX $pointY "$string"
    fi
	
    if [ -d ${SDCARD}/script/DemoFile ] || [ -d ${SDCARD}/script/pre_local_disk ] ; then
	
        losetup /dev/loop/0 /mnt/mtd/vfat.bin
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height))
            string="Command losetup failed!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
        mkdir /LocalDisk
        mount -o iocharset=gb2312 -t vfat /dev/loop/0  /LocalDisk
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height))
            string="Mounting /dev/loop/0 to /LocalDisk failed!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
	
        if [ -d ${SDCARD}/script/DemoFile ] ; then
            string="Now copying demo Files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
	
            cp -a ${SDCARD}/script/DemoFile /LocalDisk
	
            string="Demo files were copied to user space successfully..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
	
        if [ -d ${SDCARD}/script/pre_local_disk ] ; then
            string="Now copying files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
	
            cp -a ${SDCARD}/script/pre_local_disk/*  /LocalDisk
	
            string="Done copying files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
	
        chmod 777 -R /LocalDisk
        sync
        umount /LocalDisk
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height))
            string="Failed dismounting LocalDisk!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
        losetup -d /dev/loop/0
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height))
            string="Command losetup -d /dev/loop/0 failed!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
    fi
	
    chmod 777 -R /mnt/mtd
    sync
    umount /mnt/mtd
	
    if [ $? -ne 0 ] ; then
        pointY=$(($pointY + $height + $height))
        string="Failed dismounting user space!"
        echo $string
        gui-echo $pointX $pointY "$string"
        exit 0
    fi
	
    pointY=$(($pointY + $height + $height))
else
    if [ -d ${SDCARD}/script/DemoFile ] || [ -d ${SDCARD}/script/pre_local_disk ] ; then
        string="Erasing user space..."
        echo $string
        gui-echo $pointX $pointY "$string"
	
        flash_eraseall /dev/mtd12
	
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height + $height))
            string="Failed erasing user space!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        else
            string="Done erasing user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
        mount -t yaffs2 /dev/mtdblock12 /mnt/mtd
	
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height + $height))
            string="Failed mounting user space!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        else
            string="Done mounting user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
	
        pointY=$(($pointY + $height))
	
        if [ -d ${SDCARD}/script/DemoFile ] ; then
            string="Now copying demo files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
	
            cp -a ${SDCARD}/script/DemoFile /mnt/mtd
	
            string="Done copying demo files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
	
        if [ -d ${SDCARD}/script/pre_local_disk ] ; then
            string="Now copying files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
	
            cp -a ${SDCARD}/script/pre_local_disk/*  /mnt/mtd
	
            string="Done copying files to user space..."
            echo $string
            gui-echo $pointX $pointY "$string"
        fi
	
        chmod 777 -R /mnt/mtd
        sync
        umount /mnt/mtd
	
        if [ $? -ne 0 ] ; then
            pointY=$(($pointY + $height + $height))
            string="Failed dismounting user space!"
            echo $string
            gui-echo $pointX $pointY "$string"
            exit 0
        fi
	
        pointY=$(($pointY + $height + $height))
    fi
fi
	
echo 0 > /proc/boot-splash
cleanlcd
remove_sd
	
string="Please remove SD card..."
while [ -x /bin/ls ]
do
    if [ -x ${SDCARD}/script/update.sh ] ; then
        echo $string
        sleep 1
    else
        break
    fi
done
	
cleanlcd
hint_shutdown
string="Shutting down..."
echo $string
poweroff

scriptcmd for Android

Filed under: Blog Post

Here’s my script for updating the Android firmware. This script must contain the correct file header for your processor.

setenv BMP_ADR 3c00000
fatload mmc 0 $(BMP_ADR) script/hint1_en.bmp
setenv lcdparam 1,30000,8,800,480,48,40,40,3,29,13
setenv pwmparam 0,45,1040,1040
setenv LCDC_FB f900000
lcdinit
logo show -1 0
textout 30 80 "Android update will start after 8 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 7 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 6 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 5 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 4 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 3 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 2 seconds..." ffff00
sleep 1
textout 30 80 "Android update will start after 1 second..." ffff00
sleep 1
mmcinit
setenv text1 'textout 705 458 "  1.9.99 by eradicus" c5c5c5'
run text1
textout 30 80 "Android Update" ffff00
textout -1 -1 "Updating w-load..." ffff00
fatload mmc 0 0 script/wload.bin
erase ffff0000 +10000
cp.b 0 ffff0000 10000
textout -1 -1 "w-load update done!" ff00
textout -1 -1 "Updating u-boot..." ffff00
fatload mmc 0 0 script/u-boot.bin
erase fff80000 +50000
cp.b 0 fff80000 50000
textout -1 -1 "u-boot update done!" ff00
setenv touchic  true
setenv bootdelay 1
setenv audioic  wm9715
setenv touchirq  gpio5
setenv battvoltlist  6830,7086,7310,7503,7575,7636,7720,7861,7953,8018,8190
setenv gpiostate  3
setenv kpadid wms8088b_14
setenv panelres.x 800
setenv panelres.y 480
setenv logocmd 'nand read 3c00000 600000 150000;logo show;run text1'
setenv bootcmd 'nand read 0 0 380000;bootm 0'
setenv bootargs 'mem=237M noinitrd root=/dev/mtdblock9 rootfstype=yaffs2 rw console=ttyS0,115200n8 init=/init lcdid=1 androidboot.console=ttyS0 loadtime=-3'
setenv sd_powerup
setenv sd_powerdown
setenv amp_powerup 0xd811005c|0x4,0xd8110084|0x4,0xd81100ac&~0x4
setenv amp_powerdown 0xd811005c|0x4,0xd8110084|0x4,0xd81100ac|0x4
setenv wifi_powerdown 0xd811005c|0x2,0xd8110084|0x2,0xd81100ac&~0x2
setenv wifi_powerup 0xd811005c|0x2,0xd8110084|0x2,0xd81100ac|0x2
setenv regop $(amp_powerdown),$(wifi_powerdown),D8130054|0x1
setenv LOGO_STRING
setenv basevolt 3300
setenv hibernation_ui no
setenv eth_ui yes
setenv gsensor_axis 0,1,1,-1,2,1
setenv gsensor_int gpio6
setenv gsensor_ui yes
setenv motor_ui yes
setenv photo_ui_slideshow_mode
setenv vibra_start 0xD811005C|0x8,0xD8110084|0x8,0xD81100AC|0x8
setenv vibra_stop 0xD81100AC&~0x8
setenv vibra_enable 0
setenv video_ui_dir_select
setenv 88 1
setenv dw
setenv restore
setenv need_restore_data yes
setenv orientation_ui yes
setenv cam_pre_width 360
setenv cam_pre_height 480
setenv camera_rotate 90
setenv camera_chip sonix
setenv camera_up 5c|0x1,84|0x1,ac|0x1
setenv camera_down ac&~0x1
setenv camera_ui yes
setenv customer_id 1
setenv musicplayer_black_cd yes
setenv enable_hw_scal yes
setenv enable_gome_theme no
setenv modem3g_ui no
setenv pppoe_ui no
setenv release_ver 1.9_88v4c
setenv release_date 20101107
setenv release_language english
setenv bluetooth_ui no
setenv wmt.model 8088b_90_20k
setenv powerhold 1
setenv touchcodec
setenv amp_stop_when_nouse
randommac
protect off all
saveenv
fatload mmc 0 0 script/androidpad.bmp
textout -1 -1 "Updating splash screen..." ffff00
nand write 0 600000 $(filesize)
textout -1 -1 "Splash screen update done!" ff00
fatload mmc 0 0 script/ramdisk_88_en.gz
textout -1 -1 "Updating ramdisk..." ffff00
nand write 0 C00000 $(filesize)
textout -1 -1 "ramdisk update done!" ff00
fatload mmc 0 0 script/uzImage.bin
textout -1 -1 "Updating kernel..." ffff00
nand write 0 0 $(filesize)
textout -1 -1 "Kernel update done!" ff00
textout -1 -1 "Updating file system..." ffff00
setenv bootargs 'mem=237M root=/dev/ram rw initrd=0x01000000,32M console=ttyS0,115200n8 init=/linuxrc lcdid=1 loadtime=-3'
fatload mmc 0 1000000 script/mvl5_v5t_ramdisk_WM8505.090922.loop_en.gz
textout -1 -1 "Please wait..." ff00
bootm 0

To prepend the file header, execute

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "info" -d thisscript.txt scriptcmd

November 29, 2010

Android ASCII Art

Filed under: Blog Post
                         G                         G
                         GG                       GG
                          G                       G
                          GG                     GG
                           GG   GGGGGGGGGGGGG   GG
                            GGGGGGGGGGGGGGGGGGGGG
                         GGGGGGGGGGGGGGGGGGGGGGGGGGG
                       GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                      GGGGGG  GGGGGGGGGGGGGGGGG  GGGGGG
                     GGGGGG    GGGGGGGGGGGGGGG    GGGGGG
                    GGGGGGG    GGGGGGGGGGGGGGG    GGGGGGG
                    GGGGGGGG  GGGGGGGGGGGGGGGGG  GGGGGGGG
                   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG           
	
           GG     GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG     GG
         GGGGGG   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG   GGGGGG
        GGGGGGG   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG   GGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGGG  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG  GGGGGGGG
        GGGGGGG   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG   GGGGGGG
         GGGGG    GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG    GGGGG
                  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                  GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                   GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                    GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                         GGGGGGGGG         GGGGGGGGG
                          GGGGGGG           GGGGGGG
                          GGGGGGG           GGGGGGG

October 19, 2010

Active Directory with JXplorer

Filed under: Blog Post

For folks who do not read the manual. If you encounter this error using JXplorer:

[LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment:
In order to perform this operation a successful bind must be completed
on the connection., data 0, vece]

Do not use your login name. Use your full name instead.

September 28, 2010

On an obsolete road

Filed under: Blog Post

I have already forgotten these things.

1. Inner join versus outer join
2. Simple select statement for getting the max value of a column + another column
3. Definition of Object Oriented programming
4. Exact figure of the limitation of HTTP GET.
5. Differences between GET and POST.
6. The default method of an HTML form when submitted.

I have made time to review them. Here they are.

1. Inner join will return matched results between two tables while outer join will return all regardless if there is a match or none between the two tables. Here’s a good article by Jeff Atwood, A Visual Explanation of SQL Joins.

2. Given a table Person with two columns, Name and Age. To get the eldest,

SELECT Name, Age FROM Person WHERE Age = max(Age);

3. Object oriented programming is a programming paradigm that uses objects. These objects consist of fields, methods and their interaction.

4. 256 characters.

5. Given the size limit of GET, POST is used to overcome that. POST is used if you want to submit data with non-ASCII characters. If you want to hide data you’ll prefer POST than GET since it hides hidden fields in the URL but it’s not enough since you can view the source or use browser debugging tools such as FireBug and Chrome Developer Tools.

6. If you have an HTML form with no method defined, GET is the default.

There goes my hopes and dreams. The road less traveled.

September 24, 2010

Casting to a Boolean in JavaScript

Filed under: Blog Post

I came across with this expression,

button.enabled = !!enable

!! is just a double not. This is just obscure.

July 16, 2010

HTML5 Web SQL Database

Filed under: Blog Post

HTML5 has a bunch of cool APIs. In one of my previous posts, I have written a simple demonstration of the Web Storage JavaScript API. In this post I will be showing another demonstration, the Web SQL Database JavaScript API. What is so fascinating about these APIs is they are “crash-safe.” Now you can lessen the load of your web servers and perform SQL tasks like, sorting, joining, etc. on the client side.

Click [here] for the demonstration.

July 15, 2010

Removing while Iterating a Collection in Java

Filed under: Blog Post

Let us say you have a list and you want to remove items while iterating through it if a certain condition satisfies.

for (Object object : listOfObjects) {
    if (isConditionSatisfied) {
        listOfObjects.remove(object);
    }
}

What is wrong with this code above? Try it and you will get this,

Exception in thread "main" java.util.ConcurrentModificationException

You might want to do this instead,

Iterator<Object> iterator = listOfObjects.iterator();
while (iterator.hasNext()) {
    Object object = iterator.next();
    if (isConditionSatisfied) {
        iterator.remove();
    }
}

Have a nice day.

July 13, 2010

HTML5 Web Storage

Filed under: Blog Post

Here is a simple demonstration of HTML5’s Web Storage. The code is quite straightforward. One thing to experiment is after entering any string and hitting save, try closing the browser entirely and opening it again visiting the same page to see if the data persisted.

Click [here] for the demonstration.

June 9, 2010

Just for fun!

Filed under: Blog Post

It has been a while since I have written something about Javascript. You need to copy and paste this to your browser’s address bar to see how it works.

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200;
DI=document.getElementsByTagName("a"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style;
DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=
(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',50); void(0);

Enjoy!

June 7, 2010

Performance of null checks in Java

Filed under: Blog Post

Which one is faster? a == null or null == a?

This is the method of the former.

    public static boolean firstNullCheck(Object a) {
        if (a == null) {
            return true;
        }
        return false;
    }

and the method of the latter.

    public static boolean secondNullCheck(Object a) {
        if (null == a) {
            return true;
        }
        return false;
    }

Here’s the disassembly of the former.

public static boolean firstNullCheck(java.lang.Object);
  Code:
   0:	aload_0
   1:	ifnonnull	6
   4:	iconst_1
   5:	ireturn
   6:	iconst_0
   7:	ireturn

and the disassembly of the latter.

public static boolean secondNullCheck(java.lang.Object);
  Code:
   0:	aconst_null
   1:	aload_0
   2:	if_acmpne	7
   5:	iconst_1
   6:	ireturn
   7:	iconst_0
   8:	ireturn

The former saves you a bytecode. Anyone who can explain further since I am not sure whether if_acmpne is faster than ifnonnull?

Google over SSL

Filed under: Blog Post

If you do not want your search queries to be compromised, use Google SSL. However, there is one thing I discovered though, if you click on a cached link, it’s not encrypted, it goes back to HTTP from HTTPS making the protected search useless. Just be aware.

June 4, 2010

Importance of daily meetings

Filed under: Blog Post

Why are daily meetings important? Yes I know what you are thinking, to check if the schedule is on target, to spot showstoppers, roadblocks and whatnots. But aside from those, there are things that make daily meetings rewarding.

Let’s face it, some people (including me) find it hard oftentimes to achieve a certain level of focus at work especially when multitasking is inevitable. Meetings will remind us of our commitments infront of our peers. Since most of us will be ashamed of not making any progress, it will trigger ourselves to do something about it.

In my opinion, having daily meetings typically before the shift starts will help a lot of peers suffering from bad habits - procrastination. It is one way of invigorating those who have not found their way out yet.

“Keep each other in the zone, what are teammates for?”

June 1, 2010

Yesterday I turned 0x18

Filed under: Blog Post

A very simple party, KFC Bucket, 1 Black Forest Cake. Thank you God for another blessed year.

March 12, 2010

Google Search Operators

Filed under: Blog Post

There is great power here. I know most of you are not taking advantage of these operators.

1. + (plus) - this will yield search results ordered by the number of occurrences of the specified word
2. - (dash) - this will yield search results that do not contain the specified word
3. " " (double quotes) - this will yield search results containing the exact word specified
4. . (dot) - is a wildcard representing a single character
5. * (asterisk) - is a wildcard representing a single word
6. | - traditional OR operator
7. site: - search within a specified domain
8. intitle: - this will search for the 1st specified word in page titles and the 2nd specified word in the text
9. allintitle: - this will search for texts in page titles only
10. inurl: - this will search for URLs containing the specified word
11. allinurl: - this will search for texts in URLs only
12. filetype: - this will search for texts containing files of the specified extension and the specified word
13. ext: - this will search for texts containing files of the specified extension and the specified word
14. numrange - used for searching number sequences
15. link: - this will search for pages containing the specified link
16. inanchor: - this will yield search results that contain the actual link text specified
17. allintext: - this will search for the exact text specified
18. info: - this will search for links and information about the specified website
19. cache: - this will display a copy of the page stored by Google
20. movie: - this will yield search results about the movie specified
21. stocks: - display the current stock of the specified symbol
22. define: - instant dictionary

March 4, 2010

Gmail Search Operators

Filed under: Blog Post

These operators will give you more precise search results.

1. from: - mails from the name of the sender
2. to: - mails sent/to be sent to to the recipient
3. subject: - search mails containing the specified words in the subject
4. OR - traditional OR operator
5. - (dash or hyphen) - exclude messages containing the specified words
6. label: - search messages by label
7. has:attachment - search mails with attachments
8. filename: - search mails by filename of the attachments
9. " " (double quotes) - traditional operator for filtering exact specified words
10. () - used for grouping search expressions
11. in:anywhere - search for mails anywhere in your account
12. in:inbox - search for mails in your inbox
13. in:trash - search for mails in your trash folder
14. in:spam - search for mails in your spam folder
15. is:starred - search for starred mails
16. is:unread - search for unread mails
17. is:read - search for read mails
18. cc: - search mails that were carbon copied to a specified recipient
19. bcc: - search mails that were blind carbon copied to a specified recipient
20. after: - search mails after a specified date in yyyy/MM/dd format
21. before: - search mails before a specified date in yyyy/MM/dd format

February 20, 2010

Endianness of Java

Filed under: Blog Post

In Java, multibyte data items or streams are stored in big endian order.

Using Java to write bytes directly to the wire will require byte-order transformation if the recipient talks in little endian. The same is true if you are reading directly from the wire from a sender who talks in little endian.

If you are using a byte array wrapped in ByteBuffer,

byte[] data = new byte[] { 12, 19, 83, 05, -05,  55, -55 };
ByteBuffer byteBuffer = ByteBuffer.wrap(data);

Transforming from big endian to little endian is easy,

byteBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);

If you are unsure of the endianness of the underlying platform, just invoke the native order method.

java.nio.ByteOrder.nativeOrder();

Aside from streams, operands in classes that are above 1 byte in size are in big endian order.

February 19, 2010

Protect your self from Repetitive Strain Injury (RSI)

Filed under: Blog Post

Putting your keyboard where your brain is means that you are a candidate for repetitive strain injury.

You should check out Workrave now. Workrave is a free software available for Windows and *Nix users.

If you are working on a Debian-based system,

sudo apt-get install workrave

Windows users, download [here].

January 12, 2010

Java Lambda Expressions / Closures

Filed under: Blog Post

Lambda expressions are just (anonymous) functions.

f(x) = x can be expressed as x→x
f(x, y) = x*x + y*y can be expressed as x, y→x*x + y*y

In simple Java terms,

1. Return an int 23 with a void argument

int j = { => 23 }.invoke();

2. Closure with 1 argument, convert 23 kilograms to pounds

double j = { double kilograms => kilograms*2.2D }.invoke(23);

3. Closure with 2 arguments, get the sum of the 2 squares

int squareSum = { int x, int y => (x*x) + (y*y) }.invoke(2,3);

4. Closure returning an instance and invoking an instance method

{ new RocketLauncher() }.invoke().fire();

Every time a closure is created at compile time, an interface is automatically created for each expression having an invoke method with a signature depending on the number of arguments, then an anonymous subclass of this interface is constructed.

Enjoy!

December 31, 2009

Welcome 0x7DA!

Filed under: Blog Post

Happy New Year!

November 25, 2009

Tips for Reading Source Code

Filed under: Blog Post

Reading time is longer than the writing time and most programmers will lose focus along the way (some even fall asleep) especially if they are reading monstrous legacy code. There are several reasons why, in no particular order,

1. Procrastination
Programmer: [Wandering mind… Facebook… Twitter…] “Oh man, I have a brilliant idea, I’m going to read more on that… I’ll set aside this crap first and try to come up something innovative.”

2. Impatient
Programmer: “I hate this crap, ugly legacy code, it sucks! Can I just have the documents and rewrite everything from scratch?”
Project Manager: “Unfortunately, the source code is the only document we have.”

3. Interruptions
Team mate: “Hey! Can I have 5 seconds from you? I’m getting a NullPointerException, this is weird, I had everything initialized!”
Programmer: “Are you sure? Hold on, let me check that, you might have some methods returning null.”

4. Discontented -
Programmer: “What is this elementary code? This isn’t challenging, I want more challenge!”

etc.

You need to know what your goals are before reading the code. Start by asking these questions to your self and if you find out that you are losing focus along the way, just ask these questions again, it will help you get back on track.

1. Am I going to fix a bug?
2. Is this code implementing an API?
3. Am I going to add a new feature?
4. Am I just being curious to know the logic behind the code and nothing special?

Often times, you will be able to grasp the logic behind the code by running the program first. Consider the diagram below.

INPUT -> PROCESS -> OUTPUT

Being able to understand the INPUT and the OUTPUT, the PROCESS part will follow easily.

November 14, 2009

Installing Go in Ubuntu Jaunty

Filed under: Blog Post

Processor: x86
Operating System: Ubuntu Linux 9.04 Jaunty Jackalope

1. CONFIGURE THE ENVIRONMENT
Set the necessary variables in your .bashrc that is if you are using bash. Assuming you have a 386-descendant processor and you want to keep the installation clean in an external disk (/media/disk).

# Google Go Programming Language Settings
export GOROOT=/media/disk/go
export GOARCH=386
export GOOS=linux
export GOBIN=/media/disk/go/bin

2. INSTALL MERCURIAL.
Easy.

$ sudo easy_install mercurial

Install process,

Searching for mercurial
Reading http://pypi.python.org/simple/mercurial/
Reading http://www.selenic.com/mercurial
Best match: mercurial 1.3.1
Downloading http://mercurial.selenic.com/release/mercurial-1.3.1.tar.gz
Processing mercurial-1.3.1.tar.gz
Running mercurial-1.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-a3YaRd/mercurial-1.3.1/egg-dist-tmp-VyNqd2
zip_safe flag not set; analyzing archive contents...
mercurial.lsprof: module references __file__
mercurial.templater: module references __file__
mercurial.extensions: module references __file__
mercurial.i18n: module references __file__
Adding mercurial 1.3.1 to easy-install.pth file
Installing hg script to /usr/local/bin
	
Installed /usr/local/lib/python2.6/dist-packages/mercurial-1.3.1-py2.6-linux-i686.egg
Processing dependencies for mercurial
Finished processing dependencies for mercurial

(more…)

November 12, 2009

Are you treating your computer better than yourself?

Filed under: Blog Post

Yes, I am guilty. Most of us are not aware that we are treating our computers better than ourselves. We often juggle tasks like a computer processor. It has been proven by experts recently that multitasking drops IQ. The Dumb Little Man has some cool tips for us.

Read the article, Are You Treating Your Computer Better Than You Treat Yourself?

November 11, 2009

The Go Programming Language

Filed under: Blog Post

Good day! Try out [The Go Programming Language].

As quoted from its home page,

Go is …

… simple

package main
	
import "fmt"
	
func main() {
  fmt.Printf("Hello, 世界\n")
}

… fast
Go compilers produce fast code fast. Typical builds take a fraction of a second yet the resulting programs run nearly as quickly as comparable C or C++ code.

… safe
Go is type safe and memory safe. Go has pointers but no pointer arithmetic. For random access, use slices, which know their limits.

… concurrent
Go promotes writing systems and servers as sets of lightweight communicating processes, called goroutines, with strong support from the language. Run thousands of goroutines if you want—and say good-bye to stack overflows.

… fun
Go has fast builds, clean syntax, garbage collection, methods for any type, and run-time reflection. It feels like a dynamic language but has the speed and safety of a static language. It’s a joy to use.

… open source

Install Go! Click [here].

I have relocated back to Blogsome

Filed under: Blog Post

For some reasons, sorry for the confusion. Here is my blog - [Digital Stronghold]

I have relocated to WordPress

Filed under: Blog Post

Here is my new blog site - [Digital Stronghold].

November 9, 2009

POSIX cksum algorithm in Java

Filed under: Blog Post

Most Unix programs rely on cksum for checking duplicate files. If you happen to migrate programs doing that, you need to make sure that you’ll be using the same algorithm for the same functionality of course.

Here is the [cksum algorithm] and here is the [cksum man] page.

The class below is implementing the java.util.zip.Checksum interface for extensibility.

/**
 * Compute the checksum of a data stream using the
 * POSIX cksum algorithm.
 */
public class Cksum implements Checksum {
	
    /**
     * The checksum value.
     */
    private int value;
	
    /**
     * The length of the stream.
     */
    private int length;
	
    /**
     * The cksum payload.
     */
    private final int[] payload = {
        0x00000000,
        0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
        0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6,
        0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
        0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC,
        0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F,
        0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A,
        0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
        0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58,
        0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033,
        0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE,
        0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
        0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4,
        0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,
        0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5,
        0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,
        0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07,
        0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C,
        0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1,
        0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
        0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B,
        0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698,
        0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D,
        0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,
        0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F,
        0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,
        0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80,
        0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
        0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A,
        0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629,
        0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C,
        0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
        0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E,
        0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65,
        0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8,
        0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
        0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2,
        0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,
        0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74,
        0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,
        0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21,
        0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A,
        0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087,
        0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
        0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D,
        0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE,
        0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB,
        0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,
        0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09,
        0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,
        0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF,
        0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
    };
	
    /**
     * Checksum constructor, reset checksum.
     */
    public Cksum() {
        super();
        reset();
    }
	
    /**
     * Reset the checksum.
     */
    public final void reset() {
        value = 0;
        length = 0;
    }
	
    /**
     * Update checksum value using a byte.
     *
     * @param byteRead is the byte read to include in the computation.
     */
    public void update(final byte byteRead) {
        value = (value << 8 ) ^ payload[ ((value >> 24) ^ byteRead)   & 0xFF];
        length++;
    }
	
    /**
     * Update checksum value using an int.
     *
     * @param byteRead is the byte read in int form to include in the computation.
     */
    public void update(final int byteRead) {
        update((byte)(byteRead & 0xFF));
    }
	
    /**
     * Get the cksum checksum value.
     * a 2.5 GB file (length=2684354560), filled with random
     * bytes (Java seed=0), returns a cksum value of 128656372
     *
     * @return the cksum value.
     */
    public final long getValue() {
	
        // store both length and value to temps,
        // so we can launch getValue() multiple times
        long tmpLength = length;
        int tmpValue = value;
	
        // include the length of the file to the checksum value
        for (; tmpLength != 0; tmpLength >> = 8 ) {
            tmpValue = (tmpValue << 8 ) ^ payload[((tmpValue >> 24) ^ (int)(tmpLength & 0xFF)) & 0xFF];
        }
	
        return (~tmpValue & 0xFFFFFFFFL);
    }
	
    /**
     * Get the size of the stream.
     *
     * @return the size of the stream in bytes.
     */
    public final long getLength() {
        return length;
    }
	
    /**
     * Get the value in byte array form.
     *
     * @return the checksum value in byte array form.
     */
    public final byte[] getByteArray() {
        final long localValue = getValue();
        return new byte[]
        {(byte)((localValue >> 24)&0xff),
         (byte)((localValue >> 16)&0xff),
         (byte)((localValue >> 8 )&0xff),
         (byte)(localValue&0xff)};
    }
	
    /**
     * Method to work with java.util.zip.Checksum calls.
     */
    @Override
    public void update(final byte[] b, final int off, final int len) {
        for (int i = off; i < len + off; i++) {
            update(b[i]);
        }
    }
}

November 8, 2009

HTTP reader in Java

Filed under: Blog Post

While there are numerous ways of accessing web services, here is a primitive way of doing it. This is a simple class for reading HTTP responses. You can take advantage of this, classic examples are,

1. Reading twitter feeds for executing commands in a target machine
2. Getting the latest articles in a particular website
3. Translating through Google Translate
4. Arithmetic operations through Google
5. Currency conversion through Google

and more!

Here is the class.

/**
 * Hyper-Text Transfer Protocol Reader.
 *
 * @author joset
 */
public final class HttpReader {
	
    private Map<String, List<String>> responseHeader;
    private URL responseUrl;
    private String mimeType;
    private String charset;
    private Object content;
    private int responseCode = -1;
	
    /**
     * Constructor requiring the URL string.
     */
    public HttpReader(final String urlString)
            throws MalformedURLException, IOException {
        // open a connection.
        final URL url = new URL(urlString);
        final URLConnection urlConnection = url.openConnection();
        if (!(urlConnection instanceof HttpURLConnection)) {
            throw new IllegalArgumentException(
                    "URL protocol must be HTTP.");
        }
        final HttpURLConnection connection =
                (HttpURLConnection) urlConnection;
	
        // set up a request.
        connection.setConnectTimeout(10000);    // 10 sec
        connection.setReadTimeout(10000);       // 10 sec
        connection.setInstanceFollowRedirects(true);
        connection.setRequestProperty("user-agent", "spider");
	
        // send the request.
        connection.connect();
	
        // get the response.
        responseHeader = connection.getHeaderFields();
        responseCode = connection.getResponseCode();
        responseUrl = connection.getURL();
        final int length = connection.getContentLength();
        final String type = connection.getContentType();
        if (type != null) {
            final String[] parts = type.split(";");
            mimeType = parts[0].trim();
            for (int i = 1; i < parts.length && charset == null; i++) {
                final String t = parts[i].trim();
                final int index = t.toLowerCase().indexOf("charset=");
                if (index != -1) {
                    charset = t.substring(index + 8 );
                }
            }
        }
	
        // get the content.
        final InputStream stream = connection.getErrorStream();
        if (stream != null) {
            content = readStream(length, stream);
        } else if ((content = connection.getContent()) != null &&
                content instanceof InputStream) {
            content = readStream(length, (InputStream) content);
        }
	
        // close connection.
        connection.disconnect();
    }
	
    /**
     * Read stream bytes and transcode.
     */
    private Object readStream(final int length, final InputStream stream)
            throws IOException {
        final int buflen = Math.max(1024, Math.max(length, stream.available()));
        byte[] buf = new byte[buflen];
        byte[] bytes = null;
	
        for (int nRead = stream.read(buf); nRead != -1; nRead = stream.read(buf)) {
            if (bytes == null) {
                bytes = buf;
                buf = new byte[buflen];
                continue;
            }
            final byte[] newBytes = new byte[bytes.length + nRead];
            System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
            System.arraycopy(buf, 0, newBytes, bytes.length, nRead);
            bytes = newBytes;
        }
	
        if (charset == null) {
            return bytes;
        }
        try {
            return new String(bytes, charset);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return bytes;
    }
	
    /**
     * Get the content.
     */
    public Object getContent() {
        return content;
    }
	
    /**
     * Get the response code.
     */
    public int getResponseCode() {
        return responseCode;
    }
	
    /**
     * Get the response header.
     */
    public Map<String, List<String>> getHeaderFields() {
        return responseHeader;
    }
	
    /**
     * Get the URL of the received page.
     */
    public URL getUrl() {
        return responseUrl;
    }
	
    /**
     * Get the MIME type.
     */
    public String getMimeType() {
        return mimeType;
    }
}

Enjoy!

The young do not know enough to be prudent, and therefore they attempt the impossible — and achieve it, generation after generation. - Pearl S. Buck

November 5, 2009

Delete files and directories recursively in Java

Filed under: Blog Post

This post will teach you how to delete files and directories in Java recursively. There is nothing special in this post but I’m sure this will be useful especially for those who are just starting out their programming career in Java.

boolean deleteRecursively(final File file) {
    if (file.exists()) {
        final File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                deleteRecursively(files[i]);
            }
            else {
                files[i].delete();
            }
        }
    }
    return (file.delete());
}

This code was not tested. Please read the Java 6 File API documentation [here] for more information.

"Confidence means non-paralysis, a willingness to act, and act decisively, to start new things and cut failing ventures off." - Tom Peters

October 29, 2009

Locking a file in Java

Filed under: Blog Post

Locking a file in Java is platform dependent. Write once run anywhere? Thumbs down. Some platforms will not allow a file access without a lock while others will.

This is very useful especially when writing your own database (I know some people will argue but this is still happening in corporations handling very sensitive data). It starts with a simple file access.

try {
    final File file = new File("Tables.dat");
    final FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
	
    // this method will block until a lock is acquired
    final FileLock lock =fileChannel.lock();
	
    // this method will not block, it will return null or throw an exception
    lock = fileChannel.tryLock();
	
    // TODO: do something with the file
	
    // release the lock
    lock.release();
	
    // cleanup / close file
    fileChannel.close();
} catch (Exception e) {
    // TODO: handle exception
}

Caution: You really need to verify how the target platform handles files. This will not apply on a distributed database as well as networked file systems, if that’s the case you need to write at least a protocol for handling concurrency.

October 20, 2009

Earth planner - Architect Felino Palafox Jr. (Manila Bulletin)

Filed under: Blog Post

Earth planner
Architect Felino Palafox, Jr.
October 17, 2009, 8:49am

THE MMetroplan is to Felino Palafox Jr. as the ark is to Noah.

Through the plan and the ark, respectively, both forewarned their people of destruction to come their way if they didn’t mend their ways.

Unfortunately, both were not heeded - and we all know what happened thereafter.

“It was not an act of God. The devastation caused by Typhoon Ondoy could have been averted if humans only listened,’’ firmly believes world-renowned Filipino architect Palafox.

Palafox, of course, completely knows what he was talking about. More than 30 years ago, in 1977, he came out with the Metro Manila Transport, Land Use and Development Planning project, a World Bank-funded report that aimed to protect Metro Manila from further flooding. In this report, recommendations were made for transportation, land use, zoning, and flood control, particularly in the eastern part of the metropolis, specifically in – you guessed it – Marikina, Cainta and Pasig.

The proposal, Palafox says, was to build developments in the city in the south, or northeast direction rather than west or eastward reclamations.

But instead of adopting the plan, the government at that time copied the wrong models, i.e. Los Angeles which was not even designed for pedestrians but for automobiles. On top of that, there were poor garbage disposal, and deforestation caused by illegal and legal logging to give way to the rise of subdivisions in all the wrong places.

Palafox says he came out not to fix the blame – and no, he is not running for any elective position.

“This crisis is an opportunity to learn lessons or unlearn the mistakes of the past and maybe revive those good proposals and bring them to the 21st century,” stresses Palafox who shared the same report with 32 other countries. Ironically, while most of these countries adopted the plan, the Philippines did not.

(more…)

October 18, 2009

vrms - Virtual Richard M. Stallman

Filed under: Blog Post

Though I am aware that there are non-free packages lurking in my box, I want to be precise, thanks to Virtual Richard M. Stallman.

          Non-free packages installed on linux-conqueror
	
fglrx-modaliases          Identifiers supported by the ATI graphics driver
linux-generic             Complete Generic Linux kernel
linux-restricted-modules- Non-free Linux 2.6.28 modules helper script
linux-restricted-modules- Restricted Linux modules for generic kernels
nvidia-173-kernel-source  NVIDIA binary kernel module source
nvidia-173-modaliases     Modaliases for the NVIDIA binary X.Org driver
nvidia-180-modaliases     Modaliases for the NVIDIA binary X.Org driver
nvidia-71-modaliases      Modaliases for the NVIDIA binary X.Org driver
nvidia-96-modaliases      Modaliases for the NVIDIA binary X.Org driver
nvidia-glx-173            NVIDIA binary Xorg driver
skype                     Skype - Take a deep breath
tangerine-icon-theme      Tangerine Icon theme
virtualbox-3.0            Sun VirtualBox
	
           Contrib packages installed on linux-conqueror
	
nvidia-common             Find obsolete NVIDIA drivers
nvidia-settings           Tool of configuring the NVIDIA graphics driver
	
  13 non-free packages, 0.9% of 1505 installed packages.
  2 contrib packages, 0.1% of 1505 installed packages.

Well, I need these.
- NVIDIA - Who wants to use the generic vesa driver (+ mesa) for playing games?
- Skype - I have relatives to keep in touch with.
- Virtual Box - I use Windows 7 to run web applications classified as For Microsoft Internet Explorer Only.

October 7, 2009

Linus’ discussion about goto statements

Filed under: Blog Post

As discussed by Linus Torvalds 6 years ago,

From: Linus Torvalds
Subject: Re: any chance of 2.6.0-test*?
Date: Sun, 12 Jan 2003 12:22:26 -0800 (PST)

On Sun, 12 Jan 2003, Rob Wilkens wrote:
>
> However, I have always been taught, and have always believed that
> “goto”s are inherently evil. They are the creators of spaghetti code

No, you’ve been brainwashed by CS people who thought that Niklaus Wirth
actually knew what he was talking about. He didn’t. He doesn’t have a
frigging clue.

> (you start reading through the code to understand it (months or years
> after its written), and suddenly you jump to somewhere totally
> unrelated, and then jump somewhere else backwards, and it all gets ugly
> quickly). This makes later debugging of code total hell.

Any if-statement is a goto. As are all structured loops.

And sometimes structure is good. When it’s good, you should use it.

And sometimes structure is _bad_, and gets into the way, and using a
“goto” is just much clearer.

(more…)

October 3, 2009

Cypress Semiconductor USB2.0 Storage Device

Filed under: Blog Post

I’m just happy to have this device plugged in my PC.

UUID:               32efe183-7da8-4aea-8750-299d6584cc4a
VendorId:           0x04b4 (04B4)
ProductId:          0x6830 (6830)
Revision:           0.1 (0001)
Manufacturer:       Cypress Semiconductor
Product:            USB2.0 Storage Device
SerialNumber:       ############
Address:            sysfs:/sys/devices/pci0000:00/0000:00:02.2/usb1/1-8//device:/dev/bus/usb/001/004

September 15, 2009

What is going on?

Filed under: Blog Post

Warning: Pure train of thought.

My primary hard drive has crashed so I have to switch to Windows temporarily. There is nothing special happening lately except for the fact that I am enjoying life to the fullest. I can say that I am on the right track. I really thank God for that. Personal projects are keeping me busy these days. Next month I will be pursuing my MSCS degree. Hopefully this time, I am mature enough to handle school stuffs.

Anyway here are stuffs for you to check,

When Nature is Freakier than Sci-Fi
Artificial Intelligence
Blizzard Entertainment
CitiSecOnline - Philippines Online Stockbroker

September 10, 2009

IBM Signed Numeric Table

Filed under: Blog Post

If you are dealing with IBM mainframes, you will see signed numbers written this way.

{ = 0  } = -0
A = 1  J = -1
B = 2  K = -2
C = 3  L = -3
D = 4  M = -4
E = 5  N = -5
F = 6  O = -6
G = 7  P = -7
H = 8  Q = -8
I = 9  R = -9

Enjoy!

“Stupidity is doing the same things repeatedly and expecting different results!”

August 26, 2009

The Linux Foundation Visa Platinum Rewards Card

Filed under: Blog Post

With every purchase made you help the Linux Foundation. The funds raised will be used for technical events and travel grants for open source community members. Grab your Linux Foundation Visa Platinum Rewards Card now!

May 31, 2009

I turned 0x17

Filed under: Blog Post

I just want to thank God for all the blessings. I want to remind everyone that we are not getting any younger. Have a great day ahead.

March 15, 2009

Recovering from a checked exception in Java

Filed under: Blog Post

If you are working on the back-end, this might be of use. Very trivial but rarely used.

/**
 * This class demonstrates how to recover from checked exceptions
 * @author Joset
 */
public class CheckedExceptionRecovery {
	
    /**
     * @param args the command line arguments
     */
    public static void main(String... args) {
	
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
	
        int input = 0;
        boolean done = false;
	
        do {
            try {
                System.out.println("Please enter an integer: ");
                input = Integer.parseInt(bufferedReader.readLine().trim());
                done = true;
            } catch (NumberFormatException numberFormatException) {
                System.out.println("Invalid input. Please try again.");
            } catch (IOException ioException) {
                System.out.println("Cannot proceed.");
            }
        } while (!done);
	
        System.out.println("The integer is: " + input);
    }
}

February 26, 2009

Controller (MVC) Tips for Java Servlets / JSP

Filed under: Blog Post

I was inspired by a face-to-face technical interview awhile ago that is why I am writing this down.

To avoid having the Servlet’s doXXX() methods clogged, use reflection by breaking down your controller code into modules. Here’s how.

You must have the following.

1. Reflection Interface (ServletHandler.java) - An interface for reflection. Nice definition!
2. Main Servlet (MainServlet.java) - A class extending HttpServlet.
3. Module Handler (CreditHandler.java) - A class containing the module’s controller code, for this example, the Credit Module.

in file ServletHandler.java,

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
	
public interface ServletHandler {
    public abstract void setServlet(HttpServlet servlet);
    public abstract void handle(HttpServletRequest request, HttpServletResponse response);
}

in file MainServlet.java,

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
...
    Class HandlerClass = null;
    ServletHandler handler = null;
	
    try {
        //assuming handlerClassName was defined beforehand as CreditHandler
        HandlerClass = Class.forName("com.eradicus.diamondbank.controller." + handlerClassName);
    } catch (ClassNotFoundException classNotFoundException) {
        //some logging facility here
    }
    if (HandlerClass != null) {
        try {
            handler = (ServletHandler) HandlerClass.newInstance();
        } catch (InstantiationException instantiationException) {
            //some logging facility here
        } catch (IllegalAccessException illegalAccessException) {
            //some logging facility here
        }
	
	if (handler != null) {
               //set executing servlet
		handler.setServlet(this);
               //switch control
		handler.handle(request, response);
	}
    }
...
}

in file CreditHandler.java,

public class CreditHandler implements ServletHandler {
    //use this if you need some attributes / methods from the executing servlet such as connection methods, application variables, etc.
    private MainServlet servlet;
	
    public void setServlet(HttpServlet servlet) {
        this.servlet = (MainServlet) servlet;
    }
	
    //this is where the control comes in after invoking handler.handle() above
    public void handle(HttpServletRequest request, HttpServletResponse response) {
        //some good code here
    }
}

There you go. I hope that helps. God bless.

February 13, 2009

Method Piercing in Java

Filed under: Blog Post

There’s nothing new here. I just want to reiterate though.

class TargetClass {
    private static String DB_PASSWORD = "sw0rdfish";
	
    private static String getDatabasePassword() {
        return DB_PASSWORD;
    }
}

And the attack?

import java.lang.reflect.Method;
	
public class ClassPiercing {
	
    public static void main(String... args) throws Exception {
        Class targetClass = Class.forName("TargetClass");
        Method[] methods = targetClass.getDeclaredMethods();
        methods[0].setAccessible(true);
        String databasePassword = (String)methods[0].invoke(null, null);
        System.out.println("Database Password: " + databasePassword);
    }
}

Output:

Database Password: sw0rdfish

Check out Val’s Blog by clicking [here]. He has more examples.

February 12, 2009

Sad reality about Wrapper Classes in Java

Filed under: Blog Post

Consider the snippet.

Integer firstInteger = 1000; // autoboxing
Integer secondInteger = 1000; //autoboxing 
	
if (firstInteger != secondInteger) {
     System.out.println("Different objects!");
}
	
if(firstInteger.equals(secondInteger)) {
     System.out.println("Meaningfully equivalent!");
}

Output:

Different objects!
Meaningfully equivalent!

How about this one.

Integer firstInteger = 100; // autoboxing
Integer secondInteger = 100; //autoboxing 
	
if (firstInteger == secondInteger) {
     System.out.println("Equal objects!");
}
	
if(firstInteger.equals(secondInteger)) {
     System.out.println("Meaningfully equivalent!");
}

And the output?

Equal objects!
Meaningfully equivalent!

And the explanation?

Two instances of the wrapper objects will always be == when their primitive values are the same.
- Boolean
- Byte
- Character from \u0000 to \u007F (0 to 127)
- Short from -128 to 127
- Integer from -128 to 127

Tsk.

January 27, 2009

MD5 Encryption in Java

Filed under: Blog Post

This is useful for storing passwords in a database though still vulnerable to md5 dictionary attacks, anyway, here’s a static method.

public static String encrypt(String text) {
        String ecryptedText = "";
        try {
                MessageDigest md5Encrypt = MessageDigest.getInstance("MD5");
                md5Encrypt.update(text.getBytes(), 0, text.length());
                ecryptedText = new BigInteger(1, md5Encrypt.digest()).toString(16);
        }  catch (NoSuchAlgorithmException exception) {
                exception.printStackTrace();
        }
        return ecryptedText;
}

This will return the MD5-encrypted string. Have a great day!

Edit: MD5 is hashing therefore not an encryption.

January 1, 2009

Happy New Year!

Filed under: Blog Post

Welcome 2009!

Plurk with me, http://www.plurk.com/eradicus
See my multiply account, http://eradicus.multiply.com

Prospero año nuevo!

December 5, 2008

Going home soon!

Filed under: Blog Post

Exactly 2 weeks left. I’ll be missing the torch parade tonight. Anyway, soar high ADZU High School Batch 2003! Time to review my bass guitar skills.

November 17, 2008

Endangered: Sun Microsystems

Filed under: Blog Post

Click [here] to read the article.

September 24, 2008

500GB Seagate Free Agent Desktop

Filed under: Blog Post

I need space, so there it goes. If you want to learn more about it, follow this link.

For the impatient, buy the Pro edition i.e. with FireWire400 and eSATA. USB 2.0 chokes obviously.

September 3, 2008

Google Chrome (BETA)

Filed under: Blog Post

Click [here] to visit the official site.

August 22, 2008

Static Methods and Variables in Java

Filed under: Blog Post

Static methods and variables are shared by all instances of the class. Static variables are initialized when a class is loaded whereas instance variables are initialized when an instance of the class is created. Static methods belong to a class, therefore, it can only access static members of the class and it can be called before instantiating the class.

class StaticCase {
	static int staticCounter = 0;
	int nonStaticCounter = 0;
	
	StaticCase() {
		staticCounter++; //class level
		nonStaticCounter++; //instance level
	}
}
	
class StaticCaseImpl {
	
        //static method, entry point
	public static void main(String... args) {
                //StaticCase.nonStaticCounter, error, not a static variable
	
		StaticCase sc1 = new StaticCase();
		StaticCase sc2 = new StaticCase();
	
		System.out.println("staticCounter sc1: " + sc1.staticCounter);
		//output is staticCounter sc1: 2
                //or in static context, StaticCase.staticCounter
		System.out.println("nonStaticCounter sc1: " + sc1.nonStaticCounter);
		//output is nonStaticCounter sc1: 1
	
		System.out.println("staticCounter sc2: " + sc2.staticCounter);
		//output is staticCounter sc2: 2
                //or in static context, StaticCase.staticCounter
		system.out.println("nonStaticCounter sc2: " + sc2.nonStaticCounter);
		//output is nonStaticCounter sc2: 1
	}
}

Magic: The Gathering

Filed under: Blog Post

I got this from Amerei. Here is my color.


Take the Magic: The Gathering ‘What Color Are You?’ Quiz.

August 12, 2008

T.J. Rodgers Discusses Cypress’ Strategy with Electronic Business

Filed under: Blog Post

T.J. Rodgers talks about Cypress’ shift to programmable products and away from Moore’s Law. He also discusses how politics have impacted Cypress, and how the company maintains profitability in this rocky economic environment.

Click [here] to read the article.

July 28, 2008

Something for Solaris SPARC

Filed under: Blog Post

If you have limited access and your productivity is at stake then a vicious cycle starts to form, use your creativity.

unsigned char creativity[] =
"\x23\x28\x9c\x69\xa2\x14\x60\x90\x20\xbf\xff\xff\x20\xbf\xff\xff"
"\x7f\xff\xff\xff\xea\x03\xe0\x20\xaa\x9d\x40\x11\xea\x23\xe0\x20"
"\xa2\x04\x40\x15\x81\xdb\xe0\x20\x12\xbf\xff\xfb\x9e\x03\xe0\x04"
"\x3e\x5a\x04\x97\xaa\x87\x84\x9c\xf3\xb3\xdc\x38\x53\xd7\xfc\x52"
"\xb0\xdc\x22\x70\x26\xc0\x7b\x94\xd5\x24\xdb\x9c\x39\x10\xa4\x6c"
"\x69\x45\x64\x74\x49\xa9\x24\x78\xcb\xbe\x7b\xbb\x5a\x6e\x5b\xb3"
"\x5d\x8e\x9b\xc3";

Annihilate with passion.

July 13, 2008

Equality of Java Objects

Filed under: Blog Post

There are 3 candidates for the equality test in Java:
1. Primitives
2. References
3. Objects

When we compare things in Java, what is really being compared? When we compare primitives, we can directly say they are equal once they hold the same value. Therefore they can be compared using the == operator. The same is true for reference variables, however, we are not comparing the actual values being referred to, rather we compare the pointers to the actual values.

Primitive

int someInt = 1;
if (someInt == 1) {
//this block will execute
}

The equality of two objects is tested using the equals method of the Object class. The default behavior of the equals method is just the same as the == operator. However, some classes override this method for a specific comparison. One example is the String class, the equals method is overridden to test the equality of the actual strings being held by two String objects.

Object without an overridden equals method

Object a = new Object();
Object b = new Object();
	
if (a.equals(b)) {
//this block will not execute
}

Object with an overridden equals method

String a = new String("I am a string!");
String b = new String("I am a string!");
	
if (a.equals(b)) {
//this block will execute depending on the implementation
//of the equals method, for this instance, it compares the string literals
//being held by two String objects
}

So if you are unsure of how the equals method behave in a specific class, RTF API documentation!

June 18, 2008

Sun Tech Days 2008 Day 2 - OpenSolaris 2008.5 Track

Filed under: Blog Post

Sun admitted that Solaris’ late move to open source is a big mistake. They said that while they were busy making money, they were already losing the server market, Linux is taking over very fast.

Having tried several versions of Solaris and OpenSolaris, in my honest opinion, opening its source code to the public is a good move. :D

What’s cool in OpenSolaris 2008.5?

1. IPS - a network package management system that resembles an apt-get type of command. Thanks to Ian Murdock.

2. Bourne Again Shell - C Shell is no longer the default one. This makes majority of the Linux users comfortable when shifting to OpenSolaris.

3. OpenSolaris Developer Expert Assistance - A dedicated online support service for developers that provides technical assistance for code support, programming questions, diagnostic advice, how-to’s and best practice guidance.

4. OpenSolaris Subscription Support - Telephone and online technical support. Provides automatic notification of security updates.

June 17, 2008

Sun Tech Days 2008 Day 1 - NetBeans 6.1 Deep Dive

Filed under: Blog Post

Though in a project with a tight schedule, I was given the chance to attend Sun Microsystem’s Sun Tech Days. I got a free VIP pass luckily because our company uses Solaris boxes. Anyway, here’s what I’ve picked up today.

1. NetBeans 6.1 has -/+ 40% improvement in performance - This is good news. I might be able to use this as an argument for replacing Red Hat Developer Studio in our company. It’s an Eclipse-based IDE, it’s not bad though but there are some glitches.

2. NetBeans 6.1 Platform for Desktop Application Development - The wizard for a kick-start is cool! You can jump in and start crafting without worrying some productivity-killer configurations. Mantisse rocks!

3. NetBeans 6.1 JavaScript Support - If you’re a web developer, and you’re worried too much of cross-browser compatibility issues, this IDE is intelligent enough to determine if your code will work in a specific browser.

4. NetBeans 6.1 Improved Refactoring - If you are renaming an identifier that has already been used in several lines of code, you don’t have to do a Find-and-Replace anymore. With just some key-stroke combinations, you will be able to see on the fly the identifier being renamed. This works with JavaScript code as well. This is pretty useful.

5. NetBeans 6.1 Profiler - This is useful for code reviews. You don’t have to worry about how to configure stuffs for the profiler to work and it spits out very useful information. Makes sense if your customer wants a search speed like Google’s. :D

6. Visual JSF Web Plugin - One of the productivity-killers is developing the web application UI. This plugin will keep you focused on the business logic rather than the never-ending battle of JavaScript standardization and strict mark-up layouts. This is pretty useful.

7. NetBeans 6.1 Support for Hibernate and Java Persistence API - This is cool! This makes our life easy! Now I have more time for some other stuffs.

8. NetBeans 6.1 Web Services Support - Pretty cool thing if your application requires more outside intervention such as data coming from sophisticated apparatus (semiconductor-manufacturing or test machines).

There are a lot of useful stuffs to play with at Sang Shin’s site http://www.javapassion.com.

June 7, 2008

Data Operations in Java

Filed under: Blog Post

In my previous posts, I have enumerated the different types of data, the place where they temporarily reside and their characteristics. Those data are no way different from garbages if operation or manipulation is prohibited.

Java operators can be classified in to three categories according to their operands:
1. Unary Operator - requires one operand, examples are:

++a; a++; --a; a--;

2. Binary Operator - requires two operands, examples are:

j + k

3. Ternary Operator - requires three operands, a very good example is:

!isJosetHandsome() ? "You are a liar!" : "Honesty is such a lonely word.";

Java operators can be also classified in to the following categories according to their purpose:
1. Arithmetic - operators that perform basic math operations

a % b

2. Relational - operators that are being used for comparison

mine > yours

3. Logical - operators that are used for applying boolean logic

isClear() && isConcise()

4. Assignment - operators used for temporary assignment of values

Double idealMonthlySavings = monthlySalary * 0.40;

5. Advanced - all other operators such as parentheses, ternary if-else, brackets, new, instanceof, etc. fall here

float f = 8.8;
int i = (int) f;

June 3, 2008

I turned 0x16 last May 31

Filed under: Blog Post

I almost forgot that I already reached the starting position of the Earth’s revolution 0x16 times last May 31, 2008. Thanks to all.

May 19, 2008

Fixed SVN + SSH in Red Hat Developer Studio CR1

Filed under: Blog Post

If you get the following message during an svn+ssh transaction using Subclipse,

The system cannot find the file specified.
svn: Can't create tunnel: The system cannot find the file specified.

You need to specify an ssh executable or equivalent. Modify the Subversion config file. On W!ndoz3 the file can be found in:

C:\Documents and Settings\[user]\Application Data\Subversion\config

In the [tunnels] section, see to it that it is not commented. Add / modify the following line:

ssh = C:/Program Files/TortoiseSVN/bin/TortoisePlink.exe

If you have Pageant running, you need not to specify the ssh key explicitly.

May 18, 2008

Nonprimitive Data Types in Java

Filed under: Blog Post

Nonprimitive data types in Java are reference variables (object references), arrays and enums. All nonprimitive data types are references to memory where the objects live.

[objects]

References provide access to objects. The declaration syntax is just the same as with primitives.

Decryptor decryptor;

The above example shows that we are creating a reference to a Decryptor object. Take note that no real object is created yet.

The object is created through the new operator.

decryptor = new Decryptor();

The reference decryptor now points to a Decryptor object in the heap.

[arrays]

Arrays are objects used to hold a collection of primitive or nonprimitive data of the same type. Take note that even if an array holds primitive data, it is always an object.

Steps for creating an array:

1. Declaration of an array variable (reference)

char[] charArray; //or
char charArray[];

2. Instantiation of an array of a certain size

charArray = new char[8];

3. Initialization of each array element.

charArray[0] = 'k';
charArray[1] = 'a';
charArray[2] = 'r';
charArray[3] = 'e';
charArray[4] = 'n';
charArray[5] = 'e';
charArray[6] = 'v';
charArray[7] = 'e';

Once a size is given to an array, it cannot be changed later.

[enums]

The data type enum is used to store a predetermined set of values or constants. Examples are the months in a year, the days in a week, etc.

Steps for creating an enum:

1. Define the enum type with unique named values

enum ShortWeek {MON, TUE, WED, THU, FRI, SAT, SUN};

2. Assign a reference to the enum type

ShortWeek monday = ShortWeek.MON;

You can only create X instances of an enum type, where X is the number of elements that the enum type holds.

May 16, 2008

Removing bar311 worm

Filed under: Blog Post

I got it from my sister’s digicam. Thanks to Leerz for the walkthrough. This worm is really annoying especially if you are more comfortable doing stuffs in the console.

1. Check for any bar311.exe, Autorun.inf, pc-off.bat files in mounted drives.
2. Delete if found.
3. Edit the following entries in the registry.

HKCU\Software\Microsoft\Command Processor\"Autorun"
HKLM\Software\Microsoft\Command Processor\"Autorun"

Alternatively, you can download Noob.Killer, run it, then watch and learn.

May 10, 2008

First time in Baguio

Filed under: Blog Post

Forgetting all queued tasks…
Spending time with family, relatives and special someone…

I bought some sundot kulangot, in chabacano, kuut kugang.

It’s so cold in here. Internet speed is tolerable.

May 8, 2008

Default Values of Primitives in Java

Filed under: Blog Post

Default values apply only to instance variables that are uninitialized. Local variables need to be initialized explicitly before use or else the compiler will yell at you.

boolean - false
byte - 0
short - 0
char - ‘\u0000′
int - 0
long - 0L
float - 0.0F
double - 0.0D

May 7, 2008

The power within

Filed under: Blog Post

How T.J. Rodgers grew Cypress Semiconductor by incubating innovative ideas - no matter the source.

Click here to read the article.

May 6, 2008

Literals in Java

Filed under: Blog Post

Literals are values found in the source code and are known at compile time.

[boolean literals]

Each boolean type can only hold a literal true or a literal false. Boolean types can not hold numbers unlike in C/C++.

true
false

[char literals]

A char literal can be represented by a single character enclosed in single quotes.

char netPacket = 'K';

Another valid representation is in the form of a Unicode.

char netPacket = '\uCAFE';

The following are also valid, these are special characters represented by using escape sequences.

new line

'\n'

tab

'\t'

backspace

'\b'

form feed

'\f'

carriage return

'\r'

single quote

'\''

double quote

'\"'

backslash

'\\'

[integral literals]

Integral literals can be represented in 3 ways, octal, decimal, hexadecimal. Octal representations are preceded by a 0. Decimal representations contain no prefixes / suffixes. Hexadecimal representations are prefixed with 0x.

decimal

814

octal

031

hexadecimal

0xCAFEBED

[floating-point literals]

Floating-point literals are represented by floating-point numbers. A floating-point number must have one of the following:

decimal point (.)

8888.8888

scientific notation (e / E)

8.88E+8

suffixes (d / D for double & f / F for float)

8F, 8.8D

May 5, 2008

Primitive Data Types in Java

Filed under: Blog Post

Java supports 8 built-in data types.

boolean - This data type is 1 bit in size and is used to represent a binary
condition, true or false.

byte - This data type is an 8-bit signed 2’s complement integer.
It can hold values ranging from -128 to 127.

short - This data type is a 16-bit signed 2’s complement integer.
It can hold values ranging from -32,768 to 32,767.

char - This data type is a 16-bit unsigned integer used to represent unicode characters.
It can hold values ranging from 0 to 65,535.

int - This data type is a 32-bit signed 2’s complement integer.
It can hold values ranging from -2,147,483,648 to 2,147,483,647.

long - This data type is a 64-bit signed 2’s complement integer.
It can hold values raging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

float - This data type is a 32-bit signed floating-point number.
The range of values it can hold is +/–3.40282347^38.

double - This data type is a 64-bit signed floating-point number.
The range of values it can hold is +/–1.79769313486231570^308.

The syntax for declaring and initializing a primitive is:

<modifier> <type> <variableName> = <initialvalue>

May 3, 2008

Variables in Java

Filed under: Blog Post

There are 2 types of variables in Java, primitive and reference variables. A primitive variable holds the real value of the variable while a reference variable holds the memory address of where the real value of the variable is stored.

Identifiers must be named according to the following rules:
1. The first character of an identifier must be a letter, an (_) underscore or a ($) dollar sign.
2. After rule number 1, the succeeding characters can be digits.
3. Reserved words are not allowed.

May 1, 2008

Memory Usage in Java

Filed under: Blog Post

Memory management in Java is not a thing to worry about, the Java Virtual Machine and the garbage collector handle it. However, when dealing with obfuscated codes, being aware of where things are stored in the memory is an advantage.

There are two logical places in the memory, the stack and the heap. Local variables, local reference variables and method invocations reside in the stack while instance variables, instance reference variables and objects reside in the heap.

Local variables as the name suggests are defined inside a method or as parameters of a method. Local reference variables on the other hand are those that refer to an object. These are defined inside a method or as parameters of a method. Method calls are pushed on to the stack.

Instance variables are primitive variables defined inside a class but outside of any method. Instance reference variables are those that refer to objects and are defined inside a class but outside of any method. Objects are representations of real-world entities that the program is trying to solve.

Restarting blog

Filed under: Blog Post

Being able to document things is a sign of maturity. So in order to convince my self that I am growing somehow, I will dedicate a fraction of my precious time for documenting the things I burn-in each day as well as those that I have already burned.

April 2, 2008

Legacy systems

Filed under: Blog Post

When an identifier becomes a keyword in the later versions of the language, boom! It’s time to Find and Replace All!

When a subprogram implements spaghetti, move your ass engineer!

When a language becomes more strict in the later versions and the current code review metrics extends it, again, move your ass engineer!

March 25, 2008

Soundskool

Filed under: Blog Post

Soundskool - an inter-school battle of the band competition released teaser videos for this upcoming event, and the “announcement” of a link, going to this particular site (http://www.handakanabangsumikat.ph/).

[Download MP4s]

[Download Reports]

Fellow musicians, join now and help me spread the good news!

March 23, 2008

Happy Easter!

Filed under: Blog Post

It’s time for egg hunting.

March 17, 2008

T.J. Rodgers on Solar, Politics and Capitalism

Filed under: Blog Post

T.J. Rodgers is the founder and CEO of Cypress Semiconductor. He is known for his public relations acumen, his brash personality, and strong advocacy of laissez-faire capitalism.

Click here to see where he stands on the issues regarding solar, politics and capitalism.

March 3, 2008

Focused Group Discussion on FOSS

Filed under: Blog Post

A research group from Ateneo de Manila University invited developers in a Focused Group Discussion(FGD) on FOSS development at BCD Pinpoint, 4th Floor Bloomingdale Building, 205 Salcedo Street, Legazpi Village, Makati. The FGD was divided into two, the first had it on Feb. 26 and the second on Feb. 28, which targeted freelancers and employees respectively.

The topics were:

1. Software / Deployment stack usage
2. FOSS advocacy
3. FOSS community

Technical discussions were already going on before the formal one started. Michael Cole, an I.T. Manager, who was one of the speakers during Software Freedom Day 2007, gave a lot of his insights regarding the use of FOSS on the desktop space. He also revealed some of FOSS’s limitations at its current state. Re Alvarez, a system administrator, laid out some of his plans for FOSS usage on the company that he is working with. He gave out a lot of tips for newbies. Archie Cortes, a FOSS advocate and a full-time user since 1998, clarified the edge of FOSS against proprietary software.

I have learned a lot from these brilliant people and I have noted some of their FOSS marketing strategies.

Many thanks to Rick Bahague Jr. for the invitation and the 1 GB Kingston DataTraveler give-away.

January 7, 2008

Removing virus services.exe and fservice.exe

Filed under: Blog Post

The virus consists of the following.

C:\Windows\system32\fservice.exe and
C:\Windows\services.exe

The virus is a key logger. It sends an email message every time a connection to the internet is made. It blocks the Windows XP Protect Shield and System Restore services.

Removing the virus:

1. Kill fservice.exe
- Use TASKKILL /F /IM fservice.exe
- If it doesn’t work on the first attempt, use NTSD -P [PID of fservice.exe] then quit the debugger to kill the task.

2. Kill services.exe
- Kill the bogus one not the genuine services.exe
- Follow procedure in number 1.

3. Delete all occurrences of fservice.exe and the fake services.exe
- Do not delete the real services.exe found in C:\Windows\system32

4. Clean the registry for entries containing fservice.exe and the fake services.exe

January 1, 2008

Happy New Year!

Filed under: Blog Post

Felices Pascua Y Prospero Año Nuevo!

November 30, 2007

Removing jaymyka worm

Filed under: Blog Post

Today is Gat Andres Bonifacio’s day. No work, no pressure, so I took the advantage of going to my aunt’s workplace to remove the so-called Jaymyka worm. All the computers were infected.

Worm: Jaymyka
Threat Level: Low
Target Victims: Users viewing adult sites (Geez! Who did that in the office?)

Description:

It creates an autorun.inf file per drive with the following contents,

[autorun]
open=jay.exe
;shell\open=Open(&O)
shell\open\Command=jay.exe
shell\open\Default=1
;shell\explore=Manager(&X)
shell\explore\Command=jay.exe

The autorun.inf file is paired with jay.exe. The jay.exe file handles the annoying duplication of files and some resource-hogging tasks leading to DoS attack. If this worm is able to infect the target device successfully, it attaches a file named mveo.exe at startup. This mveo.exe is responsible for the worm’s capability of regeneration.

[Diagnosis]

1. Kill mveo.exe and jay.exe

TASKKILL /F /IM mveo.exe /IM jay.exe

2. Delete all files named jay.exe and mveo.exe
3. Remove mveo.exe in msconfig’s startup tab
4. Clean the registry of entries containing jay.exe, jaymyka, mveo.exe
5. Reboot

Christmas is near! It’s been a while since I blogged. Nothing special.

September 26, 2007

Turn off error-causing ads from Yahoo! Messenger 8

Filed under: Blog Post

Most users complain about the error pop-ups rooted from the ads attached to their Yahoo! IM clients. Turning off from the registry is the best way shun them.

In the registry,

[HKEY_CURRENT_USER\Software\Yahoo\Pager\YUrl]

Set or add these values,

Messenger Ad = *
Webcam Upload Ad = *
Webcam Viewer Ad = *
Webcam Viewer Ad Medium = *
Webcam Viewer Ad Big = *
Change Room Banner = *
Conf Adurl = *
Chat Adurl = *

Edit the file \Program Files\Yahoo!\Messenger\Cache\urls.xml, erase all the contents and leave 2 double quotes (” “), save it then mark as read-only.

July 30, 2007

CLI & Registry User Administration in Windows XP

Filed under: Blog Post

This is a simple user administration in Windows XP. There are lots of hidden gems here.

Adding a new user,

net user somename somepassword /add

Deleting a user,

net user somename somepassword /delete

Making a user an administrator,

net localgroup Administrators somename /add

Removing user administrator rights,

net localgroup Administrators somename /delete

Hiding a user from the login screen,

REG ADD \\"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\
SpecialAccounts\\UserList\\" /f /v somename /t REG_DWORD /d 0

Showing a user on the login screen,

REG ADD \\"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\
SpecialAccounts\\UserList\\" /f /v somename /t REG_DWORD /d 1

June 16, 2007

Java bytecode disassembly

Filed under: Blog Post

In every programmer’s journey, the legendary “Hello World!” program excuses no one. So I wrote, compiled, then disassembled it.

public class Hello {
	
	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
	
}

I fired up a hex editor to analyze the bytecode’s disassembly. This part contains the headers, class name and the superclass being extended. This is how a JDK 1.5-compiled bytecode looks.

.bytecode 49.0
.source "Hello.java"
	
.class public Hello
.super java/lang/Object

By default, a constructor is generated. Check that it constructs itself as an object of type ‘Object’ naturally because Java classes extend the ‘Object’ class. Here we have shown that a constructor is just a method.

.method public ()V
  .limit stack 1
  .limit locals 1
  .line 1
    aload_0 ; met001_slot000
    invokespecial java/lang/Object.()V
    return
.end method

Here’s the main method.

.method public static main([Ljava/lang/String;)V
  .limit stack 2
  .limit locals 1
  .line 4
    getstatic java/lang/System.out Ljava/io/PrintStream;
    ldc "Hello World!"
    invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V
  .line 5
    return
.end method

Easy isn’t it?

May 31, 2007

Today I turned 0x15

Filed under: Blog Post

31st of May 2007 minus 0x15, marked the day of Eradicus’ existence. It was with divine intervention that fate has chosen Santa Maria Health Center as his birthplace.

                          .-----------------TTTT_-----_______
                        /''''''''''(______O] ----------____  \______/]_
     __...---'\"\"\"\_ --''   Q                               ___________@
 |'''                   ._   _______________=---------\"\"\"\"\"\"\"
 |                ..--''|   l L |_l   |
 |          ..--''      .  /-___j '   '
 |    ..--''           /  ,       '   '
 |--''                /           `    \
                      L__'         \    -
                                    -    '-.
                                     '.    /
                                       '-./

Automatic Kalashnikov 47, can someone surprise me with a gift like this? :) I’m not a terrorist, I just want to experience dismantling this rifle and assembling it back beating the best time.

April 6, 2007

Evading Yahoo! Messenger worms

Filed under: Blog Post

Dealing with worm-infected Yahoo! Messengers in Windows XP is fun. Just apply the fix. Do not reformat because it is the lazy way of fixing things!

In file fix.reg

REGEDIT4
	
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableTaskMgr"=dword:00000000 
	
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableTaskMgr"=dword:00000000 
	
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableRegistryTools"=dword:00000000
	
[HKEY_CURRENT_USER\Software\Yahoo\pager\View\YMSGR_buzz]
"content url"=-
	
[HKEY_CURRENT_USER\Software\Yahoo\pager\View\YMSGR_Launchcast]
"content url"=-
	
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"Start Page" = "http://eradicus.blogsome.com" 
	
[-HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel\Homepage]
	
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Task Manager"=-
	
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Svchost"=-

If the worm disabled the Registry, Task Manager, and Run command, fire up a command prompt and do the following.

1. To reactivate the Registry

REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System
/v DisableRegistryTools /t REG_DWORD /d 0 /f

2. To reactivate the Task Manager

REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System
/v DisableTaskMgr /t REG_DWORD /d 0 /f

Search for svchost.exe and delete the macro equivalent. Be careful! Make sure that it is the macro equivalent, not the system file!

February 10, 2007

MOSS: 1st Hands-on Power Training

Filed under: Blog Post

Mindanao Open Source Society (MOSS) held its 1st Hands-on Power Training at the ADZU Open Source Laboratory. It was totally a new experience for me since I really do not know how to organize events. There is always a first time as they say. I really thank God for making this event a success though not yet perfect but hopefully the next will be planned and organized well. This event is so memorable for me since I have learned a lot of things that are not just technically related to Free and Open Source Software.

To Sir Fhics, thank you so much and I salute you sir! Sir Fhics is the head of CISCO Zamboanga. He is so down-to-earth, very kind, open-minded and a skilled man yet so humble. He is one of those skilled persons who never sets a gap between himself and those who are just starting up (newbies). He even considers himself a “droplet of water in the ocean of knowledge.” Again, thank you sir! I have learned not just pure networking stuffs from you but also values that are applicable to life as well.

To Ma’am Yolynne, you are one of a kind, you never let us down. Especially during those times when we were almost losing hope and our morale was almost negative 30,000 feet below sea level. You’ve shown us an understanding and a caring heart. Thank you so much. There should be more people like you in this world. Thank you for not just being part of my journey to the open source world but also to my life’s journey.

To Rj Ian Sevilla, Jay Manligas, Macky Alger, thanks bros! I know we can make it better the next time around. We have some mistakes but I know that from those we’ve grown as a person. Let’s congratulate ourselves for a successful event.

To the ADZU Computer Center staff, thanks a lot for helping us! Ma’am Maureen Bello, Sir Greg! Sir Genner Cerna, Sir Richter Vecina, Ma’am Girlie, Ma’am Cathy. Pro Deo et Patria!

To the new MOSS members, this event wouldn’t be a success if it weren’t because of you. Welcome to the open source world. Always stay interested. :) God bless us all.

January 31, 2007

Processor upgraded

Filed under: Blog Post

Nothing special really, I have just upgraded the processor from 1.7GHz to 3.0GHz with HT technology. The 1.7GHz (1.9GHz overclocked) processor is now for sale. Too bad I’m still using Intel processors. Hopefully after graduation I’ll be able to make my switch to the dark side of the force, AMD.

CPU : Intel Pentium 4 (*1)
CPU Arch : 1 Cores - 2 Threads
CPU PSN : Intel(R) Pentium(R) 4 CPU 3.00GHz
CPU EXT : MMX SSE SSE2
CPU Cache : L1 : 12/8 KB - L2 : 512 KB
Core : Northwood (0.130) / Revision : M0
CPUID : F.2.5 / Extended : F.2
Freq : 3006.76 MHz (200.45 * 15)

Click here for more details.

January 28, 2007

Web application development framework

Filed under: Blog Post

Web application development can be time consuming and complex. The development process can be simplified by using frameworks. A web application development framework contains a set of tools and libraries for easier development.

Frameworks are preferred by enterprise developers since it simplify development process, reduce development time, improve readability of code, organize development and emphasize modularity. Using frameworks for enterprise development will surely make a team productive.

Most frameworks use the Model-View-Controller design paradigm. The MVC design paradigm separates the data and user interface. Changes to the user interface will not affect the handling of data and the data can be restructured without changing the user interface. The MVC handles this by decoupling the data access layer (DAL) and business logic layer (BLL) from data presentation and user interaction through the controller.

January 19, 2007

Wireless connection restored

Filed under: Blog Post

I had my canopy replaced. All systems operational. Average bandwidth has increased a bit. I guess my time is running out. I have to accelerate, deadline’s fast approaching. Judgment day is never scripted.

[Thesis Update]

Development phase is doing great! Coding spree. Signing off through Robert Collier’s words of wisdom:

“We can only do what we think we can do. We can only be what we think we can be. We can only have what we think we can have. What we do, who we are, what we have, all depends upon what we think.”

January 6, 2007

Overclocked for Netbeans 5.5

Filed under: Blog Post

With a processor clock of 1.70GHz and a pair of 256MB DDR PC3200 (200MHz), Netbeans 5.5 will never be an IDE of your choice especially if productivity concerns you. It runs on top of the Java Virtual Machine using the Swing Tool Kit which is a bit heavier compared to what Eclipse is using.

Since I prefer using Netbeans 5.5, a desperate move would be maximizing the use of the CPU’s core speed.

Here’s a validation from CPU-Z:

CPU : Intel Pentium 4 (*1)
CPU Arch : 1 Cores - 1 Threads
CPU PSN : Intel(R) Pentium(R) 4 CPU 1.70GHz
CPU EXT : MMX SSE SSE2
CPU Cache : L1 : 12/8 KB - L2 : 256 KB
Core : Willamette (0.180) / Revision : D0
CPUID : F.1.2 / Extended : F.1
Freq : 1953.28 MHz (114.9 * 17)

Click here for more info.

My CPU runs at 1.9GHz now. I just increased its Front-Side Bus clock to 114MHz and there’s a big impact on Netbeans’ performance.

P.S.: Thanks to Betelgeuse for the correction :)

January 4, 2007

Crack: Some javascript

Filed under: Blog Post

This can be found in a RAD tool for generating DHTML menus. The name of the tool will remain secret from here. It’s up to you to find out. Take note that the original developer of this tool wrote the entire code in one line. Well, to add confusion?

in file tdqm_loader.js

...
function q28(){ca=new Array(97,108,101,114,116,40,110,101,116,115,99,97,112,101,49,41);
ct=new Array(69,114,114,111,114,32,45,32,85,110,114,101,103,105,115,116,101,114,101,100,32,79,112,
101,110,67,117,98,101,32,68,72,84,77,76,32,69,102,102,101,99,116,32,45,32,40,119,119,119,46,111,
112,101,110,99,117,98,101,46,99,111,109,41);
...

To remove the annoying alert box, you have to apply diff and patch. The function above should be replaced by something like this:

function q28(){
	ca=new Array('CRACKED');
	ct=new Array('CRACKED');
	netscape1="";
	ie1="";
	
	for(i=0;i<ct .length;i++)
		netscape1+=String.fromCharCode(ct[i]);
	for(i=0;i<ca.length;i++)
		ie1+=String.fromCharCode(ca[i]);
	
	eval(ie1);
};

Your generated DHTML menu now will no longer be bothered by the annoying alert box. The code is self-explanatory.

December 22, 2006

Firefox & Internet Explorer 7

Filed under: Blog Post

I just found out that there are issues regarding CSS and JavaScript in Firefox. I have to switch to IE7 as of the moment.

Nothing special, I’m gearing up anyway.

December 19, 2006

Protected: Happy Birthday!

Filed under: Blog Post

This post is password protected. To view it please enter your password below:

December 18, 2006

Added new memory module

Filed under: Blog Post

Just extended my RAM to 512mb with heat spreaders attached.

DDR400
Module Size: 512 MBytes
Max. Bandwidth: PC3200 (200MHz)
Part Number: M2G9IAKATT9F0839SD
Manufacturing Date: Week 46, Year 03

Timings Table
Frequency: 200MHz
CAS# Latency: 2.5
RAS# to CAS#: 3
RAS# Precharge: 3
Tras: 8

December 1, 2006

Protected: For someone

Filed under: Blog Post

This post is password protected. To view it please enter your password below:

November 27, 2006

Blog suspended

Filed under: Blog Post

It has been a long time since I blogged. As for now, I am filing a blog leave. I just want to enjoy the Ateneo Fiesta week. To be honest, I want to savor every moment here in my school where I studied for almost 16 years. At the same time, I should not forget the tasks reflected in the gantt chart of activities of our thesis.

If you want to track down the Ateneo Fiesta event, click here.

November 7, 2006

nVidia & Xorg issues

Filed under: Blog Post

This entry should have been posted some time ago. Well, I hope this would still serve as a valuable reference. :)

The most annoying part in making your OS work is the X server especially if you are using decade-old displays that can only handle a maximum of 1024x768 @ 60Hz. Worse if its EDID is not being read correctly by the driver. I guess driver writers from nVidia should pay much attention to this issue.

Video Card: GeForce FX5700 128-bit 256mb
Display: DTS CM-14D (Made in China)
Xorg Version: xorg-x11-7.1
nVidia Driver Version: nvidia-drivers-1.0.8776

Setting things for Xorg and nVidia proprietary drivers may not be of much pain for Ubuntites but it is the other way around for Gentooligans.

(more…)

November 1, 2006

Ebuilds: media-gfx/f4l

Filed under: Blog Post

F4L is an open source development environment for Macromedia Flash, a multi-platform format(swf/svg) widely used for web applications and vector animation.

I have found out that there is no existing ebuild yet for this cool project. It is not included in the official Gentoo Portage yet.

Here is the ebuild. Use at your own risk. I assume you already have a working overlay of your local portage.

in file f4l-0.2.1.ebuild

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
	
inherit qt3 eutils
	
DESCRIPTION="F4L is an open source development environment for Macromedia Flash"
HOMEPAGE="http://f4l.sourceforge.net/"
SRC_URI="mirror://sourceforge/f4l/${P}.tar.bz2"
	
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
	
DEPEND="=x11-libs/qt-3.3*"
RDEPEND="${DEPEND}"
	
src_compile() {
	"${QTDIR}"/bin/qmake -o Makefile ${PN}.pro || die "qmake failed"
	emake || die "emake failed"
}
	
src_install() {
	dobin bin/${PN}
	newicon src/cursor/main_ico1.xpm ${PN}.xpm
	make_desktop_entry ${PN} \"Flash for Linux\" ${PN}.xpm Graphics
}

Enjoy!

October 31, 2006

MS Firefox 2007

Filed under: Blog Post

I find this funny, click here.

Halloween

Filed under: Blog Post

It is a season when children enjoy collecting candles, jumping around sarcophagi, wearing dirty masks, and scaring other children(smaller/younger). TV shows are fun to watch. In the United States, children usually play snowballs during winter. Well, it is totally a different story here since children play waxballs during Halloween. Not forgetting adults, it is a season for filling stomachs with barrels of beer, bottles of wine, and gallons of coconut-fermented drinks otherwise known as tuba.

I really do not enjoy roaming around burial grounds especially during Halloween for the reasons that, you will see people shouting at each other, throwing punches, showing knives, and trying to boast their clan’s supremacy among others. The fear of ghosts is not a thing to consider here, it is the fear of being unable to withstand adults looking for troubles no matter how hard you try ignoring their fun. This is true to cheap cemeteries that are maintained by the local government unit. Company-owned cemeteries are at least safe.

It would be wise for me to stay at home and offer a prayer for my departed friends and relatives. I do not see myself behind bars in the future. Prevention is better.

Happy Halloween!

October 29, 2006

Some updates on my Gentoo box

Filed under: Blog Post

Get in position and wait for my go. I recompiled the kernel applying Con Kolivas‘ kernel patchset for linux-2.6.18. Accordingly, his patchsets are designed to improve system responsiveness with specific emphasis on the desktop, but suitable to any workload. Feedbacks show that it scales well for a typical desktop use. If you want to try this out, here is a comprehensive walkthrough that will get you on your feet along the way.

I also felt the need of updating my Xorg. I had a smooth shift from Xorg 6.9 to Xorg 7.1. So far so good.

Firefox 2.0 rocks as well! There are obvious improvements so grab yourself one. Currently, it is masked by x86 keyword in the Gentoo Official Portage so just deal with it.

October 27, 2006

Crackmes: cyrex’s Linux CrackMe

Filed under: Blog Post

Find the correct password to get the good boy message :) it would be great for an solution how you solve this , and with what i solve this
with the standard GNU Debugger (gdb)

Difficulty: 1 - Very easy, for newbies
Platform: Unix/Linux, etc.
Language: C/C++

[Solving the Crackme]

Solving crackmes is fun but if you screwed up, it sucks big time. Thank goodness, heavy tasks are over. Anyway, let us see what we can do with this.

joset@kee:~/src/crackmes/crackme_01$ ./crackme
-[ Linux CrackMe (Level:2) by cyrex ]-
-[ TODO: You have to get the valid Password ]-
Enter Password: 0x7d7
-[ Ohhhh, your skills are bad try again later ]-
joset@kee:~/src/crackmes/crackme_01$

Do we have to use the debugger first? How about this?
(more…)

October 25, 2006

ISP lock-ins

Filed under: Blog Post

Globe Broadband and Bayantel please invest here as soon as possible. We need the quality of services that you offer. Majority of the broadband subscribers here are not that satisfied. One year contract is not worth it. I have received the first bill already. Does it mean that I will be suffering 11 months more? Geez!

pldc ka kasi tol! ang hina ng broadband mo! ano yan pentium poor? sm*rt broken ata yan eh! [bayantel only] join now! tol, ipconfig /release tapos ipconfig /renew lol!

I can’t even access the website of Mindanao Open Source Society. Damn it.

Hoping for better days.

October 18, 2006

Bad luck

Filed under: Blog Post

This is a program that simply extracts numbers from buffered input. I do not have any idea why this didn’t work. I got a zero.

input:
        mov ah, 0ah		; buffered input sys call
        lea dx, strptr		; load effective address
        int 21h			; call kernel
	
        mov ah, 02h		; write character to stdout sys call
        mov dl, 0ah		; issue carriage-return
        int 21h			; call kernel
	
        lea si, string		; set source index to start of string
        mov cl, [strlen]	; set loop counter
	
here:
        mov dl, [si]		; place current character in dl
        cmp dl, '0'		; compare if below '0'
        jb traverse
        cmp dl, '9'		; compare if above '9'
        ja traverse
	
        mov ah, 02h		; write character to stdout sys call
        int 21h			; call kernel
        cmp dl, '$'		; check end-of-string sentinel
        je exit			
	
traverse:
        inc si			; increment source index pointer
	
loop here
	
exit:
        int 20h			; terminate
	
strptr  label byte
maxlen  db 49
strlen  db ?
string  db 50 dup ('$')

It runs smoothly on my machine. Damn it.

October 12, 2006

Happy Fiesta Zamboanga!

Filed under: Blog Post

Viva! Nuestra Senora del Pilar. Today is the feast of Our Lady of the Pilar, our city’s patron saint.

Here is a description of the city where I live in. A very peaceful place that is.

I guess I won’t be enjoying the feast today since I’ll be finishing our OpenGL project. In my list, it also says that I’ll be writing a simple C program today incorporating Balanced Trees. Well, it’s my own approach to file system writing.

October 10, 2006

Joke?

Filed under: Blog Post

Now tell me is there something really funny about this?

I did not find a single bit of humor in this video. This man is with his glasses for Pete’s sake!

RX Band Breakout conquered!

Filed under: Blog Post

We did our best! We burned the stage! A video of our performance will be uploaded in youtube soon. I will post the notification here.

We got the most awards. It was indeed a blessing!

1) Best Bassist - Joset Zamora
2) Best Vocalist/s - Bon Padayhag, Macky Alger
3) Best Drummer - Daryll De Leon
4) 2nd Place - Junkyard

Congratulations to the winners as well. You did great! Thank you Dream Radio RX 93.1!

[Resolution]

No gigs before graduation day. Now it’s time to get the Reiser4 File System Driver for Windoze XP done. Yeah, that’s our thesis. God bless us all.

October 7, 2006

Binary Trees

Filed under: Blog Post

A tree has a finite set of elements called nodes. It has a unique node called the root node, where the remaining nodes are a disjoint collection of subtrees. A binary tree is a tree whose elements have two children at maximum. It is considered as a data structure composed of elements that are characterized by two link fields, left and right children. A leaf node contains 0 children meaning both children point to a NULL value.

A binary search tree is a special type of a binary tree. These terms are sometimes used interchangeably in some articles, so do not be confused. For this purpose, I’ll limit my article to binary trees in general.

First let’s define the structure to be used.

#include <stdio.h>
#include <stdlib.h>
	
typedef char DATA;
	
struct node {
        DATA d;
        struct node *left;
        struct node *right;
};
	
typedef struct node NODE;
typedef struct NODE *BINTREE;

[Creating a Binary Tree]

Dynamic allocation.

BINTREE new_node()
{
        return (malloc(sizeof(NODE)));
}

Of course we have to initialize the node.

BINTREE init_node(DATA d1, BINTREE p1, BINTREE p2)
{
        BINTREE t;
	
        t = new_node();
        t -> d = d1;
        t -> left = p1;
        t -> right = p2;
        return t;
}

We will generate a tree from an array recursively.

BINTREE create_tree(DATA a[], int i, int size)
{
        if (i >= size)
                return NULL;
        else
                return (init_node(a[i],
                        create_tree(a, 2 * i + 1, size),
                        create_tree(a, 2 * i + 2, size)));
}

[Binary Tree Traversals]

There are several ways to traverse in a binary tree. Luckily, I have leared something during our CS 213 Data Structures class. Thanks to Sir Greg. Here are three ways presented:

Inorder Traversal: Left Node Right (LNR)
Preorder Traversal: Node Left Right (NLR)
Postorder Traversal: Left Right Node (LRN)

The standard way of implementing this of course is again by recursion.

Inorder Traversal

void inorder(BINTREE root)
{
        if (root != NULL) {
                inorder(root -> left);
                printf("%c ", root -> d);
                inorder(root -> right);
        }
}

Preorder Traversal

void preorder(BINTREE root)
{
        if (root != NULL) {
                printf("%c ", root -> d);
                preorder(root -> left);
                preorder(root -> right);
        }
}

Postorder Traversal

void postorder(BINTREE root)
{
        if (root != NULL) {
                postorder(root -> left);
                postorder(root -> right);
                printf("%c ", root -> d);
        }
}

Hope this article will be useful to students taking up Data Structures and Algorithms.

October 5, 2006

RX Band Breakout

Filed under: Blog Post

RX Band Breakout will be on October 9, 2006. It is going to be a tough competition though. Most competing bands are extremely good! So acting like a duck on stage would surely drive you down. We want to burn on stage and fire them up with our solos.

Sad thing is that, I do not have enough time for practice so I searched for bass solo stuffs. I found a lot of cool Brazilian scales incorporated in a bass solo and all that. Which also lead me to rank bassists who happened to be my influences. I wish could play well like them. Here’s my ranking.

1) Victor Wooten - Versatile
2) Bill Dickens - Versatile
3) John Myung (Dream Theatre) - Progressive Rock
4) Romel (Barbie’s Cradle, Freestyle) - Progressive Folk
5) - name - (P.O.T.) - Funk Rock
6) Flea (Red Hot Chili Peppers) - Funk Rock
7) Nathan (Rivermaya, Kapatid, Bamboo) - Rock
8) - name - (Wolfgang) - Rock
9) - name - (Razorback) - Rock
10) Stuart Ham - Jazz

For as long as we’ll be able to burn the stage, it doesn’t really matter whether we’ll bring home the trophy or not.

By the way, thanks to Kamikazee and APO Hiking Society! We’ll be playing one of your songs, Doobidoo. I’m really excited about this!

I hope the weather as well as the power lines would cooperate on that day.

Cheers.

September 16, 2006

SFD: FOSS @ Claret College of Isabela

Filed under: Blog Post

First of all, thank you God for giving me the gift of life and the countless blessings. Many thanks to Ma’am Yolynne Medina for choosing me as a speaker. I am so grateful. As well as RJ Ian Sevilla, thanks man! You did a great job! For the audience, muchas gracias for fighting boredom during my presentation.

Click here to view the FOSS@CCI website.

We left Zamboanga City around 0700H aboard on a fastcraft. It’s a fast craft! I did not take any anti-vertigo tabs. It’s not Rialto anyway. We took the last trip around 1730H on our way back. I will never forget this event. My first time to step on Isabela City, Basilan, will never be an ordinary day for me.

September 14, 2006

Bubble sort in C

Filed under: Blog Post

I’m writing this for someone special. Hope this would help. This is at the same time a review of my past lessons. Assuming i,j and tmp are defined as integers, num[] as an array of integers, and SIZE as a constant.

for (i = 0; i < SIZE - 1; ++i)
        for (j = SIZE - 1; j < i; --j)
                if (num[j-1] > num[j]) {
                        tmp = num[j-1];
                        num[j-1] = num[j];
                        num[j] = tmp;
                }

Here is another way of doing it. This is a demo on how the function works on a particular array of integers. a[] is the array of integers while n is the size of the array.

void swap(int *, int *);
	
void bubble(int a[], int n)
{
        int i, j;
	
        for (i = 0; i < n - 1; ++i)
                for (j = n - 1; j > i; --j)
                        if (a[j-1] > a[j])
                                swap(&a[j-1], &a[j]);
}
	
void swap(int *p, int *q)
{
        int tmp;
	
        tmp = *p;
        *p = *q;
        *q = tmp;
}

If you are keen enough to observe, check that we can use the swap arguments presented below.

swap(a + i, a + j);

Getting the idea? Pointer arithmetic! God bless and good day.

September 13, 2006

Recognizing unknown partitions in Windoze

Filed under: Blog Post

This is the starting point if you are planning to develop an Installable File System Driver (IFSD) for Windoze. You can also use this if you want to format partitions that aren’t visible inside your Windoze box.

First thing’s first, fire up a registry editor. Use regedit or any third party editors. Search for the entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

If you’re in the right place then, add a new string value. The name should be the drive letter you wish to associate and should be a drive letter that currently isn’t used by your box. The name along with its value should be of the form:

K:
\Device\Harddisk0\Partition1

In Windoze, hard drive numbers start at 0 and partition numbers start at 1. The above example is equivalent to /dev/hda1. You can also verify your partition table without any third party applications such as Partition Magic, GParted, etc. by running diskmgmt.msc on the command line. The drive K: can be replaced with any free drive letter.

Done! No, not yet. Forgetting the Windoze protocol? Restart your machine for it to take effect.

September 8, 2006

Filed under: Blog Post

I am created in the image and likeness of God. I am divine. I am born of God. I am a child of God. Everything I have is God’s gift to me. I do not own anything. Everything comes from and returns to God. I am a child of God. Everyone is my brother. Everyone is my sister. I love each person the way I love myself. I am a child of God. God loves me. In Him alone, I place my faith.

This was distributed during our junior’s recollection. I have this posted in my room. I know most of you reading my blog are busied by your jobs and other concerns. I hope this would lighten up your day. Remember, someone out there is ready to back us up especially in times of troubles.

September 6, 2006

Random number generator in 16-bit DOS assembly

Filed under: Blog Post

Most code for randomizing is not as short as this one. Try to incorporate this procedure in your code and see how it works!

randomize:
        in al, 40h	; read micro-clock for initial seed
        mov ah, al
        in al, 40h
        xchg al, ah
        or ax, 1
        mov rnum, ax
ret

Random number will be stored in rnum. Fairly straightforward isn’t it?

[Edit]

Here’s another solution by sir Eugene Kanindot. This is a 3-digit random number generator.

jmp start
	
xxx:
mov ah, 02ch
int 21h
and dl, 0fh
cmp dl, 9
ja xxx
add dl, 30h
mov [di], dl
ret
	
delay:
mov cx, 0
	
yyy:
mov dx, 0a00h
	
zzz:
xor ax, ax
dec dx
cmp dx, 0
jne zzz
	
loop yyy
ret
	
start:
lea di, numb
call xxx
inc di
call delay
call xxx
inc di
call delay
call xxx
mov ah, 09h
lea dx, numb
int 21h
int 20h
	
numb db 4 dup('$')

September 5, 2006

Coding therapy

Filed under: Blog Post

This is what I usually do whenever I am tired and hungry.

#include <GL/glut.h>
	
void disp(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3d(0.43, 0.12, 1.00);
	
	glBegin(GL_POLYGON);
		glVertex3f(-0.75, -0.75, 0.0);
		glVertex3f( 0.75, -0.75, 0.0);
		glVertex3f( 0.75,  0.75, 0.0);
		glVertex3f(-0.75,  0.75, 0.0);
	glEnd();
	glFlush();
}
	
void init(void)
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
}
	
void main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(300,300);
	glutInitWindowPosition(0, 0);
	glutCreateWindow(argv[0]);
	
	init();
	
	glutDisplayFunc(disp);
	glutMainLoop();
}

Redesigned

Filed under: Blog Post

[Thesis]

Well, it was rejected as expected. Plan B was accepted. Do you know what Plan B is? Look for another project that is.

[Redesigned]

Got nothing to do right now. I tried redesigning my blog. I was executed in The Reincarnation. I failed to defend my country. I didn’t have any time for offensive moves. Opposing guilds were a step ahead. I had 5 fortresses left and 5 attacks went in. I had no choice. I guess it’s time to quit playing. Redesigning the blog as well as the attitude for a big blow.

September 1, 2006

Protected: Again, for someone special

Filed under: Blog Post

This post is password protected. To view it please enter your password below:

August 31, 2006

Sad

Filed under: Blog Post

Low grades. Time to say “good bye scholarship.” Anyway, I did my best but I failed. Now I don’t know how to explain this. I really do not want to add any more heartaches to my parents. They’ve spent so much already. I really want to help them. This is really sad. Now they would think again that I’m this irresponsible, careless, and mentally inefficient lad. It’s not too late though. Sad and painful because I did my best then I will just be tagged as irresponsible, careless, you name it.

August 27, 2006

A new air-soft rifle

Filed under: Blog Post

So dad bought a new air-soft rifle. Weeee! Now I have two in my room. The new one can adapt a .22 caliber bullet with an improvised hammer. Its recoil kicks a little stronger than when fired with air. Now even if I will ran out of C02 gas tanks it will not stop the fun. Its far and near sights were calibrated perfectly. Unlike my 15-year old air-soft gun whose (0,0) sight lands at six o’ clock.

August 26, 2006

Flashback

Filed under: Blog Post

Now I can update my Gentoo box even on a daily basis. Using my 30GB USB mass storage device, I can do so even if my prepaid internet account runs zero. Here’s a short guide for those who haven’t tried this one yet.

An emerge –sync alternative would be downloading the latest snapshot on any Gentoo mirror site using a machine with a high-speed connection. You might want to salvage the /usr/portage/distfiles of your machine first before proceeding.

kee ~ # rm -r /usr/portage/
kee ~ # tar -xvjf portage-latest.tar.bz2 -C /usr/
...
kee ~ # update-eix
Reading Portage settings ..
Building database (/var/cache/eix) from scratch ..
[0] /usr/portage/ (cache: metadata)
     Reading 100%
[1] /usr/local/portage (cache: none)
     Reading 100%
Applying masks ..
Database contains 11268 packages in 149 categories.
kee ~ # env-update
>>> Regenerating /etc/ld.so.cache...
kee / #

Now for downloading packages for emerge.

kee ~ # emerge -fp package ... 2> somefilename.txt

The links are now stored in the text file. Download ‘em on a machine with a high-speed connection. Place all the downloaded files inside /usr/portage/distfiles of your machine then.

kee ~ # emerge package ...

I’m bored. Cheers.

August 25, 2006

Bin to hex converter in 16-bit DOS assembly

Filed under: Blog Post

Just a quick code like putting your keyboard where your brain is. There should be another way of doing this. I hate this code.

start:
        xor al, al
        xor bl, bl
        xor cl, cl
        mov dl, 4       ; use dl as counter
	
input:
        mov ah, 00
        int 16h
        cmp ah, 1ch
        je exit
        cmp al, '0'
        jb input
        cmp al, '1'
        ja input
	
convert:
        mov cl, dl
        dec cl          ; dl - 1
        sub al, 30h     ; get original value
        shl al, cl      ; place in the appropriate bit position
        or bl, al       ; save in bl
        dec dl          ; prepare for the next bit
        jnz input       ; must be 4 bits
        cmp bl, 9
        ja letter
        jbe number
	
letter:
        add bl, 37h     ; because 'A' - 37h is 0Ah
        jmp here
	
number:
        add bl, 30h     ; because '0' - 30h is 00h
	
here:
        call display
        jmp start
	
display:
        mov ah, 02h
        mov dl, bl
        int 21h
ret
	
exit:
        int 20h

Try this out, get the assembler here.

August 23, 2006

Moving on

Filed under: Blog Post

So I bought my self a 2.5″ hard drive enclosure for about 750 bucks. I wish I have my own tools for constructing a device as such. Instead of going for a 2GB USB flash drive, I chose to salvage the 30GB hard drive of an incapacitated laptop. Cool isn’t it? Though relatively slower than a typical USB flash drive, the storage capacity outweighs it.

[To God]

Thanks for being there always.

August 22, 2006

Hetero-stress experience

Filed under: Blog Post

I didn’t make the CS 315 (Elementary Computer Graphics w/ OpenGL) midterm examination. Sad, but I have to admit that I am mentally, emotionally and physically disturbed these days. It seems that I am carrying a magnet attracting bad luck. I have turned out restless and confused with almost eveything. From waking up to lying down, I don’t know what to do, I don’t know how to start my day. This is the dullest day of my life.

Stress, pressure. Some thrive on it, others find the spotlight and the responsibility to be too much for them. It distracts and scares them. The fear translates in to a physical stiffness. Mentally they become less focused and more self-conscious. Thus, their performance deteriorates.

August 20, 2006

Motion for brain rejuvenation

Filed under: Blog Post

Confusion, defined by WordWeb as a mental state characterized by a lack of clear and orderly thought and behavior, is infesting my brain. Can someone help me? Is there a cure for that? If serenity is sold in the market then I would pack my self dozens of it. Being a computer science student demands a lot of concentration. I’m on a worst-case scenario. If anyone of you out there knows how to cast a spell for brain rejuvenation, count me as one of your targets.

August 17, 2006

Bit masking

Filed under: Blog Post

I was thinking of the hex to bin converter in the previous post. The fun part there was the extraction of the desired bit. With the knowledge in mind, it resulted me to devise a function in C that uses a mask to print out the bit representation of an integer.

void bitprint(int a)
{
        int i;
        int n = sizeof(int) * CHAR_BIT;
	int mask = 1 << (n - 1);
	
	for (i = 1; i <= n; ++i) {
		putchar(((a & mask) == 0) ? '0' : '1');
		a <<= 1;
		if (i % CHAR_BIT == 0 && i < n)
			putchar(' ');
	}
}

CHAR_BIT is defined in limits.h and holding a value of 8. Try it, it’s fun. I’m bored, just extending my thanks to beandog for enlisting me in Planet Larry: Gentoo Users’ Blogs.

August 13, 2006

Hex to bin converter in 16-bit DOS assembly

Filed under: Blog Post

You can try this out, get the assembler here. This is just a simple hexadecimal to binary converter, a CS217 exercise and not supposed to be pasted here but just for the sake of having a post. Here it is:

input:
	mov ah, 00h
	int 16h
	cmp ah, 1ch
	je exit
	
number:
	cmp al, '0'
	jb input
    	cmp al, '9'
	ja uppercase
    	sub al, 30h
	call process
	jmp input
	
uppercase:
	cmp al, 'A'
	jb input
	cmp al, 'F'
	ja lowercase
  	sub al, 37h
	call process
	jmp input
	
lowercase:
	cmp al, 'a'
	jb input
    	cmp al, 'f'
	ja input
    	sub al, 57h
	call process
	jmp input
	
loop input
	
process:
	mov ch, 4
	mov cl, 3
	mov bl, al
	
convert:
	mov al, bl
	ror al, cl
	and al, 01
    	add al, 30h
	
	mov ah, 02h
	mov dl, al
	int 21h
	
	dec cl
	dec ch
    	jnz convert
	
	mov dl, 20h
	int 21h
ret
	
exit:
	int 20h

“And my God will meet all your needs according to His glorious riches in Christ Jesus.” - Philip 4:19

August 1, 2006

Protected: For someone special

Filed under: Blog Post

This post is password protected. To view it please enter your password below:

July 30, 2006

Crackmes: cli3nt’s mycrk

Filed under: Blog Post

Language C
Linux x86/ELF

Difficulty: 1 - Very easy, for newbies
Platform: Unix/Linux, etc.
Language: C/C++

[Solving the Crackme]

As usual, we have to run the file first.

joset@kee:~/src/crackmes/mycrk$ ./mycrk
Type cd-key: eve
wrong!
joset@kee:~/src/crackmes/mycrk$

From this point we already know what the file needs, a correct key. I immediately disassembled the file without even bothering about its characteristics.

joset@kee:~/src/crackmes/mycrk$ objdump -d mycrk > temp.txt
joset@kee:~/src/crackmes/mycrk$ less temp.txt

The first trick, is to look for the disassembly of the main function. Here’s a portion of it.

...
 80483d4:       c7 45 fc 67 1e 01 00    movl   $0x11e67,0xfffffffc(%ebp)
 80483db:       c7 45 f8 70 12 5b 00    movl   $0x5b1270,0xfffffff8(%ebp)
 80483e2:       c7 45 f0 06 00 00 00    movl   $0x6,0xfffffff0(%ebp)
 80483e9:       83 ec 0c                sub    $0xc,%esp
 80483ec:       68 14 85 04 08          push   $0x8048514
 80483f1:       e8 ee fe ff ff          call   80482e4 <printf @plt>
 80483f6:       83 c4 10                add    $0x10,%esp
 80483f9:       83 ec 08                sub    $0x8,%esp
 80483fc:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 80483ff:       50                      push   %eax
 8048400:       68 22 85 04 08          push   $0x8048522
 8048405:       e8 ba fe ff ff          call   80482c4 <scanf @plt>
 804840a:       83 c4 10                add    $0x10,%esp
 804840d:       8b 45 f8                mov    0xfffffff8(%ebp),%eax
 8048410:       3b 45 f4                cmp    0xfffffff4(%ebp),%eax
 8048413:       75 1d                   jne    8048432 <main +0x6e>
 8048415:       8b 55 f0                mov    0xfffffff0(%ebp),%edx
 8048418:       8d 45 fc                lea    0xfffffffc(%ebp),%eax
 804841b:       31 10                   xor    %edx,(%eax)
 804841d:       83 ec 08                sub    $0x8,%esp
…

I am not going to provide a detailed information about this. Let’s observe the line there with a cmp, since lines with cmps usually attract crackers’ eyes at a first glance. ;) It is very obvious that a value is being compared with the content of the eax register and is obtained through a buffered input because the line is preceded with a call 80482c4 <scanf @plt>. How do we get the value of the eax register? Getting the idea? Of course, we will use gdb by setting a breakpoint where the line resides and displaying the value being held by the eax register.

joset@kee:~/src/crackmes/mycrk$ gdb ./mycrk
...
(gdb) b *0x8048410
Breakpoint 1 at 0x8048410
(gdb) r
Starting program: /home/joset/src/crackmes/mycrk/mycrk
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Type cd-key: eve
	
Breakpoint 1, 0x08048410 in main ()
(gdb) print $eax
$1 = 5968496
(gdb)

Looking back, we can see that it would jump to 8048432 <main +0x6e> if the values didn’t satisfy each other. Let’s see what it does from there.

...
 8048432:       83 ec 0c                sub    $0xc,%esp
 8048435:       68 29 85 04 08          push   $0x8048529
 804843a:       e8 a5 fe ff ff          call   80482e4 <printf @plt>
 804843f:       83 c4 10                add    $0x10,%esp
 8048442:       b8 00 00 00 00          mov    $0x0,%eax
 8048447:       c9                      leave
 8048448:       c3                      ret
...

There’s the presence of a call 80482e4 <printf @plt>. We can come up with an assumption that it is the notification being printed if an invalid key is entered. :) Therefore the key is the value being held by the eax register awhile ago. Let’s try it.

joset@kee:~/src/crackmes/mycrk$ ./mycrk
Type cd-key: 5968496
73313
joset@kee:~/src/crackmes/mycrk$

Done.

July 29, 2006

A palindrome checker in 16-bit DOS assembly

Filed under: Blog Post

A good morning to start off is to get this simple program working. This is an improvement of the previous palindrome checker posted. What can we benefit from this anyway? :)

; palindrome checker
	
start:
        mov ah, 0ah
        lea dx, strptr
        int 21h
	
        lea di, string
        lea si, strlen
        mov cl, [si]
        xor ch, ch
        mov bx, cx
        lea si, string
        shr cl, 1	        
	
check:
        mov dl, [si]
        mov dh, [di+bx-1]
        cmp dl, dh
        jne notpal
        inc si
        dec di
	
loop check
	
        cmp dl, dh
        je pal
	
notpal:
        mov ah, 09h
        lea dx, msg2
        int 21h
        int 20h
	
pal:
        mov ah, 09h
        lea dx, msg1
        int 21h
        int 20h        
	
strptr  label byte
maxlen  db 49
strlen  db ?
string  db 50 dup ('$')
msg1    db '',10,'string is a palindrome!$'
msg2    db '',10,'string is not a palindrome!$'

“If God’s people which are called by His name, will humble themselves and pray, and seek His face, and turn from their wicked ways; then He will hear from heaven, and will forgive their sins, and will heal their land.” - 2 Chron 7:14

A case inverter in 16-bit DOS assembly

Filed under: Blog Post

This is a simple case inverter, if you want to try this out download the a86 assembler here. It works like a charm in dosemu-freedos.

; case inverter
	
start:
        mov ah, 0ah
        lea dx, strptr
        int 21h
	
        lea si, string
        mov cl, [strlen]
	
check:
        mov al, [si]
        cmp al, 'Z'
        ja lowercase
        cmp al, 'a'
        jb uppercase
	
lowercase:
        cmp al, 'a'
        jb traverse
        cmp al, 'z'
        jbe toupper
	
uppercase:
        cmp al, 'Z'
        ja traverse
        cmp al, 'A'
        jae tolower
	
toupper:
        sub al, 32
        mov [si], al
        jmp traverse
	
tolower:
        add al, 32
        mov [si], al
	
traverse:
        inc si
	
loop check
	
        mov ah, 02h
        mov dl, 10
        int 21h
	
        mov ah, 09h
        lea dx, string
        int 21h
        int 20h
	
strptr  label byte
maxlen  db 49
strlen  db ?
string  db 50 dup ('$')

“Fortune favors the prepared mind.” - Louis Pasteur

July 25, 2006

Crackmes: lord’s easy Linux crackme

Filed under: Blog Post

crackme will print text under certain conditions
what are the conditions? ;) sorry for my bad english
- lord

Difficulty: 1 - very easy, for newbies
Platform: Unix/Linux, etc.
Language: Assembler

[Solving the Crackme]

An initiative would be running the file:

joset@kee:~/src/crackmes$ ./blah
joset@kee:~/src/crackmes$

It didn’t print anything at all. So the conditions aren’t met. I’ve been using gdb and objdump for quite some time now. Since there is no form of corruption in the file, these tools will be more than enough. Here’s the disassembly of the file in objdump:

  blah:     file format elf32-i386
	
Disassembly of section .text:
	
08048094 < .text>:
 8048094:       31 c0                   xor    %eax,%eax
 8048096:       b8 2f 00 00 00          mov    $0x2f,%eax
 804809b:       cd 80                   int    $0x80
 804809d:       3d ad de 00 00          cmp    $0xdead,%eax
 80480a2:       75 16                   jne    0x80480ba
 80480a4:       b8 04 00 00 00          mov    $0x4,%eax
 80480a9:       bb 01 00 00 00          mov    $0x1,%ebx
 80480ae:       b9 c4 90 04 08          mov    $0x80490c4,%ecx
 80480b3:       ba 06 00 00 00          mov    $0x6,%edx
 80480b8:       cd 80                   int    $0x80
 80480ba:       31 c0                   xor    %eax,%eax
 80480bc:       40                      inc    %eax
 80480bd:       31 db                   xor    %ebx,%ebx
 80480bf:       cd 80                   int    $0x80

The first 3 lines tell us that it will call getgid (47 in /usr/include/asm/unistd.h). The system call returns the group id of the user running the file. The next 2 lines are straightforward. The execution jumps to 0x80480ba if eax is not equal to 0xdead. Here’s what will happen from 0x80480ba onward:

1. eax will be cleared out (eax = 0)
2. eax will have a new value of 1 (exit system call)
3. ebx will be cleared out (ebx = 0)

For a clearer view, try echo $? after running the file and you’ll get a 0. Here’s how I did it. I patched the file. Take a loot at 0x80480a2, we can find the conditional jump there. I just changed the opcodes jne (75) 0x80480ba (16) to nop (90).

joset@kee:~/src/crackmes$ gdb --write -nx -q blah
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) x/x 0x80480a2
0x80480a2:      0x04b81675
(gdb) set {int} 0x80480a2 = 0x04b89090
(gdb) q
joset@kee:~/src/crackmes$

There it is, 1675 to 9090. Now for the final shot,

joset@kee:~/src/crackmes$ ./blah
Okej!
joset@kee:~/src/crackmes$

Try running the file with a user under 0xdead perhaps it would also yield the same result. I haven’t tried it though.

July 24, 2006

Filed under: Blog Post

Making you feel loved was the easiest thing I have ever done before. It’s just sad to think that things just changed. I wish I could turn back those days. The times when we sat down under a tree, observed the fading horizon, held hands and stared at the crimsoning sun. I know how destiny fools us. If destiny asserts that we are not for each other, then I would fight destiny just to have you in my arms forever. I love you my everdearest.

I’m sorry for what had happened to the rose. It’s not too late though, I can still take care another bud for you.

July 22, 2006

Antidote for insanity

Filed under: Blog Post

Simple programming stuffs save me from insanity. This a86 assembly program tells if str1 is a palindrome.

start:
        cld
        mov cx, 7
        lea si, str1
        lea di, temp
	
reverse:
        mov al, [si+6]
        mov [di], al
        inc di
        dec si
        loop reverse
	
        mov ah, 09h
        lea dx, temp
        int 21h
	
        cld
        mov cx, 4
	
compare:
        lea di, temp
        lea si, str1
        repe cmpsb
        jne exit
	
        mov ah, 09h
        lea dx, yes
        int 21h
	
exit:
        mov ah, 4Ch
        mov al, 00
        int 21h
        int 20h
	
str1    db 'racecar$'
yes     db '',10,'string is a palindrome!$'
temp    db 8 dup ('$')

[Middle-East Crisis]

Israel, known as the chosen people of God called a thousand reservists in a possible prelude to a ground offensive against Lebanon. Accordingly, they have to clean up bunkers and tunnels that are invulnerable to air attacks. Isn’t it ironic for the Mossads to be called as the chosen people of God?

July 9, 2006

Outdoorsman recall

Filed under: Blog Post

I can still remember way back then, I was five years old when I had my primary hobbies, hunting, fishing, and shooting-range. Today, we went to Sinubung, a semi-dangerous place located in the far west coast of Zamboanga City and is known for its shore having huge waves and numerous sea urchins. We have gone fishing. It was fun riding my grandfather’s motor-operated vinta again though I am deeply saddened with what had happened today. The last time I set foot on that vinta was 15 years ago. I can still remember my grandfather pulling the nylon with a huge squid hooked up. Of course, the squid fired up a black tint. Because of that black tint, and the times when I threw up while riding the vinta, I have something now which I call memories worth remembering.

Awhile ago, we did the same but no squid and from what I have observed fishes are already scarce! We spent almost three hours, changing position from time to time on the sea. I was the one throwing and pulling the anchor everytime we shift locations but damn no fishes!

A very nice experience. The prize for the experience? Well, a swollen left foot, 5 thorns pierced from black sea urchins. It’s not a big deal though. The prize does not outweigh the experience. Waves were really strong awhile ago. I was a little nervous.

The truth is, I am sad today. It could be that I’ve lost someone very special.

July 7, 2006

Preparing for Muziklaban

Filed under: Blog Post

Red Horse Muziklaban is fast approaching. Tomorrow will be the qualification or shall I say audition. One composition down. I am still trying to come up with a nice riff for the adlib. Hoping to impress the judges tomorrow.

[Programming]

I am just messing up with DOS Assembly. I started out programming in 32-bit protected mode, now broadening my knowledge by diving into 16-bit real mode. I have nothing new these days, just reviewing C++.

Signing off through a quote by Albert Einstein

“Information is not knowledge.”

July 2, 2006

Victory!

Filed under: Blog Post

Congratulations Manny Pacquiao!

He was once a singer of a local band in Gen. Santos City. Look at him now, he is the most influential person in our nation and probably one of the most influential persons around the globe. I was really fascinated by his fight with Oscar Larios. He has become faster than ever. Incomparable vigor that is! Raise it up Manny. More power and advertisements ahead.

On the other hand, I pity Oscar Larios, he was a great fighter. I admire his sportsmanship and humility. He is one of the cheerful and honest boxers I’ve ever seen. His courage is a deadly weapon that one shouldn’t take advantage of. Maintaining his mind in equilibrium state could have driven Manny on the floor.

[Globe Telecom]

What is happening? I couldn’t send and receive SMSs. Calling does not solve the issue either. Hoping for better services in the future.

June 19, 2006

GDT Explained

Filed under: Blog Post

GDT contains a number of entries, Segment Descriptors. Usually each is 8 bytes long and marks the starting point, length, and access rights of the segment. It is stored in memory of course. The address is stored in a special 48-bit CPU register called Global Descriptor Table Register (GDTR). The lower 16 bits inform the size of the GDT while the upper 32 bits inform the location of the GDT in memory.

The GDT itself is a 64-bit long entries. These entries define whether the current segment that the processor is running is for Ring 0 or Ring 3. Ring levels are restrictions, Ring 0 is for system use while Ring 3 is for application use. Such protection exists to prevent applications from causing the kernel to crash and to tell the processor which instructions are valid.

–snipped–

June 15, 2006

Orders received!

Filed under: Blog Post

ADZU Open Lab will be switching to Edubuntu 6.06 Dapper Drake! Wee! Expecting Ubuntu sovereignty in the University! More power Ubuntu Linux Development Team.

A Freedom Toaster empowered by Shuttleworth Foundation is badly needed in our University.

The network administrator, Sir Greg, also suggested Xubuntu 6.06 in the College Internet Access Area (CIAA). Well, it’s easy as one-two-three.

June 13, 2006

I’m back!

Filed under: Blog Post

It’s good to be back to one’s abode. I haven’t been blogging lately for the reason that my dad was confined and there were no other who could watch over him except me. Good thing that my dad’s okay now. Got to go, have to finish the enrollment process.

God bless.

May 31, 2006

20!

Filed under: Blog Post

Twenty factorial?

Thank God for all the blessings especially the gift of life. Thank you mom and dad for taking care of me. Thank you everyone! Happy birthday to me! I am no longer a teenage lad. I could not believe it. Time flies so fast.

May 27, 2006

Revamp, an apology

Filed under: Blog Post

[Previous Post]
Sorry I forgot the private flag because I was in a hurry awhile ago. I hope it didn’t deface Planet Ubuntu-PH.

[OS Development]
Global Descriptor Table conquered! Nothing special, more tasks ahead. So far so good. Linux 0.01 is cool and MiniOS (Minix) too! Hail to you Linus Torvalds and Andrew Tanenbaum.

May 26, 2006

Jeepney, today - 2

Filed under: Blog Post

Thinking of the song? No, definitely not Kala’s hit in the Myx Daily Top 10.

It was 31 down 7 o’clock in the evening, the last day of our training. The sky was darkening and the wind blew softly as I walked toward the terminal. Going home later than 6 o’clock in the evening is such a waste of time I heard myself whisper. Before taking the jeepney in line, I have decided to sit down and buy a bottle of coke in a bakery situated near the end of the terminal. While taking a sip, I observed people passing by. Definitely not Manila, whispering to myself and reminiscing the events a year ago. 5 minutes would be long enough for me to begin sipping air so I took a jeepney. I have waited for the jeepney to be filled up. Not exceeding 10 minutes, the wheels started rolling as expected.

This year is going to be the hardest school year ever. Again, talking to myself. Anticipating sleepless nights, hardworks, additional duties or obligations, etc. Then suddenly while thinking of these, my sight landed on the driver. He looked so tired and problematic. What if I am on his shoes? Is he happy with his life? Then I began asking myself, what would be my life a year after wherein I will not be calling myself a student anymore? Will I be able to work in prestigious firms such as NEC, Orange and Bronze, Accenture, etc.? Well, so much for that.

It was time to pay for my fare and step down.

Please hand my fare over, I handed PhP 6.00 (discounted fare for students and senior citizens). Not far from the jeepney, I was wondering why it was not moving and all the passengers were looking at me. It seems that there was a problem. I approached the driver with an idea that he wasn’t happy with my fare. He shouted, how much do you pay to this far?! I replied, PhP 6.00, student. Student?! it’s summer break, no classes these days! My reply, I have summer classes and it does not mean that if it’s summer break then we should follow regular fare. The reasons why students and senior citizens follow the discounted fare are,

[Students]

They are still studying and do not have a job yet.

[Senior Citizens]

Most of them were retired and have no other means of income, some are just depending on their pension plans.

Even if we’ll see face to face in the court you will never triumph. What is the use of having that fare rate there posted on your windshield? Consider Manila, the food is more expensive compared here but the drivers there are disciplined in following the fare matrix provided by the LTFRB. Then with loud voice he began uttering a lot of things like, it should be PhP 6.50! Currently, I do not even have the fee for this jeepney! While he was throwing a lot of harsh words, at the back of my mind, I was already thinking of giving all extra coins in my bag. I was reflecting during that moment and have realized that I have relatives who survive through the same profession, driving, I know how hard it is to suffice the needs of one’s family especially if one does not own a jeepney. I slowly opened my bag and got all the coins there, then with smile I gave all those to the driver. We understand your situation, here take these coins, you might be needing it badly for your family. He replied in low tone, thank you child, please do understand us. Then with smile I replied, okay sir, no problem about that. Then the jeepney started rolling. While walking down the street to our house, I have felt an extraordinary happiness.

Being happy is a choice that we make. Never forget this. Everytime we wake up in the morning, it is us who chooses whether to be happy or not. Being happy is not being rich, it is being content with what we have.

Pro Deo et Patria

May 22, 2006

Kernel head

Filed under: Blog Post

This is a late post. Simply explains how the kernel sits in after grub.

[BITS 32]
	
global _start
extern kernel_entry
	
PAGEALIGN	equ 1<<0
MEMORYINFO	equ 1<<1
HEADERFLAGS	equ PAGEALIGN | MEMORYINFO ; 0x3 that is
HEADERMAGIC	equ 0x1BADB002
CHECKSUM	equ -(HEADERMAGIC + HEADERFLAGS)
STACKSIZE	equ 0x4000
	
section .text
ALIGN 4 	; section must be 4 byte-aligned
multibootheader	;
	dd HEADERMAGIC
	dd HEADERFLAGS
	dd CHECKSUM
	
_start:
	mov esp, stack+STACKSIZE
	push eax
	push ebx
	call kernel_entry
	jmp $
	
; GDT here
	
; ISRs here
	
section .bss
ALIGN 4
stack	resb STACKSIZE	; 16KB of memory

I’m just sad tonight, that’s why I decided to post this out of nothing. Well I guess keeping myself busy would be wise enough.

May 21, 2006

Sunday, sad discovery

Filed under: Blog Post

[Da Vinci Code]

I have been to the movie house recently and watched this controversial film. The book, despite its ever-growing popularity, did not interest me that much since I equate my faith with a sword mightier than Tireal’s Azurewrath. I was saddened deeply when I reached the movie house and saw numerous people there oozing with their teenage curiosity. First of all, have they been to church? It’s Sunday for pete’s sake. Why would they prioritize watching a film that is against their religion without even thinking that they have their obligations? Dan Brown’s manuscript is really a work of art and no question about that but people should remember it as a fiction book and nothing beyond.

To all those who have read the book or have watched the film, try reading The Da Vinci Code Decoded written by a Jesuit priest.

[OS Development]

Do not write your own operating system. An information available globally that could be considered as a blackhole where operating system developers might fall. I am one of those enlightened hobbyists who fell into that hole while searching for a supplementary reading about the Global Descriptor Table. Developing your own OS is just reinventing the wheel. Straightforward as it may sound. Yeah right. We want to learn here and reinventing the wheel does not only mean to reinvent. Go grab your processor’s fan, detach it, and power on for a decent devastation.

May 16, 2006

Early take-off

Filed under: Blog Post

I have emerged vim-7.0-r2 just recently.

Preparing a lot for our college thesis. Not excluding the amount of food intake. Reading the intel manuals from hell. Heavy bondings with bochs, vim, nasm, gcc, ld, strace, objdump, hexedit, as, etc.

Requesting a divine intervention for strength.

May 10, 2006

Making C++ behave like Java

Filed under: Blog Post

I was sidetracked from my C++ programming (Battle for Wesnoth) by the school’s Senior Summer Trainings 2006. After MySQL and PHP, and a week OJT at Zamboanga Freeport (OMED IT Solutions), the dark side of the force has arrived, Java Programming. We are currently being trained by Ma’am Ebony Domingo and some CS upperclasses who already received their respective diplomas last March of this year. Their spirits of magis uplift my morale and drive me to be more optimistic especially in dealing with a language that I’m not quite familiar with.

Java is known for its being a platform independent language, equipped with an auto garbage collection mechanism, etc. (I don’t want to elaborate more on these).

What I am trying to point here out is that, one of Java’s assets, which is the auto garbage collection, is also possible in C++ using an auto pointer. Now, how is this possible?

What an auto pointer does is, it owns a dynamically created object and automatically performs a cleanup when the object is no longer needed.

First, we have to consider how they normally do it (without auto pointer).

void function()
{
        sophie *s(new sophie);
        /* do something here */
        delete s;
}

A classic memory leak would occur if there’s no delete.

Here’s how it’s being done using an auto pointer.

void function()
{
        auto_ptr<sophie> s(new sophie);
        /* do something here */
}

Beyond this scope, the object frees automatically.

God bless us all!

April 24, 2006

Unanticipated

Filed under: Blog Post

Summer vacation days are even more tiring than the usual school days! I have thought of decreased loads in my TO-DO list but I was wrong. Good day.

April 18, 2006

Locked and loaded

Filed under: Blog Post

Today is the second day of the Senior Summer Trainings 2006. Yesterday, we have started off MySQL running on Ubuntu. We did just simple exercises but very worth-doing even if I had previous experiences with the subject.

To Ma’am Flisha Fernandez, thanks a lot. The Ateneo Spirit of Magis has a way of rewarding people like you.

[Kernel]

Please welcome “The Instrument of Doom” linux-2.6.14-kee-innovative with nVidia support. I have purchased a second-hand graphics card (GeForce FX 5700 256mb 128bit) from a friend. Good to go!

[Gig]

I hope the training will end up earlier than the usual time. I have to warm up for the gig tonight at Park 88.

March 27, 2006

Getting the feel of the groove

Filed under: Blog Post

Junior year’s over. New daily schedule has emerged. In a day there must be at least 2 hours of bass exercises which include music bass theory, scales, funky bass lines, and jamming sessions. 6 hours of programming (right after this sissy FoxPro RDBMS project). In weekends, there must be at least 2 jamming sessions with my band for compositions and reviews. Play at different bars at night, for pleasure and income. My top priority for this summer break is to code some modules for our final project ahead. Of course, schedule is subject to change due to unpredictable and uncontrollable forces such as heavy household chores, family affairs, family business, or anything that concerns morality.

March 25, 2006

Palindrome syndrome

Filed under: Blog Post

I really do not enjoy coding in MS Visual FoxPro but I have no choice. Damn! I swear not to use it any longer after this RDBMS project.

I was asked by a friend to code a simple program to check if a string is a palindrome. I miss coding in C and assembly a lot! So to satisfy my urge, I tried to do it in a different manner. A timed coding session!

#include<stdio.h>
#include<string.h>
	
#define MAXSTRING 50
	
int main(void)
{
	int i;
	int ctr = 0;
	char c;
	char string[MAXSTRING] = "\0";
	char temp[MAXSTRING] = "\0";
	
	printf("Enter a string: ");
	for (i = 0; (c = getchar()) != '\n'; ++i)
		string[i] = c;
	string[i] = '\0';
	
	for (--i; i >= 0; --i){
		temp[ctr] = putchar(string[i]);
		++ctr;
	}
	if (!strcmp(string, temp))
		printf("\nString is a palindrome!\n");
	else
		printf("\nNot a palindrome!\n");
	return 0;
}

I finished coding in 4 minutes and 37 seconds. Not a good record though. So sad.

March 13, 2006

LPT1 stepper motor control

Filed under: Blog Post

Last Sunday, I was coding some modules for our RDBMS project and playing Dungeon Siege: Legend of Aranna (quite old but it would be a waste of time if I did not) in parallel. I received a phone call asking a favor to write a program for sending signals through the parallel port. It sounds a little scary at first because I did not have any idea on parallel port interfacing.

Let me explain the project.

The project is a Car Control System. They have 2 bipolar stepper motors. One is responsible for the forward-reverse function and the other one is for the left-right function.

Signals recognized by the floppy drive stepper motor:

Clockwise 18-degree turn

1001      or      0x9
0110      or      0x6

Counterclockwise 18-degree turn

0110      or      0x6
1001      or      0x9

Now, how is it possible to send these signals using the parallel port? Not all 25 pins are needed. For this project, only the data pins are needed.

Pin         Function
 2             D0
 3             D1
 4             D2
 5             D3
 6             D4
 7             D5
 8             D6

LPT1 is usually 0x378; having this knowledge, everything comes in trivial.

In file lptcontrol.c

#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
	
int main(int argc, char* argv[])
{
	short data;
	
	if(argc<2) {
		printf("Usage\n\n");
		printf("lptcontrol.exe [option] [data]\n\n");
		return 0;
	}
	
/* a read function is not necessary for this project
   included for additional info */
	
	if(!strcmp(argv[1],"read")) {
		data = _inp(0x378);
		printf("Data from parallel port:  ");
		printf("%d",data);
	}
	
	if(!strcmp(argv[1],"write")) {
		_outp(0x378,atoi(argv[2]));
		printf("Data written to parallel port:  ");
		printf("%s",argv[2]);
	}
	return 0;
}

If you want a constant turn you can achieve it through a loop.

while(1) {
        _outp(0x378, 0x9);
        _outp(0x378, 0x6);
}

This will result to a motor spinning clockwise. C program above is written for Windows OS.

March 7, 2006

Ethical hacking, a glimpse of my Philo paper

Filed under: Blog Post

Is hacking ethical? It is if viewed within the context of the three definitions offered: hacktivist, hobbyist and researcher. We have the right in this country to protest, and if our activism takes a digital or electronic form, we have the right to do so. But don’t take my word for it.

Who are ethical hackers? These early efforts provide good examples of ethical hackers. Successful ethical hackers possess a variety of skills. First and foremost, they must be completely trustworthy. While testing the security of a client’s systems, the ethical hacker may discover information about the client that should remain secret. In many cases, this information, if publicized, could lead to real intruders breaking into the systems, possibly leading to financial losses. During an evaluation, the ethical hacker often holds the “keys to the company,” and therefore must be trusted to exercise tight control over any information about a target that could be misused. The sensitivity of the information gathered during an evaluation requires that strong measures be taken to ensure the security of the systems being employed by the ethical hackers themselves: limited-access labs with physical security protection and full ceiling-to-floor walls, multiple secure Internet connections, a safe to hold paper documentation from clients, strong cryptography to protect electronic results, and isolated networks for testing.

Ethical hackers typically have very strong programming and computer networking skills and have been in the computer and networking business for several years. They are also adept at installing and maintaining systems that use the more popular operating systems (e.g., GNU Linux, BSD Unix or Windows NT) used on target systems. These base skills are augmented with detailed knowledge of the hardware and software provided by the more popular computer and networking hardware vendors. It should be noted that an additional specialization in security is not always necessary, as strong skills in the other areas imply a very good understanding of how the security on various systems is maintained. These systems management skills are necessary for the actual vulnerability testing, but are equally important when preparing the report for the client after the test.

Finally, good candidates for ethical hacking have more drive and patience than most people. Unlike the way someone breaks into a computer in the movies, the work that ethical hackers do demands a lot of time and persistence. This is a critical trait, since criminal hackers are known to be extremely patient and willing to monitor systems for days or weeks while waiting for an opportunity. A typical evaluation may require several days of tedious work that is difficult to automate. Some portions of the evaluations must be done outside of normal working hours to avoid interfering with production at “live” targets or to simulate the timing of a real attack. When they encounter a system with which they are unfamiliar, ethical hackers will spend the time to learn about the system and try to find its weaknesses. Finally, keeping up with the ever-changing world of computer and network security requires continuous education and review.

One might observe that the skills we have described could just as easily belong to a criminal hacker as to an ethical hacker. Just as in sports or warfare, knowledge of the skills and techniques of your opponent is vital to your success. In the computer security realm, the ethical hacker’s task is the harder one. With traditional crime anyone can become a shoplifter, graffiti artist, or a mugger. Their potential targets are usually easy to identify and tend to be localized. The local law enforcement agents must know how the criminals ply their trade and how to stop them. On the Internet anyone can download criminal hacker tools and use them to attempt to break into computers anywhere in the world. Ethical hackers have to know the techniques of the criminal hackers, how their activities might be detected, and how to stop them.

Given these qualifications, how does one go about finding such individuals?

The best ethical hacker candidates will have successfully published research papers or released popular open-source security software. The computer security community is strongly self-policing, given the importance of its work. Most ethical hackers, and many of the better computer and network security experts, did not set out to focus on these issues. Most of them were computer users from various disciplines, such as astronomy and physics, mathematics, computer science, philosophy, or liberal arts, who took it personally when someone disrupted their work with a hack.

One rule that IBM’s ethical hacking effort had from the very beginning was that we would not hire ex-hackers. While some will argue that only a “real hacker” would have the skill to actually do the work, we feel that the requirement for absolute trust eliminated such candidates. We likened the decision to that of hiring a fire marshal for a school district: while a gifted ex-arsonist might indeed know everything about setting and putting out fires, would the parents of the students really feel comfortable with such a choice? This decision was further justified when the service was initially offered: the customers themselves asked that such a restriction be observed. Since IBM’s ethical hacking group was formed, there have been numerous ex-hackers who have become security consultants and spokespersons for the news media. While they may very well have turned away from the “dark side,” there will always be a doubt.

I believe hackers have a lot to offer. They provide a balance of power by virtue of their creativity and technical skills. I think we need to protect and recognize them and find ways of working together.

Yes, I do believe that hacking — when properly defined — is an ethical activity. And yes, I do believe that understanding our freedom and rights and protecting all that’s good in our society while preventing all that’s bad is the right approach.

February 25, 2006

A change-gas

Filed under: Blog Post

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.

February 23, 2006

ADZU openlab scutworks

Filed under: Blog Post

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.

February 19, 2006

Verify user in /etc/passwd

Filed under: Blog Post

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.

February 17, 2006

A hidden post made visible

Filed under: Blog Post

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.

February 14, 2006

Test mtsend

Filed under: Blog Post

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!

February 4, 2006

Queued tasks

Filed under: Blog Post

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

February 1, 2006

Wesnoth terrain

Filed under: Blog Post

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.

January 23, 2006

Unix half-duplex pipes

Filed under: Blog Post

The pipe ‘|’ is a type of inter-process communication. Its facilities provide a method for multiple processes to communicate with one another.

Simply putting a pipe in between is a method of connecting the standard output of one process to the standard input of another.

joset@kee$ ls -l | grep -i foo

In the example above, the output of ls is written to the input of grep. Obviously, the output of grep is written to the standard output of the shell, the screen.

Here is how a pipe works.

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
	
int main(void)
{
	int	fd[2], n_bytes;
	pid_t	child;
	char	string[] = "Hello, world!\n";
	char	readbuf[80];
	
	pipe(fd);
	
	if ((child = fork()) == -1){
		perror("fork");
		exit(1);
	}
	
	if ((child == 0)){
		/* child process closes up input side of pipe */
		close(fd[0]);
	
		/* send "string" through the output side of pipe */
		write(fd[1], string, strlen(string));
		exit(0);
	}
	
	else{
		/* parent process closes up output side of pipe */
		close(fd[1]);
	
		/* read in a string from the pipe */
		n_bytes = read(fd[0], readbuf, sizeof(readbuf));
		printf("Received string: %s", readbuf);
	}
	return 0;
}

January 22, 2006

GNU recursive naming convention

Filed under: Blog Post

Eradicus Redefines All Deprecated Information Creatively Upon Scanning (ERADICUS).

A legal alien?

Filed under: Blog Post

Yesterday, I was triggered by my ego to attend a session of WMSU’s review for the incoming ICT proficiency exam. Each student spent a total of Php 460.00 for the review and test fee. It started last week. Passers of the said exam are guaranteed to be certified ICT professionals as noted by NCC. I was curious about how the review was being held. I was able to set myself in the classroom without catching much of the professor’s attention. It was my first attempt. I was somehow excited at first, but as the review went on, the professor did not talk that much and started filling up the chalkboard. The topic was about data structures. I was surprised with what I have found out. I bet you have the idea.

January 9, 2006

A sticky lesson

Filed under: Blog Post

With a dial-up connection reaching 14kbps at max, an ‘emerge-delta-webrsync’ consuming only 5 minutes of your uptime, a free access from 0000H - 0800H, and a script that does nasty things like disconnect after ‘emerge -f foo’ and switch to ‘init 0′, You will not be able to resist the clamor for an up-to-date box.

The lesson began here:

root@kee# emerge =sys-devel/gcc-3.4.4

This does not mean dirty!

joset@kee$ eix -e gcc
	
* sys-devel/gcc
     ...
     Installed:  3.3.6 3.4.4-r1
     Homepage:   http://www.gnu.org/software/gcc/gcc.html
     ...
	
Found 1 matches
joset@kee$

Not realizing that having multiple GCCs installed is normal, and without following the upgrading-gcc-guide, a stupid action followed.

root@kee# emerge -C =sys-devel/gcc-3.3.6

Bang! libstdc++.so.5.0.6, where the hell are you? All programs linked dynamically to this library were paralized! My intention was to clean up gcc-3.3.6 since I have emerged gcc-3.4.4 recently.

After abusing /dev/ppp0’s abnormal upstream and downstream rates, I have finally learned my lessons.

Luckily, my box was revived!
The solution found in http://gentoo-wiki.org proved its worth.

January 1, 2006

Love is an essential inspiration

Filed under: Blog Post

Unrequited love, is, something that you should not take away from the person offering you. It is willing to stay to you forever. It will grow on every assault. The longer it takes, the stronger it gets. Unrequited love finds justice if not being deprived of it having expressed.

December 12, 2005

The true emptiness

Filed under: Blog Post

It is very important for me to express to you how much you really mean to me. I wish I could do this in person exquisitely. But since we are physically separated by miles of emptiness, this expression must come in the form of letters such as this.

Life seems to be full of trials of this type which test my inner strength, and more importantly, my devotion and love for you. After all, it is said that “True Love” is boundless and immeasurable and overcomes all forms of adversity. In truth, if it is genuine, it will grow stronger with each assault upon its existence.

I am happy this way. Life is so kind for giving someone like you as my sole inspiration. My love has been assaulted many times, and I am convinced that it is true because the longer I am away from you, the greater is my yearning to see you again.

Across the miles, I send to you my tender love and my warm embrace. Thank you for being one of my life’s sweetest blessings.

November 29, 2005

Mystery program

Filed under: Blog Post

This program is system-dependent, it will run correctly on many different systems. Try it on your machine.

#if (VAX || PC)
        #define HEX0 0x6c6c6548
        #define HEX1 0x77202c6f
        #define HEX2 0x646c726f
        #define HEX3 0x00000a21
#else
        #define HEX0 0x48656c6c
        #define HEX1 0x6f2c2077
        #define HEX2 0x6f726c64
        #define HEX3 0x210a0000
#endif
	
typedef union {
        char what[16];
        long cipher[4];
} mystery;
	
int main(void)
{
        mystery x;
	
        x.cipher[0] = HEX0;
        x.cipher[1] = HEX1;
        x.cipher[2] = HEX2;
        x.cipher[3] = HEX3;
	
        printf("%s", x.what);
        return 0;
}

Isn’t it a wonder?

November 27, 2005

List application

Filed under: Blog Post

To illustrate the use of those functions, here is an example.

#include <stdio.h>
#include <stdlib.h>
#include "list.h"
	
LINK string_to_list(char []);
void print_list(LINK);
int count_rec(LINK);
	
int main(void)
{
        LINK h;
	
        h = string_to_list("ABC");
        printf("The resulting list is\n");
        print_list(h);
        printf("\nThis list has %d elements.\n", count_rec(h));
        return 0;
}

The output of the program is

The resulting list is
A --> B --> C --> NULL
This list has 3 elements.

November 23, 2005

Printing a list using recursion

Filed under: Blog Post

This is a function for displaying a list. Oh I just love recursion.

void print_list(LINK head)
{
        if (head == NULL)
                printf("NULL");
	
        else {
                printf("%c --> ", head -> d;
                print_list(head -> next);
        }
}

November 21, 2005

Pro guns

Filed under: Blog Post

It is indeed true that my passion for guns already existed long before I came to this chaotic world. Guns are the most outstanding weaponry ever in the history of man. Let me give you some facts about my preferred gun as of the moment.

Avtomat Kalashnikov 47 (AK-47)

Country: Soviet Union/Russian Federation
Type: Assault Rifle
Inventor: Mikhail Kalashnikov
Year of design: 1947
Service duration: 1951-Present
Cartridge: 7.62 mm X 39
Action: Gas-Operated rotating bolt
Rate of fire: 600 rpm
Muzzle velocity: 710 m/s
Effective rage: 300 m
Weight: 4.3 kg (unloaded)
Length: 870 mm
Barrel: 415 mm
Magazine Cap.: 30
Viewing sights: Adjustable iron sights, optional mount required for optical scope
Variants: AK-47, AKS, AKM, AKMS, AK-74, AK-101, AK-103
Number built: More than 1 million excluding unlicensed (paltik)

Do not confuse yourself with its figure since it resembles a Dragunov sniper rifle when mounted with an optical scope.

November 20, 2005

Counting a list recursively

Filed under: Blog Post

If there is an iterative way, there must be a recursive way.

int count_rec(LINK head)
{
        if (head == NULL)
                return 0;
	
        else
                return (1 + count_rec(head -> next));
}

November 19, 2005

Counting a list iteratively

Filed under: Blog Post

This is a simple way of counting elements in a list. For some, they would prefer to embed this operation upon list creation and insertion or deletion.

int count_it(LINK head)
{
        int cnt = 0;
	
        for ( ; head != NULL; head = head -> next)
                ++cnt;
	
        return cnt;
}

What lies inside

Filed under: Blog Post

There are things in life that are inevitable and I am powerless to control them. The sun will rise and set, the tide will come in and go out, the seasons will change, friends walk in and out, and the caterpillar will soon turn into a beautiful butterfly. Somehow, I feel reassured by this because many other things in life are so transient - so momentary.

I can’t imagine life without knowing you. For without you, my life would be empty of all inspiration. There will be no work of art for me to gaze at; no person of greatness before me; no timeless melody to listen to. My life will exist in shades of gray instead of vibrant colors, and I will be less than whole.

The proper words have escaped me, and my innermost feelings have been locked away in the depths of my heart. I wish I could say these to you in person while gazing into your eyes. I cherish any thought of you, prize any memory of you that rises from the depths of my mind, and live for the day when our eyes meet.

November 9, 2005

Creating a list by iteration

Filed under: Blog Post

The previous post is quite a bit confusing because it is by recursion. Well, nothing special. Here is the code in all its glory.

#include "list.h"
	
LINK s_to_l(char s[])
{
        LINK head = NULL, tail;
        int i;
	
        if (s[0] != '\0') {
                head = malloc(sizeof(ELEMENT));
                head -> d = s[0];
                tail = head;
	
                for (i = 1; s[i] != '\0'; ++i) {
                        tail -> next = malloc(sizeof(ELEMENT));
                        tail = tail -> next;
                        tail -> d = s[i];
                }
                tail -> next = NULL;
        }
	
        return head;
}

November 8, 2005

A note higher for musicians

Filed under: Blog Post

On the 25th of November 2005, Parokya ni Edgar, Bamboo, Joey Ayala and Noel Cabangon will be performing live at the Zamboanga City Sports Complex. It will be another big event for us all. Junkyard will be performing too. My bass guitar must serve a purpose of the mirror starting today.

November 7, 2005

Window bomb

Filed under: Blog Post

Whip up your favorite text editor and start doing this.

<html>
<title>Window Bomb!</title>
<script language="javascript">
        while (true) {
        window.open()
}
</script>
</html>

Expecting browsers to ignore this in the future.

Linear linked list

Filed under: Blog Post

This is how I implement linear linked lists in C. The structure must be defined in a header file.

In file list.h

#include <stdio.h>
#include <stdlib.h>
	
typedef char DATA;     /* an element of type character */
	
struct linked_list{
        DATA d;
        struct linked_list *next;
);
	
typedef struct linked_list ELEMENT;
typedef ELEMENT *LINK;

Linear linked list includes some of the basic operations:

1. Create list
2. Count elements
3. Look up an element
4. Concatenate lists
5. Insert an element
5. Delete an element

Here is how I create a list by recursion.

#include "list.h"
	
LINK string_to_list(char s[])
{
        LINK head;
	
        if (s[0] == '\0') /* base case */
	
                return NULL;
	
        else {
                head = malloc(sizeof(ELEMENT));
                head -> d = s[0];
                head -> next = string_to_list(s+1);
                return head;
        }
}

November 6, 2005

General notice

Filed under: Blog Post

Eradicus provides these entries for educational use. While every reasonable effort is made to ensure that these entries do what is claimed, Eradicus will not be held accountable for any damage or distress caused by the proper or improper usage of these materials, and makes no guarantee in regards to their operation or suitability for any specific purpose.

Digital Stronghold is for research and educational purposes only. The primary intent of this category is to provide the reader with hard to find content for research or self education relevant to all computer science aspects, network security and various protection methods and their intrinsic flaws by demonstrating exploit methods and techniques used to circumvent them. I hope that you are better aware of the danger that lurk out in society today and learn how to protect yourself with the knowledge you need. In continuing you must remember that you are going to use this information only for educational and research purposes.

While possession of information shown on this blog violates no laws, actually using or implementing some of the contents on this blog may violate some laws.

Theme designed by Joset Anthony Zamora


Digital Stronghold

↑ Get Headline Animator