Today I wrote a quick script to move collection of movies I have downloaded over period of time, my macbook was getting filled, and my external drives I have them connected to TV were lying untouched, so I plugged in drives to my laptop and moved stuff in year based organised order, I did not read year from the file metadata, since I downloaded movies from internet mostly contains year in the name which was very helpful to put them into right year folder, but I really wished if these movie files have metadata. Here is the script you can use to organise, if you do not want to move and just organise within the same folder just make sure _from and to location are same. In that case it will organise movies based on year of release in the same folder.
It has dependency on my own package pySan, you can grab it from PyPi and keep following this post I will update in near future to update based on genre, resolution , and rating using data from IMDb.
So today I was waiting for a massive file download to finish, and start new file download, since I have fast speed internet I do not really used any download manager, just click on URL and download the file. And while waiting I wrote this script that gives me file size before having to download any file or a page of the URL in clipboard.
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.
awakened by thoughts,