2014 (old posts, page 5)

[Linux] Synapse Redefines How You Interact With Ubuntu!

Synapse is a graphical launcher enabling you to start applications and also to  quickly find and access relevant documents and files (by making use of the Zeitgeist engine).
 While I was searching for some good file managers, I came across Synapse. It has redefined how I interact with my system. Some reasons why I liked this.

1. It is lightweight and super fast when compared to dash or any other launchers I have used. 

2. You can launch any app you want with just a few key strokes.
3. You can even run commands from it.
4. It can perform actions. If you want to shutdown your system, you don't need to grab mouse or open terminal to shutdown, you can just type sh.... in the launcher, it prompts the shutdown option.
5. It comes with 5 themes. Virgilio theme shows not only matched items but it also shows relevant items.

6. Once you found what you have been looking, you can press ENTER to perform default action or you can press TAB to show other actions.

7. It also keeps a track of your previous searches and you can access them with key down.

It is very intuitive. There is no need to open file manager at all. Whatever file you want, just type a few letters, you can jump to location of file or you can open file directly. So I can play whatever music I want instantly and do whatever I want.

To install it on Ubuntu 14.04, you can use this ppa.
sudo apt-add-repository ppa:synapse-core/testing
sudo apt-get update
sudo apt-get install synapse
Happy synapsing!!

Scaling Celery - Sending Tasks To Remote Machines


Celery is a Python package which implements a task queue mechanism with a foucs on real-time processing, while also supporting task scheduling.
It has 3 main components.
Celery Application(or Client): It is responsible for adding tasks to the queue.
Celery Worker(or Server): It is responsible for executing the tasks given to it.
Broker: It is responsible for transporting messages between client and server.

What You Should Know:

You should know basics of Celery and you should be familiar with
creating celery tasks

from celery import Celery

app = Celery('tasks', backend='amqp',

def add(x, y):
return x + y
adding tasks to a queue,

and consuming tasks with a worker

celery worker -A my_app -l info
If your tasks doesn't need much system resources, you can setup all of them in the same machine. But, if you have a lot of jobs which consume resources, then you need to spread them out in several machines.
In this tutorial lets move our celery workers into a remote machine keeping client and broker in same machine.

Sending Tasks To Another Machine:

On Machine A:
  1. Install Celery & RabbitMQ.
  2. Configure RabbitMQ so that Machine B can connect to it.

# add new user
sudo rabbitmqctl add_user <user> <password>

# add new virtual host
sudo rabbitmqctl add_vhost <vhost_name>

# set permissions for user on vhost
sudo rabbitmqctl set_permissions -p <vhost_name> <user> ".*" ".*" ".*"

# restart rabbit
sudo rabbitmqctl restart
  1. Create a new file remote.py with a simple task. Here we have broker installed in machine A. So give ip address of machine 1 in broker url option.

from celery import Celery

app = Celery('tasks', backend='amqp',

def add(x, y):
return x + y
  1. Now we have everything setup on machine A. We can now put some tasks in queue.

In [1]: from remote import add

In [2]: add.delay(1, 2)
Out[2]: <AsyncResult: 3eb96a11-aa61-46d3-9b9d-e0e1703438d0>

In [3]: b.delay(2, 3)
Out[3]: <AsyncResult: ec40db1a-a43c-4486-9530-0a3153fe1380>

In [4]: b.delay(3, 4)
Out[4]: <AsyncResult: ca53a4c7-061b-408e-82ee-86c2d43d21a0>
Everything is setup on machine A. Now lets get into machine B.
On Machine B:
  1. Install Celery.
  2. Copy remote.py file from machine A to this machine.
  3. Run a worker to consume the tasks

celery worker -l info -A remote
As soon as you launch the worker, you will receive the tasks you queued up and gets executed immediately.

[2014-11-09 00:01:19,168: INFO/MainProcess] Received task: remote.add[c2d2bb27-ff5f-47da-b2b9-6fb11669ee1a]
[2014-11-09 00:01:19,170: INFO/MainProcess] Received task: remote.add[8daa1a5c-17d0-46dc-9c93-faf7fbeccdd9]
[2014-11-09 00:01:19,172: INFO/MainProcess] Received task: remote.add[79603d15-24f1-43f8-b8b7-525b7cd4b9a2]
[2014-11-09 00:01:19,401: INFO/MainProcess] Task remote.add[8daa1a5c-17d0-46dc-9c93-faf7fbeccdd9] succeeded in 0.226168102003s: 3
[2014-11-09 00:01:19,462: INFO/MainProcess] Task remote.add[c2d2bb27-ff5f-47da-b2b9-6fb11669ee1a] succeeded in 0.286503815001s: 5
[2014-11-09 00:01:19,464: INFO/MainProcess] Task remote.add[79603d15-24f1-43f8-b8b7-525b7cd4b9a2] succeeded in 0.288741396998s: 7
This is just a simple guide on how to send tasks to remote machines.
Depending on your need, you might have to set up a cluster of servers and route tasks accordingly to scale.

Pandoc: Best Way To Convert Markdown to reStructuredText!

I wrote a simple readme to one of my Python package Fadapa. I built the package using setuptools. In setup.py file, for long_description field I just read README.md file and  assigned it. After uploading the package to PyPi, I saw the page and found that PyPi doesn't support Markdown format. So I had to change it to reStructuredText.

Pandoc is the best tool available to convert markup formats. It supports a lot of formats and you can convert it to any format you want.

If you have a few documents to convert, you can convert them online. You can also install in in your system if you want to convert a lot files. Instructions on how to install on various operating systems is give here.

For ubuntu you can install by
sudo apt-get install pandoc   
Then you can convert files using
pandoc readme.md --from markdown --to rst -s -o readme.rst
This converts readme.md to readme.rst.

Pypandoc is a simple python wrapper for pandoc. Using that also, you can convert files.

Install it using pip
pip install pypandoc
and then to convert files just do
import pypandoc
output = pypandoc.convert('somefile.md', 'rst')

Update: There is an feature request with pull request to add support for Markdown for PyPi.


Django Tips & Tricks #1 - Useful Shell Aliases For Python/Django Developers

Developers and hackers prefer using terminal and spend a lot of time on it. Instead of typing long commands over and over, they can be aliased to shortnames. The shell builtin alias allows users to set aliases.

One of the most used command while setting up development environment is pip install -r requirements.txt This can be aliased to pir.

alias pir='pip install -r requirements.txt

Now to install requirements, type pir and pressing enter. Here are some other aliases related to python which will be useful on a daily basis.

alias py='python'
alias ipy='ipython'
alias py3='python3'
alias ipy3='ipython3'

alias jn='jupyter notebook'

alias wo='workon'
alias pf='pip freeze | sort'
alias pi='pip install'
alias pun='pip uninstall'

alias dj="python manage.py"
alias drs="python manage.py runserver"
alias drp="python manage.py runserverplus"
alias dsh="python manage.py shell"
alias dsp="python manage.py shell_plus"
alias dsm="python manage.py schemamigration"
alias dm="python manage.py migrate"
alias dmm="python manage.py makemigration"
alias ddd="python manage.py dumpdata"
alias dld="python manage.py loaddata"
alias dt="python manage.py test"

Just add the above aliases to your ~/.bashrc or ~/.zshrc. That's it. Hpy alsng!


How To Add Pypi Pins/Badges To Github Readme Page!

If you are writing a python package or if you have already written one, it would be nice to show PyPi badges on Github Readme page.

PyPi Shields makes it super easy to add pins/shields to your GitHub repo, documentation or website. There are various shields like package downloads, version, egg and wheel distributions and license.

Lets say you want to add your version number to your github page. You can get badge at
If your readme is in markdown format you can add it as

[![Latest Version](https://pypip.in/version/<PYPI_PKG_NAME>/badge.svg)](https://pypi.python.org/pypi/<PYPI_PKG_NAME>/)

or if you are using srt format, you can use this

If your readme is in markdown format you can add it as

.. image:: https://pypip.in/version/<PYPI_PKG_NAME>/badge.svg

    :target: https://pypi.python.org/pypi/<PYPI_PKG_NAME>/

    :alt: Latest Version

In addition to version badges, you get the following badges.

Python Versions: 
Python Implementations: 
Development Status: 

Here is a screenshot of PyPi badges added to one of my Python Package on Github.


A Better Way To Take Screenshots Of Movies With Subtitles!

I take a lot of screenshots(just press SHIFT + S or select Take screenshot from Video drop down menu) when I am watching movies. Few days back I was watching The Matrix and I wanted a take screenshot of this quote.

However the entire quote is present in two different frames. I used to use image editor and join those two images and keep them in my screenshots folder.

Today as I was thinking about a better solution for this. I got this idea of editing subtitles. I opened the subtitles files and edited this part  


01:06:45,251 --> 01:06:47,085

To deny our own impulses...


01:06:47,336 --> 01:06:50,463

... is to deny the very thing

that makes us human. 

and changed to this


01:06:45,251 --> 01:06:47,085

To deny our own impulses is to deny the very thing

that makes us human. 

which made it possible to capture the entire quote in a single frame.

Of course this is not the best method but it is far better than editing and joining couple of images.


I Found A Purse Near Dairy Circle, Bangalore!

I was going to Dairy circle yesterday evening. Near to the bus stop  I  found  a purse. A lot of people were standing and passing by but no one noticed it. I just looked around to see if any one is searching for it. But no one was there. I checked the contents to see if any number or any information is available to call the owner of the purse.

Here are the contents of the purse:

1. Bus ticket from Chennai to Bangalore
2. A shop's visiting card
3. A hundred rupee note
4. An old ten rupee note
5. Some change.
6. 3 photos
7. A SIM card

There was number written on the purse. I tried to call that number but it was not reachable and the SIM card also not working.


How To Install Adobe Digital Editions On Ubuntu 14.04?

Few days back, I rented an e-book from Kinige, a retailer of telugu print & ebooks. I thought I could read that book immediately on their website. But they offered a .acsm & I had to install ADE(Adobe Digital Editions) to read that book. Since ADE is not available for Linux platform, I had to install wine first and then install ADE from it.

1. Installing Wine:

Wine  is a compatibility layer capable of running Windows applications on several POSIX-compliant operating systems, such as Linux, Mac OSX, & BSD. The easiest way to install wine on Ubuntu 14.04 is from its PPA. Open the terminal and run these commands.
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks
You can check if wine is installed correctly by typing  wine --version 

2. Install ADE

Once you installed wine, you can easily install ADE. The current version is ADE 4.0 as of today(Oct 9th 2014). But only ADE 1.7 works on wine. So you have to download ADE 1.7. You can download it from here. Once you have downloaded that, you can just double click and install it just like windows.


తెలుగు సాహిత్యం పైన చలం ప్రభావం! (Influence Of Chalam On Telugu Literature)

చలం వల్ల తెలుగు సాహిత్యం లోను రచయతల్లోను వ్యక్తుల జీవితాల్లోను ఏం మార్పులు జరిగాయో అర్థం చేసుకోవటానికి ఈ ఒక్క పేరా చాలు.

ఈ పేరా రంగనాయకమ్మ  గారి చలం సాహిత్యం నుండి తీసుకోబడింది.