Tuesday, March 3, 2009

dialyzer

dialyzer is a static code analyzer tool, which helps to compensate of the lack of type checking on erlang. it one of the most important tools for debugging an erlang app in my opinion. setting up the dialyzer is not to hard, but the documentation is not the most east to follow. here is what i did on my new colinux machine.

the dialyzer use plt files which contain the result of the analysis. those files can be used as a start point for an analysis, which mean you can do a big analysis once, and then just check the changes.

first i will build a plt file for the OTP base i use:

dialyzer --build_plt -r /usr/local/lib/erlang/lib/kernel*/ebin /usr/local/lib/erlang/lib/stdlib*/ebin /usr/local/lib/erlang/lib/mnesia*/ebin /usr/local/lib/erlang/lib/compiler*/ebin  --output_plt the.plt

my OTP base is at /usr/local/lib/erlang/lib.


then i will add all the missing directories according to the dialyzer analysis, by searching the missing module:


find /usr/local/lib/erlang/lib -name "module_name.beam"

i will add those missing modules like that:


dialyzer --add_to_plt --plt the.plt -r /usr/local/lib/erlang/lib/{tools*,inets*,debugger*,ssl*,runtime_tools*,webtool*,gs*,public_key*,observer*,eunit*}/ebin --output_plt the.plt


and also private libraries i use, like nitrogen:


dialyzer --add_to_plt --plt the.plt –r ~/erlang/lib/nitrogen/ebin --output_plt the.plt

finally i will add my development code:


dialyzer --add_to_plt --plt the.plt -r ~/my/project/path/ebin --output_plt the.plt

i will the use it to check my code, like this:


dialyzer --plt ./the.plt -I ./include -r ./ebin

mostly i will also filter known issues with grep -v command

Thursday, February 19, 2009

yet another colinux instructions

i hope this is my last post on colinux and erlang, but although i had written several time about it, i will do it once more, to sum up a little guide to setup a new colinux with the correct way to set erlang on it. i also added few words on adding the nitrogen web framework.

> is used for windows command prompt
$ is used for linux shell prompt

- put the final iso file on a new directory c:\linux\distro

2. qemu
- extract qemu into a new directory c:\linux\qemu
- start windows command prompt
- make a 3gb image -
> fsutil file createnew c:\linux\distro\qemu_ubuntu_3gb 3221257728

- make a image for a 512mb swap file

> fsutil file createnew c:\linux\distro\qemu_swap_512mb 536903168

- on c:\linux\qemu create the next batch file: install.bat


   1: @ECHO OFF
   2: set qemu_dir=C:\linux\distro
   3: set hd=%qemu_dir%\qemu_ubuntu_3gb
   4: set swap=%qemu_dir%\qemu_swap_512mb
   5: set cdrom=%qemu_dir%\ubuntu-8.04.2-server-i386.iso
   6: set mem=384
   7: qemu -hda %hd% -hdb %swap% -cdrom %cdrom% -m %mem% -boot d -L .
   8: pause

- run the batch file you have just created: install.bat

- go through the linux installation, select manually partition when asked, and do the following:

create new partition
choose /dev/sda
choose create as: primary partition
choose file system: ext3

create new partition
choose /dev/sdb
choose create as: primary partition
choose file system: linux-swap

- install, and when you get to the point it asks for restart - you have finished. it takes some time, so be patient.


3. colinux


- run and install on c:\coLinux

- don't use or download any of the suggested distributions on the install process

- download and install unxutils - http://gnuwin.epfl.ch/apps/unxutils/en/install/

- open command prompt and do

> cd c:\linux\distro

- convert qemu ubuntu image to colinux image

> dd if=qemu_ubuntu_3gb of=ubuntu_3gb.img bs=512 skip=63

- you only need the file ubuntu_3gb.img the other 2 files (qemu_swap_512mb and qemu_ubuntu_3gb) can be removed

- create new swap file -

> fsutil file createnew c:\linux\distro\swap_512mb 536870912

- create a file on c:\linux\distro named ubuntu8.04.conf, and paste the following into it:

kernel=vmlinux
sda1="c:\linux\distro\ubuntu-8.04.2-server-i386.ext3.3gb.img"
sdb1="c:\linux\distro\swap_512mb"
root=/dev/sda1 fastboot 3
ro
mem=384
eth0=slirp
eth1=tuntap

- create a shortcut for colinux-daemon.exe, right click on it and edit its properties, to add the following parameters (on the shortcut target field)

c:\coLinux\colinux-daemon.exe -t nt @c:\linux\distro\ubuntu8.04.conf

- start this new shortcut, running the colinux the first time

- edit /etc/network/interfaces and the windows TAP connection, see my previous post named colinux from Sunday, November 2, 2008 (steps 10 and 11)

- install ssh and update:

$ sudo apt-get install ssh
$ sudo apt-get update
$ sudo apt-get upgrade

- change basic shell to bash:

$ chsh -s /bin/bash user_name

- connect using putty to 192.168.37.20:22



4. compress and backup the colinux image

- to determine the free space in megabytes

$ df -m 

- fill image with zeros

$ dd if=/dev/zero of=foobar bs=1M count=above result less 5
$ rm foobar

- logout, and compress from windows using winrar, should get around 100MB file



5. install erlang from source

$ sudo apt-get install build-essential
$ sudo apt-get install libncurses5-dev
$ sudo apt-get install m4
$ sudo apt-get install libssl-dev
$ sudo apt-get install openssl

$ cd; mkdir workspace; cd !
$ wget http://erlang.org/download/otp_src_R12B-5.tar.gz
$ tar xvfz otp_src_R12B-5.tar.gz
$ cd otp_src_R12B-5
$ ./configure
$ make
$ sudo make install



6. install some basics

$ sudo apt-get install git subversion ctags vim


7. setup environment

- edit .bash_profile, and add the following at the bottom:

export ERL_LIBS=${HOME}/erlang/lib


8. download nitrogen

$ cd; mkdir -p erlang/lib; cd !$
$ git clone git://github.com/rklophaus/nitrogen.git
$ cd nitrogen
$ make


9. done

Sunday, January 25, 2009

nitrogen

i have stumbled upon a very promissing web framwork for erlang. nitrogen, altough very young (first release was around December 2008), it seems exactly what i have looking for. it actually bring the erlang into the web, allowing to develope a true erlang based web app.

nitrogen have several appealing features. the framwork support ajax/comet, which is absolutely a shame how easy it ease to use. it allows defining html templates, with 'holes' in it to insert content from the erlang source. but the real benefit is the ability to write those 'holes' in erlang modules. those 'holes' are filled with elements which are parallel to html structures, and because you are using erlang sytax to describe them, you can use the erlang pattern matching and messaging system in it.


Friday, January 16, 2009

coLinux strikes back!


because the colinux images are very old, i have decided to build one of my own, based on ubuntu 8.10. so, i followed this post, to create my colinux image. keep in mind installing ubuntu using qemu on windows takes ages (really, few hours, so schedule it to an hour before you go to sleep).

later, i just added another conf file to start this colinux, see more details on me previous post:
kernel=vmlinux
sda1="c:\linux\distro\ubuntu_8.10.ext3.3gb.img"
sda2="c:\linux\distro\ext3_disk_1gb.img"
sdb1="c:\linux\distro\swap_512mb"
root=/dev/sda1 fastboot 3
ro
mem=384
eth0=slirp
eth1=tuntap

moreover, i edited the network and samba, again, as i posted before. afterward i have installed erlang and yaws.
finally, few fixes and tweaks i have encountered:

because i want it as a server:
$ sudo apt-get install linux-headers-server linux-image-server linux-server

to solve and odd error message on startup (mmap: Bad address):
$ sudo apt-get remove dmidecode --purge

to prevent yaws, and few other services i don't need form start after boot:
$ sudo update-rc.d -f bluetooth remove
$ sudo update-rc.d -f gdm remove
$ sudo update-rc.d -f yaws remove

that's it! if you got so far, you are officialy an uber-geek ;)

Wednesday, December 31, 2008

life expectancy

a thought.

people now days live longer and longer, but most of them work harder to support their life style. overall one could say, the mean life time is steadily growing, but the amount of free time one has in his lifetime is pretty much the same. moreover, the majority of the time spent on work is done while one is at his prime of his life.

or... you can enjoy what you do for work.

live longer, don't forget to enjoy the time.

Sunday, December 28, 2008

[toread]

handy web-clipping i found: toread.

simply enter your email address, drag the little [toread] link they supply, and now, every time you stumble on a page you wish to save or read later, just press the [toread] link. the web page and link will be sent to your mail.

useful.

simple.

brilliant.

Saturday, December 13, 2008

More on Chrome

some random stuff i found about google chrome:

1. javascript snippets which functions like an add-on, can be found here. you have there adblock, linkfy and more.

2. i use linksys WRT54G and i couldn't access it with chrome since on login the user name is left empty. i just managed to pass this after entering a space as the user name, with the right password of course ;) 

3. last thing is about monospace font on chrome (and firefox as well) is that it look to me too small. i don't know why i didn't do it so far, but i just changed it's size from 13 to 14.