17 August 2013

How to write PEP8 compliant Python code on Vim

I've made this code two years ago when I wrote code for one of the popular open cloud program. This is not a standard plugin code for vim, If you have not made any configurations, you can simply follow the instructions here and download this code. This is for Ubuntu and Debian only.
I've made this seeing two links, which I don't remember right now. Sorry about that.

Please download this code (https://app.box.com/s/plc7xwm49avp4ubzq915) and follow these instructions

This is tutorial is for people who are already little known to vi editor. This is  done for vim 7.2
vim for terminal

The vimrc is so set that it would not let  write code beyond 80 lines and would automatically break. using   will
throw all the pep8 errors

Installation
-------------
Install vim7.2
Ubuntu: sudo apt-get install pep8
Ubuntu : sudo apt-get install vim
Ubuntu : sudo apt-get install vim-common (you may not need this step on all Ubuntu's)
Ubuntu : sudo apt-get install vim-runtime (you may not need this step on all Ubuntu's)
Ubuntu : sudo apt-get install vim-tiny (you may not need this step on all Ubuntu's)
copy the .vimrc from the folder to your  /home/yourusername/.vimrc
copy the folder .vim to  /home/yourusername/.vim

Checking PEP8 Complaint
-----------------------

vi somefile.py

:retab - This removes all the whitespaces mixed with tabs

Run F5

toggle between the windows using Ctrl + W twice

Toggling through a python function defintion
--------------------------------------------

Install  ctags or exuberant ctags

Ubuntu:

sudo apt-get install exuberant-ctags
rm .vim/tags/python.ctags
touch  .vim/tags/python.ctags
ctags -R -f ~/.vim/tags/python.ctags /usr/lib/your_python_library/  /home/youruser/any-python-project1/ /home/youruser/any-python-project2/ .. so on

Browsing the source code of the file
-------------------------------------
Open vi anyfile.py

in ex-mode

:helptags .

Run F3


Command in Ex-mode  - Functionality

F5 -  would run pep8 command would show list of pep8 errors (this happens only on all .py files)

CTRL + ] - would take the library function definition

CTRL + T
or - Would get back to the original file
:rew

:%s/^\s\+  - To remove  unwanted whitespaces at the beggining of lines

:retab - to remove all unwanted mix of whitespaces with tab

Note:

:w -  A simple save will automatically remove all trailing whitespaces

29 March 2013

Question: Mac grep to exclude directories

I'm tired of searching for this exclude directories apparently running grep -ir --exclude-dir=.svn  'needle' . on Mac OS X snow leopard . The --exclude-dir for grep does not work on Mac. Also I don't want to run any piped greps like  "grep -nHR 'needle' . | grep -v svn" as I'm searching in a 30GB source code as it consumes too many hours.

21 July 2011

Shades - I

Cricket, after all the only so much famous game that Indians play at international level with little professionalism and to a certain quality. Oh did some politicians see this an opportunity to cash...! Oh How...! Keep the cricket going, as the most read news in the country cricket than politics...! Let me show you right now a common scenario...!

Minister X with Magical power shows an illusion of two people of what is presently going at a certain place between two colleagues.. can be termed as common man...! Minister Y watches curiously the Illusion

Common Man A: Did someone rob money from the telecom account..
Common Man B: Yeah...! It happens yar...! After all why are they in Power. Hey Sachin scored century...!Wow...! Did you see how hit the last ball...!

Common Man A: Hey, I heard even our Home minister was there in the scandal..!
Common Man B: Hey Sachin man.. What a 6...!Awesome..! Great shot..! What even he was there...!
Common Man A: Yeah..! What..!
Common Man B: I don't understand politics man..! I'm getting late, need to play cricket with my son...!
Common Man A: Oh...! You are aspiring him to become a Cricket Player...!
Common Man B: No Man...! That is what he enjoys too...! Cricket man...! My Passion, unfortunately in this software...!
Common Man A: ( ....!), By the way you heard of Anna Hazare movement...!
Common Man B: it will stop in few days and everything will be Normal, We go to office, talk and we get back to work..! Do few shares, people loose interest after the movement, and thats it life back to normal..! Need to go home man...!
Common Man A: Sighs..! Bye ...!
Common Man B: (picks up cellphone)...! Hey Ramesh..! Did you the last ball that Sachin hit..! What a winning shot man...!.... (.....fades!)

12 November 2007

USBWORM

Do you have any problems on your computer saying "I Dont hate mozilla" or you cannot open hidden files inspite of enabling Tools->FolderOptions->View->Show all hidden files and folders. Then you have a solution here that could be useful.

10 January 2007

Bangalore's Horrible traffic


Ghhhhrrrrrrrrrrrrrrrrr..... Bangalore's Horrible traffic really irritates...

30 December 2006

Coding on Open Source Products

Well, I've been working on LAMP(Linux, Apache, MySQL and PHP) for past three plus years. I thought I should write a technology blog, and chose PHP technology with which I work.

The two Open sources that I started working have enhanced my coding skills. First one being dotproject, The second one being wordpress. Most well known opensource products for Project Management and Blogging tools respectively.

Though these two are indifferent products they use same technology in PHP Both use PHP as the language.MySQL being the common database for most of opensource products. The other two being OS and Webserver whom generally being Linux and Apache.

Unlike the commercial products ,these products surpass them in their reusing the code(OOPS in PHP), PHP-coding perspective,PHP -designing perspective,PHP-security and building the product. Gives a very good start for those who starters coding on a product with PHP as their technology. The method of designing, coding, reusing is something to be learnt from them.

Dotproject uses MVC(Model View Contoller)design pattern while wordpress uses singleton pattern. Apart from designing usage of some other utility softwares in these products like ,ez2pdf, ADOdb, PEAR libraries etc gives more deep insight of how to use a third party tools.

04 December 2006

Great, One can earn through blog

Well Google Adsense Idea on blog is great,
But exactly the day I subscribed to google Adsense, my hoster made my site down because of some technical reasons... Not on bloggers until I succeed building it.
Kool, Ill also post some of the important stuff like news which Im fond off. Also technology related news which Im crazy about.. well I started writing again long essays.
Ill stop
Google