How to install Greasemonkey (User javascripts) In Opera

Please note that not all Greasemonkey scripts run on Opera. However, most of them works just fine 🙂

These scripts are called User JavaScripts on Opera.

How to install an User JavaScript:

Step 1

Create a folder any where in your computer. Name it as you like (exapmle: MyOperaScript).

Step 2

Copy user script file on that folder.

Step 3

Launch Opera. Then Go to:

 Tools > Preferences  > Advanced > Content>JavaScript Option

select the folder created in step 1.

Click “OK” and exit preference window.

Opera Greasemonkey Support

That’s so simple! 😀

Python Tutorial: Dictionaries (Maps): Advanced features

Sorting: more loop operations of maps

Suppose, we have the following map:

>>> D = {'a': 1, 'b': 2, 'c': 3}
>>> D
{'a': 1, 'c': 3, 'b': 2}

We can create a list of keys of a map, then use a for loop to treat it as a sequence:

>>> Ks = D.keys( ) # Unordered keys list
>>> Ks
['a', 'c', 'b']
>>> Ks.sort( ) # Sorted keys list
>>> Ks
['a', 'b', 'c']
>>> for key in Ks: # Iterate though sorted keys
print key, '=>', D[key]
a => 1
b => 2
c => 3

Checking existance of a key:

Fetching a non-existant key is error. Consider the following code snippet:

>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> D['e'] = 99 # Assigning new keys grows dictionaries
>>> D
{'a': 1, 'c': 3, 'b': 2, 'e': 99}
>>> D['f'] # Referencing one is an error
...error text omitted...
KeyError: 'f'

We can use following method to check whether a key exists:

>>> D.has_key('f')
>>> if not D.has_key('f'):
print 'missing'

Python Tutorial: Dictionaries (Key-value pair Maps) Basics

Dictionary in Python is a data-structure also known as map. Chances are you’re already familiar with them, if using Associative Arrays in PHP or Hashtables in C++ or Java. You may imagine a dictionary as an array, where instead of numerical indexes (the first element of array is indexed as 0, the second element is indexed by 1 and so on), you use string indexes. Each element of a map is accessed (or, indexed) by an unique “key”; so they are also known as key-value pairs. Dictionaries are not sequences, so the order in which elements are added to the dictionary doesn’t matter.


Suppose, we want a data-structure to store information about a cooking recipe. For the recipe, we want to store which food (dish) we’re cooking, how many quantities it serve, and the color of the food being  prepared (don’t ask me why).

You can create a map using this syntax: variable_name = {key:value}

In the following examples, any text after “>>>” is actual code that you use in your Python scripts. You can also type this code in Python command line interpreter. Any line not beginning with “>>>” indicates an output of the previous code.

>>> D = {'food': 'pudding', 'quantity': 4, 'color': 'pink'}

>>> D['food'] # Fetch value of key 'food'

>>> D['quantity'] += 1 # Add 1 to 'quantity' value

>>> D
{'food': 'pudding', 'color': 'pink', 'quantity': 5}

Alternately, you can create an empty map, and insert key-value pairs later. Unlike Lists (arrays in Python), you can perform out-of-bound assignments:

>>> D = {}

>>> D['name'] = 'Bob' # Insert element on-the-fly

>>> D['job'] = 'dev'

>>> D['age'] = 4

>>> D
{'age': 4, 'job': 'dev', 'name': 'Bob'}

>>> print D['name']


Like lists, nesting is also possible in maps. Consider the following code pattern:

>>> rec = {'name': {'first': 'Bob', 'last': 'Smith'},
                  'job': ['dev', 'mgr'],
                  'age': 40.5}

>>> rec['name'] # 'Name' is a nested dictionary
{'last': 'Smith', 'first': 'Bob'}

>>> rec['name']['last'] # Index the nested dictionary

>>> rec['job'] # 'Job' is a nested list
['dev', 'mgr']

>>> rec['job'][-1] # Index the nested list

>>> rec['job'].append('janitor') # Expand Bob's job description in-place

>>> rec
{'age': 40.5, 'job': ['dev', 'mgr', 'janitor'], 'name': {'last': 'Smith', 'first':

How to automatically update Twitter status by PHP

I was wondering how to update my status automatically in twitter using PHP, & found some interesting articles on the internet. I found One all-in-one open-source php project which needed CURL support, but many servers can restrict that access to curl. So with a little help from here & the official Twitter API, I’ve just prepared a working script to Update your Status at twitter automatically 🙂 The best thing is, you don’t need to have CURL enabled! (it will then use fsockopen if CURL is disabled)

Download Code

How to Use

Once downloaded, save the code in a file like twitter.php

Then use following simple function to automatically update your status:

$status = "My First status from the API!";
// encode the status
$status = urlencode($status);
// Tweet it!
$twitter = tweet($username,$password,$status);
// Now you can do additional fun with the data returned at $twitter variable. That's not necessary after all

Troubles? Let me know…… Got help? Cheer me up!