google chrome

tools Tagged with:
Oct 282008

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 http://stevenpratt.com/2008/09/06/google-chrome-adblock-plugin

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

tools Tagged with:
Oct 252008

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

http://www.flickr.com/search/?q=squishycow

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: https://addons.mozilla.org/en-US/firefox/addon/6876.

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: http://www.flickr.com/search/?q=squishycow. did i say that i am the plugin author? ;)

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:

check:
	@for f in $(MODULES); do \
	echo $$f; \
	erl $(FLAGS) -noshell -eval "
	cover:compile($$f, [{i,\"$(INCLUDE)\"}]),\
	$$f:test(),
	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

enjoy!

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))]
 
check:
	@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 <- "$(MODULES)"], \
	F = fun(X) -> cover:analyse_to_file(X, \"$(LOG)/\" ++ \
	    atom_to_list(X) ++ \"_coverage.html\", [html]) end, \
	[F(X) || X <- "$(MODULES)"]. \
	" -s init stop;

firefox tip

tools Tagged with:
Oct 222008

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 http://www.virtual-clouds.com/ erlang

woot!

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:

keyword description location
g google http://www.google.com/search?q=%s
gs google ‘site:’ http://www.google.com/search?q=site%3A%s
gc google code search http://www.google.com/codesearch?q=%s
gd google ‘define:’ http://www.google.com/search?q=define%3A%s
b babylon translation http://search.babylon.com/web/%s?babsrc=client
Oct 222008

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
	end.
 
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) ->
    	receive
    		{From, stop} -> From ! stopped;
    		{From, reset} -> always([], start);
    		{From, {add, N}} -> always(module2:add(N, State), continue)
    	end.

    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) ->
    	receive
    		{From, stop} -> From ! stopped;
    		{From, reset} -> always([], start, Func);
    		{From, {add, N}} -> always(Func(N, State), continue, Func)
    	end.

    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) ->
    	receive
    		{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}
    	end.

    last i’ll show the test function:

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

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

    that's it!

Oct 212008

erlangi have started off a new project, mostly based on erlang, and i have decided to post few of my observations and experiences which i pick along the way. i will start with edoc and eunit, both i have added to my project with zero effort, and got remarkable results.

edoc produces automatic documentation for the project. i have just added the right code to my project makefile, and voula – instance documentation for my functions api. the code itself is:

docs:
erl -noshell -eval "edoc:application($(APPNAME), \".\", [$(DOC_OPTS)])" -s init stop

where:

APPNAME = myappVSN = 0.1
DOC_OPTS = {def, {version, \"$(VSN)\"}}, no_packages

eunit gives an easy way to add unit testing to the project, again, i have added few lines to my makefile:

MODULES = $(patsubst %.erl,%,$(wildcard *.erl))
check:
@for f in $(MODULES); do \
echo $$f; \
erl $(ERL_LIB_FLAGS) -noshell -s $$f test -s init stop; \
done

those few lines takes all the erl files on the current directory and run the test function for each module.

that’s it for the first time.

© 2010 Virtual Clouds Suffusion WordPress theme by Sayontan Sinha