Tag Archives: 2013

Understand Python decorators – part 001

Do you know what is a function in python language.

Then the decorator is a function that takes one argument and returns something useful.

The big diff is the way we use this.

About the decorator : function that takes one argument – the function being decorated.

The result it’s returns the same function or a function with a similar signature.

How can do that with one function make_something:

You have this function with some inputs : function_inputs .

If you want to use decorator then :

The decorated function is wrapped by a function which calls the decorated function.

This is the reason we have : return wrapped

When we need to use the decorated function then just use it with @ .

Let’s try one simple example:

The result come with:

Easy or not?

When we run the script the results will come in this order:

It’s only print hello and 3 functions.

Also we have 2 functions decorated.

first will be :

… and in the end all will be print :

This is just one step in decorators , because is more. Like classes or

If is to hard for you , see this example:

This means:

It’s something like a=deocorator(a)

Because functions and classes use many forms then will give us some rules.

Posted in All, Programming, Python. Tagged with , , , .

Make your mozilla browsers faster.

If you use mozilla browsers like firefox, iceweasel or else the is a way to make it faster.

Just disabling hardware acceleration seems to have made Firefox open drastically faster.

Go to browser settings Options – Advanced and uncheck Use hardware acceleration when available, see next image:


Posted in All, Linux, Windows 7, Windows 8, Windows XP. Tagged with , , , , .

Working with cookies and selenium python module.

Today I will show how to deal with cookies and Firefox.

Selenium Python Client Driver is a Python language binding for Selenium Remote Control.

You can read more about this module here.

You can find some examples , but most of webpages working with cookies.So let’s make one simple tutorial.

The next source code is very simple and most of the python users knows what means.

The next source codes will get your cookies from the webpage.

You can deal with all functions of selenium python module , see :

This module can be a way for you to testing your webpages , save cookie , restore and more…

Also , if you know networking development also you can use scapy module to test more.

I hope will like this simple tutorial about python.

Posted in All, Programming, Python. Tagged with , , .

Set your special keys under LXDE environment.

You can use xev command to print contents of X events.

Now is need to parse the all content output to see the keys code.

Copy the output. You will need later.

Create a file and named .Xmodmap .

Put the content output and change like :

Now is need to set the enviroment using command xmodmap.

Restart your computer. This will reload the settings for your keyboard.

Posted in All, Linux. Tagged with , , .

Connect and debug your android application with one function under linux os.

This is a simple way to use your tablet device to debug your android applications.

Go to root account and open the .bashrc file.

Type the next source code using your home folder account.

Restart your terminal, connect your tablet device .

Now you can use this command : tablet to start connection with your tablet.

Sometime is need to use root account to stop and start the server…

Posted in All, Android, Linux, Programming. Tagged with , , , .