Tuesday, 31 March 2015

How to remove a package in ubuntu when you don't know its name ?

So I had this ubuntu alarm clock app installed, which I wanted to remove, but I couldn't find its package name.




So here is the command to figure out the package name of an installed app 

dpkg --get-selections | grep 




And woot, I've found it. Now lets get rid of it.

sudo apt-get purge alarm-clock-applet


Ideas and Memory tradeoff


I have a hypothesis that there exists a tradeoff in the mind between the tendency to think big,bright ideas and being able to recall them later.

Explaining this further, the brighter and more revolutionary the idea you just thought of, the lesser are the chances that you will be able to recall it by the time you decide to work on it.

But with maturity and practice, this tradeoff must fade off, that's why people who are in the profession of implementing ideas liek artists, writers, musicians produce the best work of their lives after much much practice.

To cite a famous example, Douglas Adams, once was presumably high and was having a lunch conversation with his friend, during this conversation, Adams told him three ideas, one of them was the book “The Hitchhiker’s guide to the galaxy”. 
They realised the importance of these ideas and knew instantly that they were profound.


When they met later, they forgot the two ideas except for the "Hitchhiker's guide to the galaxy" one.
None of them was able to figure out, what the rest of the ideas were, except for the fact that they were equally revolutionary.




Now imagine what the other two ideas might have been.

Source : A documentary titled "Life, Universe and Doughlas Adams" https://www.youtube.com/watch?v=OHJLNrDzYm0

On Observation


When an astronomer looks up in his little telescope and locates a galaxy amidst the white dust, he wonders whether this galaxy existed before he decided to observe it.

A tree falls in the forest far away, away from any human or mammal, does it make noise, even when there is no one to hear it ?


Well no, it doesn't make any noise, because noise is the result of vibrations in the air coming in contact with eardrums in mammals, so for there to be noise, there must be someone to observe it.


So just like a tree falling in a forest far far away doesn’t make any noise similarly does things that no one observe, like some very distant, very faintly visible galaxy, does they exist ?

Space and Time

Space and Time

This post is a transcription of Alan Watts philosophy along with some gems from the armchair philosopher in me.

The perception of space and time we have today is very limited (I am specifically talking of layman here, physicists and philosophers and other learned men do indeed have a better view).

We view time as a linear function and space as finite, discrete and omnipresent.

What Alan Watts says is that, this is just one way of looking at things, and no one way is right. But sometimes we must be exposed with other point of views to really get an idea of “what’s going on”.

Lets talk about space first, If I ask you to describe “the sun” for me, you would go about it like, its a sphere of so and so diameter, and so and so location.

Here we are using matter as distinction between the space where sun ends and emptiness begins.

But we also know that there is significant equivalence between matter and waves, so if I were to use EM waves instead of matter in defining the boundary points of the sun, I would still be technically correct.

But by that definition, we are inside the sun, in fact all the portion that the first rays of sun has reached is all inside the sun.

So you see, its all a matter of definition, how we define  things is how we end up looking at them.


Now lets talk about time,


...continued

Chicken and Egg


This post is a transcription of one of Alan Watts philosophy.(the idea might date way back to the medival ages, but I heard it first in one of Alan Watts lectures.)

Everything is reproduction, every event, in one way or another.

An egg is a chicken’s way of becoming another chicken.

A planet is a star’s way of becoming another star.

And intelligence is a disease, that makes that planet into a star.

And in a way, life is a planet's way of becoming a star. 
Explaination : Life evolves into higher forms of intelligence, they find about nuclear fission and fusion, and end up blowing the planet to pieces, starring it up ?

And just like during mammal reproduction, of all the sperm cells, only one or two succeeds in making an egg, similarly out of all the planets that might be part of a star’s solar system, only one or two would sustain life, the life enables one of the species in attaining complete control over that planet, and then that species finally learns how to blow up the planet to pieces, and then its only a matter of time.


I would like to go further and say that, this analogy of reproduction can be used to explain almost all of the significant events.

An execution in an Idea’s way of becoming another idea.

and finally conclude by saying,


Death is one Life’s way of becoming another life.


I need to drink some coffee to get hold of these dense ideas.

Sunday, 29 March 2015

Difference between __str__ and __repr__ in python

Here is what the doc says
Called by the repr() built-in function and by string conversions (reverse quotes) to compute the "official" string representation of an object. If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment).
Called by the str() built-in function and by the print statement to compute the "informal" string representation of an object.

 Now lets take an example,

>>> from decimal import Decimal
>>> a = Decimal(1.25)
>>> print(a)
1.25                  <---- span=""> this is from __str__
>>> a
Decimal('1.25')       <---- span=""> this is from __repr__
The __str__ is intended to be as human-readable as possible, whereas the __repr__ should aim to be something that could be used to recreate the object, although it often won't be exactly how it was created, as in this case.
It's also not unusual for both __str__ and __repr__ to return the same value (certainly for built-in types).


from . import stuff in python

I came across this piece of code in a Django App

    from . import views

The dot is used to specify explicit relative imports, which tells the python interpreter to import views from the current pacage.

This change was added in PEP-0328.

You can also use more than one dot to more deeper into the package heirarchy, for instance

package/
    __init__.py
    subpackage1/
        __init__.py
        moduleX.py
        moduleY.py
    subpackage2/
        __init__.py
        moduleZ.py
    moduleA.py
Assuming that the current file is either moduleX.py or subpackage1/__init__.py , following are correct usages of this syntax:

from .moduleY import spam
from .moduleY import spam as ham
from . import moduleY
from ..subpackage1 import moduleY
from ..subpackage2.moduleZ import eggs
from ..moduleA import foo
from ...package import bar
from ...sys import path