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 dat type also known as map. You may be already familiar with them, if using Associative Arrays in PHP or Hash-tables 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 indexed by 1 and so on) you can use string indexes. Each element of a map is accessed (or, indexed) by an unique key, and so they are known as key-value pairs. Dictionaries are not sequences, hence maintains no left-to-right order.

Dictionaries are not sequences, hence maintains no left-to-right order.


You can create a map by the declaration: var_name = {key:value}

Code after “>>>” in following examples means: you need to type the code in Python command line. Any line not beginning with “>>>” indicates an output.

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

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

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

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

Alternately, you can declare an empty map, and insert key-value pairs later. Unlike Lists, you can perform out-of-bound assignments:

>>> D = {}

>>> D['name'] = 'Bob' # Create keys by assignment

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

>>> D['age'] = 40

>>> D
{'age': 40, '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!