Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Sep 14, 2013

Difference Between Update and Upgrade in Ubuntu

Update :
Updates the list of available packages and their versions, but it does not install or upgrade any packages.
apt-get update


Upgrade :
Installs newer versions of the packages based on the updated list of available packages.
apt-get upgrade

After updating the lists, the package manager would know about available updates for the software already installed in a computer. This is why running update prior to upgrade is recommended.

Jul 1, 2013

Creating GIF animation in Ubuntu

From the manual of 'covert'
The convert program is a member of the ImageMagick(1) suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
The above quoted paragraph is an understatement of the abilities of convert. Besides many amazing acts, Convert is capable of creating of animated GIF images. To do so, type the following in terminal:
$ convert -delay 100 -loop 0 image*.png animation.gif
For more on ImageMagick, I recommend this blog post.

Dec 2, 2012

Calling C functions from Python

Python is capable of calling functions from a C library. Say, we have the following C code which needs to be used in a python script. I'm using Ubuntu 12.04 with python 2.7.
int add(int a, int b) { return (a+b) ; }
First the C code has to be compiled as a shared library.
$ gcc -fpic -c c_code.c $ gcc -shared -o c_code.so c_code.o
Then the shared library has to be copied to /lib/x86_64-linux-gnu/
$ sudo cp c_code.so /lib/x86_64-linux-gnu/
The following python script imports the shared library and invokes functions from it.
from ctypes import cdll,c_int lib = "c_code.so" dll = cdll.LoadLibrary(lib) add = (lambda x,y: dll.add(c_int(x), c_int(y))) print(add(1,1)) print(add(2,3))

Nov 30, 2012

Fixing broken merge list in Ubuntu

Sometime broken merge list poses a barricade on the path of further updates. To fix this problem, the old (flawed) merge list has to be removed first, then a new one has to be created. In Ubuntu 12.04, the following worked for me.
sudo rm /var/lib/apt/lists/* -vf sudo apt-get update

Nov 7, 2012

Opening a Terminal Anywhere in Ubuntu

Being able to open a terminal from any location on the file system tree (even when you're logged in on a remote server) is a very useful feature. Installing nautilus-open-terminal provides this option in the context menu. To install,
$ sudo apt-get install nautilus-open-terminal
Natuilus file system needs to be reset after installation. To do so,
$ nautilus -q
Right click to bring up the context menu and be happy to see the 'Opne in terminal' option :)

Oct 13, 2012

Matplotlib


Quoting from the Matplotlib website,

matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python and ipython shell (ala MATLAB®* or Mathematica®†), web application servers, and six graphical user interface toolkits.
It allows generation of publication ready plots and charts from a python script. Just started using this in one of my current projects and finding it satisfactory so far. The matplotlib figures can also be exported to a number of bitmap formats and vector formats like PDF. A definite advantage compared to MATLAB.

I'm using Ubuntu these days, to install Matplotlib in your Ubuntu box:

1. Ubuntu software centre,
or
2. Install it using apt
$ sudo apt-get install python-matplotlib

Oct 3, 2012

Python in Ubuntu

My favorite development environment for Python in Ubuntu is Eclipse. The following steps describe how to get an up and running development environment on your Ubuntu box.

1. Python

Python usually comes with the bundle but just in case:
$ sudo apt-get install python

2. Eclipse

Eclipse is available from the Ubuntu Software Center, I usually install it from there that. Another option is to install it manually, which I never tried myself.
$ sudo apt-get install eclipse sun-java6-jdk $ sudo udate-java-alternatives -s java-6-sun

3. Pydev

  1. Run Eclipse
  2. Help -> Install New Software
  3. Type in "Work with": http://pydev.org/updates, name should be Python
  4. Select Pydev from the list of available options, then click Next
  5. Select the Python module that needs to be installed, click Next
  6. Let the downloading finish, then restart Eclipse

Ubuntu Installer for Windows

Ubuntu 12.04 (the latest version at the time of writing this) has an installer for windows which can be downloaded from here. It allows you to download the installer as a windows executable (.exe) and perform the installation like installing many other windows applications. Thanks, Ubuntu.