Page 2 of 3

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:

root=/dev/sda1 fastboot 3

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 to 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 now officialy an uber-geek ;)

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.



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.

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.


every now and then i want the linux power on my windows. i tried all the workarounds: cygwin, unix-tools, vmware, virtual box, even the new microsoft powershell.

then i found colinux.

colinux actually runs a linux os as a windows program. i am not so strong on how it works, but i do use it and enjoy it, especially now when i develop on linux, and i don’t want to be remotely connected to another server all the time. i decided to share the setup i did for a colinux on my vista machine. here is the how-to, basically i followed the instructions at the colinux wiki:

  1. download colinux-stable from:
  2. download ubuntu distribution from the same address.
  3. install colinux c:\colinux, don’t download any distribution from the installer.
  4. unzip distribution files into c:\colinux.
  5. download 324Mb swap file from:
  6. unzip swap file into c:\colinux.
  7. edit c:\colinux\example.conf:
  8. create and run batch file, with this content:
    colinux-daemon.exe -t nt @example.conf
  9. login using id: root, password: root.
  10. edit /etc/network/interfaces:
    auto eth0
    iface eth0
    inet staticaddress
    auto eth1
    iface eth1
    inet staticaddress
    <li> edit tap adapter on windows: control panel\network and internet\network connections:
    <pre lang="text">properties, tcp/ipv4
    static ip:
    subnet mask:
    gateway: leave blank
  11. add new user, as root:
    useradd -d /home/user_name -g admin -m user_name 
    passwd user_name
  12. install ssh:
    sudo apt-get install ssh
  13. login using putty, connect to
  14. update system
    sudo apt-get update
    sudo apt-get upgrade
  15. change basic shell to bash:
    chsh -s /bin/bash user_name
  16. use samba to access linux machine from windows:
    sudo apt-get install samba
    sudo /etc/init.d/samba stop
  17. edit /etc/samba/smb.conf:
    	workgroup = WORKGROUP
    	valid users = user_name
    	path = /home/user_name
  18. start samba again
    sudo /etc/init.d/samba start
  19.  add yourself as a samba user:
    sudo smbpasswd -L -a your_username
    sudo smbpasswd -L -e your_username
  20. on windows, right click on ‘my computer’ and choose ‘map network drive’, then enter: \\host_name\user_name, and fill your samaba password when asked to. if you haven’t changes the default host name then it is ‘ubuntu’
  21. that’s it :)

google chrome

today i stumbled upon google new internet browser, chrome, again. once, when it first went out, i tried it, and left it, because i felt firefox it pretty good for me. but today i found an interesting comic page that describe the main idea behind it. well, the comic presentation is great, and the ideas are great, so i decided to give it a try once again. first thing i felt, is the lack of my firefox add-ons, my foxmarks to sync bookmarks across computers, at work and at home, the adblock which saves me from epileptic sites, ‘copy and go’, greasemonkey, etc.

sure, i can live without few of them, but adblock and bookmark sync are must. luckily i was glad to see there is a nice solution for the adblock, see

by the way, if google don’t want to loose their adsense business with their own browser, they should supply or support an adblock plugin. because the solution above remove all ads from the page, while the firefox plugin is more delicate and customizable, which allows the user to disable only irritating ads.

overall, the browser is very fast, and quite nice actually. it is nice to see companies and groups bold enough to enter into a very saturated area, and change the rules. that what microsoft did with internet explorer 3 and above to netscape (who remember them today?), that what firefox did to ie, and now it is interesting to see a true change to this whole field of browsers.

a great page presenting some of the tweaks availble for google chrome can be found here.

on less functional level, one can ask himself, where does it go. well, staying on the technological level, rahter on the theological, i read a lot on the web about the cloud computing. an article by Steve Balmer, another opinion about google chrome and android, just search for ‘cloud google chrome‘ and there are plentty of them.

each and his own imagination, i just hope we will not wake up from a dream of open source, free applications, into an admition fee based server-barred-services reality.

copy and go

i found this hilarious item, and immediately wanted to post it:

isn’t it frustrating when the link is posted in plain text? well, there is a firefox add-on which solves it, and gives the option to open it immediately on a new tab. the add-on is called ‘copy and go’ and can be found here:

by the way, for all the ie users or those without this add-on, here is the link i pasted above as text, more properly presented: did i say that i am the plugin author? ;)

code coverage in erlang

yesterday i found about code coverage under erlang on this nice blog. i wanted to integrate it with my unit testing, so i would be able to see what code of mine is not tested. this can be used to add new tests to cover it, or even remove of unnecessary code.

it took me some time to play with it and come up with a good method of doing that. eventually i have replaced the unit testing makefile line with:

	@for f in $(MODULES); do \
	echo $$f; \
	erl $(FLAGS) -noshell -eval "
	cover:compile($$f, [{i,\"$(INCLUDE)\"}]),\
	cover:analyse_to_file($$f, \"$(DOC)/$${f}_coverage.html\", [html])."\
	-s init stop; \

This actually do 3 things in a raw:

  1. compile each module using cover:compile.
  2. run the test, using the eunit test() function.
  3. dump analysis into html files on doc directory


edit: i found out, that you compile the whole directory for covearge, so the result you get is thecombined  coverage for all the specified modules and tests.

OBJECTS := $(patsubst %.erl,$(BIN)/%.$(EMULATOR),$(wildcard *.erl))
MODULES := $(patsubst %.erl,%,$(wildcard *.erl))
SKIP_FILES := $(patsubst %.erl,%,$(wildcard *_tests.erl))
MODULES := $(filter-out $(SKIP_FILES), $(MODULES))
MODULES := [$(subst $(space),$(comma),$(MODULES))]
	@echo Testing units...
	@$(TIME) erl $(ERL_LIB_FLAGS) \
	-mnesia dir '"$(DATA_DIR)"' -mnesia debug $(MNESIA) -noshell \
	-eval "\
	cover:compile_directory(\".\", [{i,\"$(INCLUDE)\"},{d,'NODEBUG'}]), \
	T = fun(X) -> io:format(user, \"~-20.s\", [X]), X:test() end, \
	[T(X) || X &lt;- "$(MODULES)"], \
	F = fun(X) -> cover:analyse_to_file(X, \"$(LOG)/\" ++ \
	    atom_to_list(X) ++ \"_coverage.html\", [html]) end, \
	[F(X) || X &lt;- "$(MODULES)"]. \
	" -s init stop;

more on eunit

the use of eunit is very easy and intuitive. in principle every function which ends with _test of arity 0 (i.e. no input arguments) will be automaticly exported by eunit. eunit will also create a function called test() which will call all tests functions which have been defined. this mechanism leaves the programmer with only the actual test writing, and saves him/her the tedious wrappers and procedures. writing a test on a new module become something which take few seconds.

for example, the next function has its own testing function:

flip_sides(Side) ->
	case Side of
		x -> o;
		o -> x
flip_sides_test() ->
	?assert(flip_sides(x) == o),
	?assert(flip_sides(o) == x).

the testing function is invoked automatically by calling the test function of this module, e.g. mymodule:test(). the test function is supplied by the eunit framework, which takes every function that ends with _test() and add it to the testing list of that module.

a more advanced testing method is needed for testing the always loops that keep the state on the erlang module. few problems need to be solved in order to properly test those kind of loops:

  • initial state loading.
  • external function calls.
  • check of the new state, after each event.
  • the first problem can be solved by adding a new start function for debug use, which takes all the state variables of the always loop as parameters. this allows you to start the always loop in any state you want.

    % original start of arity/0
    start() -> start([], start).
    % new function for debug of arity/2
    start(State, Status) ->  register(?MODULE, spawn(fun() -> always(State, Status) end)).
    % the state loop
    always(State, Status) ->
    		{From, stop} -> From ! stopped;
    		{From, reset} -> always([], start);
    		{From, {add, N}} -> always(module2:add(N, State), continue)

    the next problem is the call for external function, shown here as call for module2:add/2, i solved this by adding another parameter to the loop’s state in order to keep a reference to the called function. i have also added it to the start function.

    % original start of arity/0
    start() -> start([], start, fun module2:add/2).
    % new function for debug of arity/2
    start(State, Status, Func) ->
    	register(?MODULE, spawn(fun() -> always(State, Status, Func) end)).
    % the state loop
    always(State, Status, Func) ->
    		{From, stop} -> From ! stopped;
    		{From, reset} -> always([], start, Func);
    		{From, {add, N}} -> always(Func(N, State), continue, Func)

    adding a reference to the external function allows me to switch to a mocking function as desired. for the new state checking i have added a dump command to the always loop which return me the current state, so i can test it on my testing functions.

    % the state loop
    always(State, Status, Func) ->
    		{From, stop} -> From ! stopped;
    		{From, reset} -> From ! reset, always([], start, Func);
    		{From, {add, N}} -> always(Func(N, State), continue, Func);
    		{From, dump} -> {State, dump, Func}

    last i’ll show the test function:

    always_reset_test() ->
    	Fun = fun callback_check_reset_mockup/2,
    	start([x, o], continue, Fun),
    	?assert(rpc(dump) == {[], start, Fun}),

    callback_check_reset_mockup(N, State) -> void. % you can check match if applicable

    that’s it!

firefox tip

firefox is a very good browser. after all the bantchmarks and preformance tests, one of his unrivalled strength points, is the add-on ability. sometime we forget it has also a great build-in cutomization ability availble for the end user. recently i found this firefox 3 feature that i use a lot.

i use firefox url address bar for custom search, e.g. i have already defined:

g	google search
b	babylon translation
gs	google search on specific site
gc	google code search
gd	google define

i know you can use the little search box on the upper right corner, but it is so small… but why can’t i use the big address bar ?? well, the answer – yes is i can :) and i’ll show you how.

for example if i want to simply do a google search. i go to the address bar (quick access: ctrl+l), and i type: g something in my mind

well, ok, so? so i am surfing this blog, and i want to search the term ‘erlang’, and there is no build in search on this site, or i just prefer to use google search, again i go to the address bar, i add ‘gs’ and space before the url, and i add the term on the end of it, again separated by space: gs erlang


how do i do that? on firefox 3 you can add keyword to bookmarks, all you need to do is to open the bookmarks menu, and then click organize bookmarks. there, for each bookmark, there is additional data at the bottom, press the ‘more’ button, and few additional options will appear. the one that interests us right now is the ‘keyword’, here you put your desired shortcut (e.g. g for google). moreover, on the ‘location’ you can add the rest of the address bar contents as %s.

so, here is the above shortcuts keywords and locations:

gsgoogle ’site:’
gcgoogle code search
gdgoogle ‘define:’
bbabylon translation

Powered by WordPress & Theme by Anders Norén