Embracing Firefox 5!

For Ubuntu 10.04.

sudo add-apt-repository ppa:mozillateam/firefox-stable

sudo apt-get update

sudo apt-get install firefox

From : http://support.mozilla.com/en-US/questions/795196

If behind firewall,
$ sudo bash
# export https_proxy=http://www.example.com:8000/
# add-apt-repository ppa:

From: https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/516032

Advertisements

Geany – Python Source Code Editor

Geany is good Python source code editor in as it fulfills my required features (i) code-folding and (ii) dark colour theme.

By default, Geany only shipped with white color background. However, different color schemes can be downloaded from here. Currently I am using the geany-dark-scheme.

*In Ubuntu, one of parameters of the config file “filetypes.python” should be: stringeol=0xE23636;0xe0c0e0;false;false.

Python Assignment

Someone think out an assignment to improve my Python skill.

Question: List 10 ways to add from 1 to 10 in Python.

Answer:

# Method 1
num_list = range(10+1)
result = sum(num_list)

# Method 2
num_list = range(10+1)
result = 0
for n in num_list:
	result += n

# Method 3
result = 1 + 2 + 3 + 4 + 5 + 6 +7 + 8 + 9 + 10

# Method 4 (Recursive call)
def calc(num):
	if num == 0:
		return 0
	return num + calc(num-1)

result = calc(10)

# Still thinking for the rest .... will update in future.
# Still thinking for the rest .... will update in future.
# Still thinking for the rest .... will update in future.

 

Tackling Polynomial Equations with Python (Numpy)

How to calculate a polynomial of  (s+1)(s+2)…(s+10) in a short time?

Instead of calculate them one by one, we can do it with the help of Python library – Numpy.

1. Make sure you have installed Numpy for your Python interpreter. In Ubuntu, you may just want to install python-scipy as it contains all the scientific calculation tools.

2. Try the following example in your python interpreter:

from numpy import *
p1 = poly1d(1, 1 ) #(S+1)
p2 = poly1d(1, 2 ) #(S+2)
p3 = poly1d(1, 3 ) #(S+3)
p4 = poly1d(1, 4 ) #(S+4)
p5 = poly1d(1, 5 ) #(S+5)
p6 = poly1d(1, 6 ) #(S+6)
p7 = poly1d(1, 7 ) #(S+7)
p8 = poly1d(1, 8 ) #(S+8)
p9 = poly1d(1, 9 ) #(S+9)
p10 = poly1d(1, 10) #(S+10)
print p1*p2*p3*p4*p5*p6*p7*p8*p9*p10

3. Then, you will an get an output like:

   10      9      8       7       6       5       4       3      2
1 x  - 10 x + 45 x - 120 x + 210 x - 252 x + 210 x - 120 x + 45 x - 10 x + 1

That is the answer:

 x^10 - 10x^9 +45x^8 - 120x^7 + 210x^6 
- 252x^5 + 210x^4  - 120x^3 + 45x^2 - 10x + 1

4. Say, we need to find the root of this polynomial. With the help of Python, we can get the roots by feeding these line into the interpreter.

(p1*p2*p3*p4*p5*p6*p7*p8*p9*p10).r #.r means root.

And, we will get an output like this:

array([ 1.04405137+0.0143565j ,  1.04405137-0.0143565j ,
        1.02709855+0.03755416j,  1.02709855-0.03755416j,
        0.99974141+0.04619473j,  0.99974141-0.04619473j,
        0.97275208+0.03706564j,  0.97275208-0.03706564j,
        0.95635659+0.01406697j,  0.95635659-0.01406697j])

The polynomial has 5 complex conjugates: 1.04405137 +/- 0.0143565j, 1.02709855 +/- 0.03755416j, 0.99974141+/- 0.04619473j, 0.97275208 +/-0.03706564j, 0.97275208 +/- 0.03706564j and 0.95635659 +/- 0.01406697j .

Clothe Naked Data with Encrypted Partition

February 2008 – Edison Chan, a Hong Kong artist is found to be in troubles after his sex photo scandal circulates the world through Internet. He claimed that the photos were stolen after sending his laptop to a repair shop.

Edison did a mistake that we do, that is, storing files nakedly in machine.

Some files like docs and spreadsheets can be encrypted with the tool provided by OpenOffice itself. However, pictures and MP4 are left nakedly in hard disk. A baddie may possess these files by overriding the user privilege (E.g. using live-CD to bypass).

To overcome this, we encrypt our partitions. Most of the Linux users will have two partitions in their machine. One for for the root (/, /root, /bin,…) and another one for users home directory (/home). To avoid performance impact, we can encrypt the the partition of the home directory.

In the following example, Ubuntu 9.10 will be the targeted Linux OS, and LUKS is used as the encryption system.

Continue reading “Clothe Naked Data with Encrypted Partition”