Wednesday, August 19, 2009

How to install Adobe Flash Player plugin on Ubuntu

To install Adobe Flash Player plugin

sudo apt-get install flashplugin-nonfree

To check the current version, if installed using Aptitude (the method above)
sudo aptitude show flashplugin-nonfree

Tuesday, August 18, 2009

How to post source code for viewing in WordPress.com

WordPress.com allow you to post source code of some languages.

The supported languages include:

  • bash

  • cpp

  • csharp

  • css

  • delphi

  • html

  • java

  • jscript

  • php

  • python

  • ruby

  • shell

  • sql

  • vb

  • xml


What you need to do is to wrap the source code between sourcecode tag. For example:
[sourcecode language='python']

your code here

[/sourcecode]

Saturday, August 15, 2009

Convert RPM package to deb package format on Ubuntu

How to convert RPM package to deb package format on Ubuntu, and install it with dpkg?

Step 1: Install the required packages

sudo apt-get install alien dpkg-dev debhelper build-essential

Step 2: Convert the RPM file


Run
sudo alien thepackagename.rpm
or
fakeroot alien thepackagename.rpm
and a .deb file called thepackagename.deb will be generated.

Step 3: Use dpkg to install the package

sudo dpkg -i thepackagename.deb

Thursday, August 13, 2009

Python: Remove items from a list that occur in another list

Suppose that you have two list x and y. How to remove items from list x that occur in list y?

Method 1

>>> x = [1, 2, 3, 4, 5, 6, 7, 8]
>>> y = [4, 7, 9]
>>> list(set(x) - set(y))
[1, 2, 3, 5, 6, 8]

Method 2

>>> x = [1, 2, 3, 4, 5, 6, 7, 8]
>>> y = [4, 7, 9]
>>> [i for i in x if i not in y]
[1, 2, 3, 5, 6, 8]
I have presented two methods for removing items from list x that occur in list y. If you have better method, please leave a comment.

Sunday, August 2, 2009

How to download YouTube video on Ubuntu

You can download YouTube video with youtube-dl.

Install youtube-dl

sudo apt-get install youtube-dl

Download the video

youtube-dl http://the-youtube-video-uri

Convert into MPEG format

ffmpeg -i source.flv output.mpg

How to install Java on Ubuntu 9.04

To install Java support on Ubuntu, run this command in a Terminal:
sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin
You can also click here to test whether the JVM is working fine in your browser.

Saturday, August 1, 2009

How to enable Apache public_html for user on Ubuntu

Suppose that you want each user to have their own public_html in their home directory.

For example, user with username ahmad, can have his own Web site at
http://localhost/~ahmad


Enable mod_userdir

To achieve that, first, what you need to do is to enable mod_userdir, which is installed by default with Apache2.
sudo a2enmod userdir

Create public_html directory

Second, the user need to create public_html directory in their home directory.
mkdir public_html

Restart Apache

Finall, you should restart Apache.
sudo /etc/init.d/apache2 restart