Sunday, January 4, 2009

custom search in maxthon 2

Maxthon is my favorite internet browser and one of its greatest features is the custom search ability. You can run a search in (almost) any site just by writing your query to the address bar and hitting enter. Let's see how it is done.

Go to the website in which you'd like to search your query. In our example, the website is mininova which is a torrent search engine.


Write an arbitrary query to the search box. We use "Queen" as query. Then, hit the search button.

mininovaNow that the search results are in hand, take a look at the address bar.



mininova


You can see that "http://www.mininova.org/search/?search=Queen" is written in the address bar. This means that, for running a different search all we have to do is changing the word "Queen" with the new query (e.g. http://www.mininova.org/search/?search=Savatage) and hit enter to load the new url. But there is an easier alternative that'll automate our search so we won't have to write that long url everytime we want to search a torrent.

Now open maxthon > tools > maxthon setup center and choose search tab and click on "add item". You'll see a row like this:

mininovaFirst textbox is the title. You can choose something arbitrary. I choose "Torrent" in our example. The second textbox is alias. We will choose an alias for the search engine which will reduce the necessary amount of typing. I choose "t" (for torrent). So I will be able to do a custom search with the syntax "t myQuery". The third one is the url that we discovered in previous steps. It was "http://www.mininova.org/search/?search=Queen" for our example. We will replace our example query by "%us" which will give us http://www.mininova.org/search/?search=%us
in our example. I replace "Queen" with "%us" and write the new url in the corresponding textbox and then click on save.

mininova

Now, you can search a torrent by writing "t Query" to the address bar and hitting enter. Bon appétit!

Friday, January 2, 2009

useful stuff about associative arrays in javascript

Associative arrays in javascript have a similar task to associative arrays in any programming language; holding key-value pairs. If, for instance, our "keys" are fruits and the "values" associated to these keys are fruits' count in the basket then fruitBasket which holds these keys (fruits) and values (fruits' count) is the associative array.

First let's see how an associative array is created;


var fruitBasket = new Array(); /*create it just like any other array*/


Then let's populate our fruitBasket with different types of fruits


fruitBasket["apple"] = 1; // there are one apple
fruitBasket["orange"] = 3; // three oranges and
fruitBasket["lemon"] = 2; // two lemons in our fruit basket


Now, let's retrieve the value associated with a key. For instance, let's retrieve and print the count of "apple".


document.print(fruitBasket["apple"]);


I'm interested in the whole content of my fruitBasket. I want to print it. But how can I retrieve it? Assuming that the keys of the associative arrays are objects (fruits of type String in our example), it is quite easy to guess that we can't access them the way we did with plain arrays. So fruitBasket[0] won't return me the first fruit in the basket. Let's see how we can accomplish it.


for(var fruit in fruitBasket){ /*for each key in the associative array*/
// write the key (fruit name)
document.write(fruit+"=");
/* write the value associated with the key (fruit count)*/
document.write(fruitBasket[fruit]+", ");

}


Now, allow me to complicate things a little bit. I throw two more apples and three more lemons in the basket. So we have to add 2 apples and 3 lemons to the corresponding counts. Let's accomplish it using our fruitBasket.


/* fruitBasket["apple"] returns the value associated with the key "apple" which is its count in the fruitBasket. */

fruitBasket["apple"] = fruitBasket["apple"] + 2; // add 2 to the actual count
fruitBasket["lemon"] = fruitBasket["lemon"] + 3; // add 3 to the actual count


I want to add a new fruit type to the basket, but first I want to check if it is really a new fruit or an existing one in the basket. Assume that I want to add 2 bananas to the basket.


/*
I try to retrieve the value associated with the key "banana". If there's no such a key then it'll return "null".
*/
if( fruitBasket["banana"] == null ){ // no banana in fruit basket
/* create a banana key and give it 2 as value, that is, add 2 bananas to our fruitBasket*/
fruitBasket["banana"] = 2;
}


To sum up, I tried to show how an associative array is created, how its key-value pairs should be retrieved and how to add new key-value pairs to the associative array.

Thursday, January 1, 2009

removing undesired saved forms from maxthon

Sometimes you unintentionally allow maxthon to save forms (thus to hold your passwords). I'm going to explain the way of removing undesired forms from your system.
  1. Open Maxthon > Tools > Maxthon Setup Center > Magic Fill
  2. Click the entry to be removed, and then click delete

Wednesday, December 24, 2008

disposable e-mail account

If you are bored of giving your e-mail address to lousy forums/websites so that they can fill your inbox with lots of spam, then try mailinator which offers a disposable e-mail service. Give a randomusername@mailinator.com e-mail to the lousy website when you sign-up and then go to mailinator and check your e-mail (you don't need to log in with a password). Do the confirmation thing through the e-mail and voila! You didn't have to give your usual e-mail for a stupid confirmation of a stupid website/forum.

Monday, December 22, 2008

reprogram your mouse buttons via x-mouse

x-mouse I have a Logitech cordless optical mouse. I recently tried to reprogram its buttons for new functionality, but Logitech recommends the usage of native windows vista mouse drivers instead of offering a more functional one, so here I am, googling for an application that'll give me the desired functionality. Then, I found X-Mouse. It has every option I need when I tweak my mouse buttons and a very low RAM consumption. You can change the functionality of left, right, middle, left thumb, right thumb button into one of the offered functions (like "close application", "copy/cut/paste", "send a custom keystroke sequence", "launch any application", "double click" so on) . I highly recommend it.