I always wondered how to retrieve file icon associated to file type that too platform independent way, so here it is this simple.
today I tried to push my new repository to bitbucket and i started to get prompt for password every time I pushed, I wonder what happened, So I googled and found I should use ssh instead of using https to avoid getting password prompt, specially when I am on my personal computer. I checked in my bitbucket account and found that their is no ssh key saved, but I am pretty sure that I did set it up in past, and I do have repos hosted on bitbucket account and I was pushing it all this time and what happened now. Anyway So i went setup again, first I didn't realised i was standing in my local repo folder so I generated ssh key while I was in bash shell. didn't realised the private and public key got saved their I started looking up in ~/.ssh folder.
Now this was one mistake I made, then if you look on altasian website or even may other support they are referring to id_rsa for me it didn't existed, not at ~/.ssh location. So I went to my local repo and tried to push thinking i have copied my ssh key from known_hosts but that moment i got to know about two files
on attempting to generate ssh-key:
$ ssh-keygen -t rsa
you will get:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/userName/.ssh/id_rsa):
earlier at this moment I entered bitbucket, since I was generating it for but bucket account which got saved in my local repo folder instead of ~/.ssh folder. and it generated two files by the name bitbucket and bitbucket.pub i.e private and public key respectively.
I went to ~/.ssh folder again and entered
$ ssh-keygen -t rsa
but this time I neither entered the name nor entered paraphrase, then copied using cat ~/.ssh/id_rsa.pub | pbcopy and pasted it to my bitbucket account > sshKeys
wrote a tiny utility using python to notify file downloaded to downloads folder using QFileSystemWatcher from PyQt4.
wrote it while watching tv, forgive me if I missed something but I have tested on my OSx let me know if something doesn't work for you.
I read PDF books on my tab, and I tend to pick up the one that has not many pages though this is not always the case.
Sometimes I do pick up what interest me, however few months back I wrote a python script to get total number of pages of all the pdf ebooks I have in folder.
Today I was stumbling across web pages and some how I reachedSO API page. There are plenty of ways to do all sorts of things, but I quickly got all the tags I am subscribed to using the Json data they return.
Before I go over getting rid of pyc files I think it would be fair to go over when pyc are created ! The .pyc files are created (and possibly overwritten) only when that python file is imported by some other script. If the import is called, Python checks to see if the .pyc file's internal time stamp matches the corresponding .py file. If it does, it loads the .pyc; if it does not or if the .pyc does not yet exist, Python compiles the .py file into a .pyc and loads it.
Although it always helps to have pyc files since CPython compiles its source code into "byte code", and for performance reasons, it caches this byte code on the file system whenever the source file has changes. This makes loading of Python modules much faster because the compilation phase can be bypassed. When your source file is foo.py , CPython caches the byte code in a foo.pyc file right next to the source. From PEP-3147
If your source changes; CPython will recompile and re-cached the bytecode.
But sometimes you would still don't want to have a pyc or a file ending with ~
to avoid that I came up with an shell command or alternatively a python script to get rid of pyc or files ending with '~' tilde .
Find files ending with pyc or ~
below code will find and delete the files as well.
click read more for a little romance with python :p
I have been long trying to get this thing figure out how to fetch a url while sitting behind proxy. I took a bit of help from SO, now I got it figured how it works using python that too with authentication. Here is basic sample code.
getattr is a python built-in function taking (at least) two arguments: the object from which you're getting the attribute, and the string name of the attribute.
If the string name is a constant, say 'foo', getattr(obj, 'foo') is exactly the same thing as obj.foo.
So, the main use case for the built-in function getattr is when you don't have the attribute name as a constant, but rather as a variable. A second important use case is when you pass it three arguments, rather than just two: in that case, if the attribute is absent from the object, getattrreturns the third, "default", argument, rather than raising an exception.
__getattr__ is a special method, defined in a class, that gets invoked when some attribute of an instance of that class is requested, and other normal ways to supply that attribute (via the instance's __dict__, slots, properties, and so on) all failed. You can define it, for example, when you want to delegate otherwise-undefined attribute lookups to other objects.
So your second example is wrong because the builtin getattr can never be called with a single argument.
Using the above model, we can get the attribute by supplying the attribute_name. This works when we give a name as a string and you need to look up the instance attribute referenced by that name.
Use of __getattr__
You can also tell a class how to deal with attributes which it doesn't explicitly manage and do that via __getattr__ method.
Python will call this method whenever you request an attribute that hasn't already been defined. So you can define what to do with it.
Caveats and use of __getattribute__
If you need to catch every attribute regardless whether it exists or not, use __getattribute__ instead.
Difference__getattr__ only gets called for attributes that don't actually exist. If you set the attribute directly, referencing that attribute will retrieve it without calling __getattr__.
__getattribute__ is called all the times.
A key difference between __getattr__ and __getattribute__ is that __getattr__ is only invoked if the attribute wasn't found the usual ways. It's good for implementing a fallback for missing attributes, and is probably the one of two you want.
more bits and pieces : http://www.devx.com/opensource/Article/31482/0/page/4
Today I came across an article on linked in Pulse by Ted Eagly on how to live always learning. i.e. Remaining Teachable: The Never-Ending Path To Wisdom.
He points in the beginning what Leo Tolstoy said
"The most difficult subjects can be explained to the most slow-witted man if he has not formed any idea of them already; but the simplest thing cannot be made clear to the most intelligent man if he is firmly persuaded that he knows already.”
I didn't knew somebody wise has already made statement that is exactly what I have been thinking about. No doubt I am now losing extra wisdom tooth.
I used to and on many occasion still come across people who say "I know" but when they say that they are not careful enough what that might lead to when they say "I know". It is good to know and knowing is everything, but listening to others is also equally important. With the attitude to not listen or ignore with over confidence or persuade on a belief that you know it right and better than the other person will shun your ability to judge and make better decision. If a person chooses not to listen and continues to flap his wings of his righteousness would ultimately become outdated of what is right (for himself or for his fellows).
Ignorance is not bliss, Always be open to listen to others.
I used to call this thoughts eclipsing thinking, because such an attitude limits your thinking, devouring the person from the path of progress or may totally lead to misery.
I would want to be fierce and point what type of people and what people say when their thoughts eclipse thinking.
The first category of people are the one I want to point are those who are young learners with little experience but when they get an exposure and opportunity to sit among the smart and wise people, they develop the attitude of being masters of knowledge beholder, a bit of arrogance kicks in. We usually refer to these people smart ass in urban language.
The second one are those who are really smart and keeps good knowledge, they know but knowing shouldn't limits listening to others. And in a self setup of thoughts ignoring that the world around is evolving and with the change in information, knowledge requires updating. Those in this category are also on the fall of devouring themselves from the latest knowledge of the ever evolving world around and keeps the attitude but lesser than the first category. I really respect these people, since they are smart and I try to handle the conversation and get along with a delicacy.
The third category is of those people actually knows nothing but likes to speak a lot, these are the stupid liars who are fooling around the management or being outspoken and heard by everyone. Their tendency is just to prove themselves that the know everything but the truth is the either keep half knowledge of what they do or they don't know anything at all. I tend to stay away from these people and don't be friend be with them. (these are not the one what Leo Tolstoy or Ted Eagly was referring to.)
The fourth category of people are the one who are on high profile job designation, these people are more equipped with arrogance than attitude. But as I have noticed this fourth category is easier to be fooled by those people in third category. The only reason why their thinking is limited is their tendency that they know better ignoring the fact that the person they do not want to listen to may have right or new knowledge or information that could be useful.
Thanks for reading, if this was such a torture please don't hesitate swearing in the comment box below, I am also not very experienced in writing but I only write with what I have lived and experienced .
awakened by thoughts,