Tuesday, 7 April 2015

Writing Your First Python Library

 

 #Can I do it?

YES you can, anybody can as i matter of fact I did, all you need is to be determined and must have zeal to do it. In beginning you might get this idea that these libraries are written by top-notch-geeky-nerdy developers, but you are wrong, most of the libraries are written and maintained by general enthusiasts like us. 


#How to do it?

1. Go to your project folder, create a folder namely <project_name>.

2. In the <project_name> folder, create another folder namely <Package_name>
    In <Package_name>, code your program <program.py>

3. Create a __init__.py file. Have a look. Save your program as __init__.py

             from <program.py> import <function_names>
             __all__ = [<function_name>, ]

4. Your FileSystem should look like:
                 
                 <Project_Name>
                         |
                  <Package_Name>
                         |
                         |________________________
                         |                                      |
              <program.py>                     __init__.py

5. In <Package_Name> you only needs 2 files <program.py> and __init__.py

6. Now, you need to write setup.py, README and MANIFEST.INI . Starting   from setup.py. setup.py=> A py file that contains the metadeta of your package.
Example : 

       #!/usr/bin/python2.7

       """GitGui Project"""

      __version__ =  '1.1.1'

     from setuptools import find_packages, setup

    setup(name = 'GitGui',
    package = ['GitGui'],
    version = '0.8',
    descripiton = 'A test module:GitGui',
    Summary = 'A test module : GitGui',
    long_description = 'A module for pushing a file to your github repo',
    platforms = ["Linux"],
    author = "Rahul Mishra",
    author_email = "priyrahulmishra@gmail.com",
    url= "https://github.com/Rahul91/GitGui/",
    download_url = "https://github.com/Rahul91/GitGui/tree/master/tarball/",
    license = "MIT",
    keywords = ['Git', 'Github', 'Python', 'GUI'],
    packages = find_packages()
    )


MANIFEST.INI => A file to instruct all files you need in your tarball (compressed file) zipped format.
     example: 
             include *.py
             include README

NOTE: You can also exclude any file explicitly using exclude <filename>.


README=> A file for introduction, like a manual for your package, highlighting its installation, usage and features.


6. Your tree of files should like like this.

                  <Project_Name>
                         |____________________________________________________________
                         |                               |                             |                                 |
                 <Package_Name>    README          MANIFEST.INI            setup.py   
                         |
                         |
                         |________________________
                         |                                      |
              <program.py>                     __init__.py


7. For creating a tarball, execute the command
            python setup.py sdist

8. Now we are ready to go live. 
   i. Create your account here: https://testpypi.python.org/pypi?%3Aaction=register_form

   ii. Now create a .pypirc.py file in your home folder, like given below.
                     [distutils]
                     index-servers =
                      pypi

                      [pypi]
                      repository: https://testpypi.python.org/pypi
                      username: <username>
                      password: <password>

Replace <usrname> and <password> with what you have created your account.

    iii. Register your project on PYPI.
         $ python setup.py register -r https://testpypi.python.org/pypi

     iv. Upload and you are done.
         $ python setup.py sdist upload -r https://testpypi.python.org/pypi


Now that you have uploaded it to server, it is ready for everyone, they can download, install and play around the code.

Hope this blog helps anyone who needs.

Cheers.
Happy Coding.




Wednesday, 16 July 2014

Working with Mercurial

 

What is Mercurial

Mercurial is a Version Control System, just like Git with few changes, Mercurial is a Open Source Software, written in Python, unlike Git which is written in perl and C and was developed by Linus Torvalds. Although Git and Mercurial are almost same in there nature, different people have different preferences.
 According to Wikipedia, Mercurial is a cross-platform, distributed revision control tool for software developers. Mercurial's major design goals include high performance and scalability, decentralized, fully distributed collaborative development, robust handling of both plain text and binary files, and advanced branching and merging capabilities, while remaining conceptually simple.It includes an integrated web interface. Mercurial has also taken steps to ease the transition for SVN users.

Getting started with Mercurial

  • You can download and install Mercurial using
                      sudo apt-get install mercurial (for Ubuntu/debian)
                      yum install mercurial (for Fedora)

  • You have to create a .hgrc file in your home directory, as  "." in hgrc suggest that it is a hidden file, it is a configuration file and must be stored in home directory. Following is an example of .hgrc  file.

                       
[ui]
username = Rahul Mishra <rahulmishra@gmail.com>

[extensions]
purge =
strip =
color =
pager =
progress =
rebase =

[pager]
pager = LESS='FSRX' less
attend = tags, help, annotate, cat, diff, export, status,\
         outgoing, incoming, glog, log, grep




Using Mercirial

  • After setting up the .hgrc file we are ready to go, we can make a directory, mkdir dir_name then cd dir_name.
  •  Then we can create a file say vim Test.txt and we can write in it  and finally save and exit.
  • For intailizing Mercurial we have to give command hg init, just like git init, this command will initialize this directory as Mercurail repo.
  • hg init will add a hidden file .hg in this directory,also we have to add our file Test.txt to the empty repo by using command hg add Test.txt.
  • Next we have to commit the file, using hg commit <file_name>, this will open an editor, it is nano as default, you can also change with  select-editor command. Writing a good and precise and meaning full is very important, also give a space between the heading and the details.
  • A patch file is generated in the same way, now if we change our Test.txt and do a hg diff, we can see the difference made in the file. hg diff works only when you have not committed the changes, because once you have committed the changes the buffer are overridden and hg diff will not produce any output.
  • hg log gives the changes made in every commit and also gives the heading of the commit message. 
  •   hg status will give the currnt status of the files as Modified or  Added.     

Monday, 7 July 2014

         The dgplug Summer Training is back '14


The #dgplug Summer Training is back again this year, started this week, it had more then 150 members in the initial days. This Summer training is however different from any other training, conducted on IRC(Internet Relay Chat) and surely one of a kind, the summer training aims mainly on python and FOSS(Free and Open Source Software) and Real-world project experience.



This training is conducted on freenode network and #dgplug channel, can be accessed by any IRC client, chatzilla and Xchat being the most famous ones. I personally use chatzilla as IRC Client. Typically the students are from Durgapur and Kolkata, however there are many students from different parts of India as well as abroad. The class usually starts at 18:30 IST and mainly conducted by Kushal Das (nick- kushal) CPython Developer and works in Redhat, Pune, India. Also others moderators are Sayan Choudhary(nick - sayan), Ratan Debnath (rtnpro), Chandan Kumar and Eijah.


Highlight of this summer training being interactions with the develpores, talks given by various Up stream Developers and online communcations atticates. This is my second year in this Training, last year i could not complete it because of Placement and studies issues, this year i have another problem, its the damn job training starting next month, although i will try my level best to continue my classes.

The only problem that the class have (according to me) is that the no. of students participating decrease day by day, and only 10-20 students complete there training fully, may be this is because not everybody can grasp to the new things they are learning also the pace the class goes with presents a little problem but the main problem being the students itself, they grows the tendency of not asking question and gradually the lose there interest too, else everything related with this training is just awesome.

Friday, 18 April 2014

 UNDERSTANDING GITHUB



To understand GitHub, you must first have an understanding of Git. Git is an open-source version control system that was started by Linus Trovalds – the same person who created Linux. Git is similar to other version control systems – Subversion, CVS, and Mercurial to name a few.

Git in Github

So, Git is a “version control system,” what’s that mean? When developers are creating something (an application, for example), they are making constant changes to the code and releasing new versions, up to and after the first official (non-beta) release.

Version control systems keep these revisions straight, and store the modifications in a central repository. This allows developers to easily collaborate, as they can download a new version of the software, make changes, and upload the newest revision. Every developer can see these new changes, download them, and contribute.

Similarly, people who have nothing to do with the development of a project can still download the files and use them. Most Linux users should be familiar with this process, as using Git, Subversion, or some other similar method is pretty common for downloading needed files, especially in preparation for compiling a program from source code (a rather common practice for Linux geeks).

Hub in GitHub


We’ve established that Git is a version control system, similar but better than the many alternatives available. So, what makes GitHub so special? Git is a command-line tool, but the center around which all things involving Git revolve – effectively, the Hub, is GitHub.com, where developers can store their projects and network with likeminded people.


Technical Terms

Repository
A repository is a location where all the files for a particular project are stored, usually abbreviated to “repo.” Each project will have its own repo, and can be accessed by a unique URL.

Forking a repo

“Forking” is when you create a new project based off of another project that already exists. This is an amazing feature that vastly encourages the further development of programs and other projects. If you find a project on GitHub that you’d like to contribute to, you can fork the repo, make the changes you’d like, and release the revised project as a new repo. If the original repository that you forked to create your new project gets updated, you can easily add those updates to your current fork.

Pull requests

You fork a repository, make a great revision to the project, and want it to be recognized by the original developers, maybe even included in the official project/repository. You can do so by creating a pull request, so the authors of the original repository can see your work, and then choose whether or not to accept it into the official project. Whenever you issue a pull request, GitHub provides a perfect medium for you and the project’s maintainer to communicate.

 And the best part: GitHub isn’t just for developers

All this talk about how GitHub is ideal for programmers may have you believing that they are the only ones who will find it useful. Although it’s a lot less common, GitHub can actually be used for any types of files – so if you have a team that is constantly making changes to a word document, you can actually use GitHub as your version control system.  This practice isn’t common as there are better alternatives, but keep it in mind.

Friday, 21 March 2014

GSoC 2014



Ah!, finally GSoC Registration time for students are coming to an end. And hopes and  dreams of thousands of students, are on stake as working for some big orgs can come true in real life. But getting a proposal approved by the mentoring organisations is not a easy task, especially if you are working with big orgs, like Gnome, gnu, wikimedia, the Linux foundation etc. First you have to start by fixing a bug, which is not a easy task, believe me, i have gone through this stage, the pressure is enormous, and also you have to do in a fix limited span of time. After that there comes the big task of writing a proposal, which is again not a easy task, different orgs have there different template designed, so that they can easily evaluate the proposals, as working for wikimedia, i got a simple template and then you just have to get started.

Most of the ideas proposed are from the idea-page of that org, but you just cant copy the whole stuff and paste in your proposal, you have to be specific about your idea and how you are willing to execute what ever is your idea, with proper timeline and phases.


I may not get the chance for working as intern in GSoC, this year, as they can only choose one candidate, and they make sure, that only the best gets it, having said that, one should not lose there hope, and should continue to contribute, because thats the main agenda of GSoC. i.e. more and more student contribute to Open Source. And i will continue to do so.
 
Also in midst of all these, proper communication is also very important, you have to on IRC, mailing-list, and in regular contact with mentors and admins. Even all these things does not guarantees the approval of your proposal, so the cool thing would be to relax, just try to give your best, be in contact with your mentors and try to improve your final proposal.



Friday, 23 August 2013

Understanding Linux



What is Linux?

Linux, first of all is an Operating Systems..!!!
Operating Systems - Now whats an Operating System, Lets solve this riddle

An operating system (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs. 

And now whats KERNEL. Kernel is heart of an OS, it manages resources, now whats an resource?? Are we going off topic!!! Okay lets be back on our topic.
Lets be back to Linux.

History

Linux is a Unix-Like OS. The History of Linux began in 1991 with the commencement of a personal project by a Finnish student, Linus Torvalds, to create a new free operating system kernel. Since then, the resulting Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to its state in 2009 of over 370 MB
of source under the GNU General Public License.


Features of Linux

Free

Linux is free.  :)
First ,It's available free of cost (You don't have to pay to use this OS, other OSes like MS-Windows or Commercial version of Unix may cost you money) 
Second free means freedom to use Linux, i.e. when you get Linux you will also get source code of Linux, so you can modify OS (Yes OS! Linux OS!!) according to your taste. 
It also offers many Free Software applications, programming languages, and development tools etc. Most of the Program/Software/OS are under GNU General Public License

Unix Like 

Then Ken Thompson (System programmer of Bell Labs) thinks he could do better (In 1991, Linus Torvalds felt he could do better than Minix - History repeats itself.). So Ken Thompson wrote OS on PDP - 7 Computer, assembler and few utilities, this is know as Unix (1969). But this version of Unix is not portable. Then Unix was rewrote in C. Because Unix written in 'C', it is portable. It means Unix can run on verity of Hardware platform (1970-71). 
So Unix is Multi-user, Multitasking, Internet-aware Network OS.  Linux almost had same Unix Like feature for e.g.
  • Like Unix, Linux is also written is C.
  • Like Unix, Linux is also the Multi-user/Multitasking/32 or 64 bit Network OS.
  • Like Unix, Linux is rich in Development/Programming environment.
  • Like Unix, Linux runs on different hardware platform.

Open Source 

Linux is developed under the GNU Public License. This is sometimes referred to as a "copyleft", to distinguish it from a copyright.
Under GPL the source code is available to anyone who wants it, and can be freely modified, developed, and so forth. There are only a few restrictions on the use of the code. If you make changes to the programs , you have to make those changes available to everyone. This basically means you can't take the Linux source code, make a few changes, and then sell your modified version without making the source code available.


Why Linux?

Hmm.. A skeptic, good.. Well, First of all its FREE and you have got this amazing oppurtunity to modify, customize and change the source code which is available to all, unlike Windows where everything is hidden and all..

Secondly, there is this really cool community of Linux users always for your help, kinda missing from Windows platform.

Its a whole new world when you start or when you switch to Linux form boring BLUE GAINTS.


Where Linux can be used

Anywhere, literally anywhere be it be your old pc, new laptop, tablet or even mobile phones. It is there, specifically speaking these are where Linux can be used.
  • Personal Work
  • Web Server
  • Software Development Workstation
  • Workgroup Server
  • In Data Center for various server activities such as FTP, Telnet, SSH, Web, Mail, Proxy, Proxy Cache Appliance etc.

Conclusion


So start using one. Latest version of Linux Ubuntu is 13.04, easily available everywhere to download go to www.ubuntu.com/download


 

Cheers!!!



 











Monday, 19 August 2013

Bleeding Rupee ,Diseased Economy.

Since July last year, the Indian rupee has fallen by more than 27% against the US dollar, one of the biggest declines among Asian currencies.

Understanding Money

Money is the value assigned to a commodity, a piece of paper, a coin or electronic data. It can be of different types-commodity money, representative money, fiat money and commercial bank money. Gold coins, cocoa beans, cattle or anything that has a value of its own and is used as a medium of exchange is commodity money. The use of commodity money is similar to barter, except that the commodity used is widely accepted 
and can be easily handled.


The value of a currency is its purchasing power – that is, what you can get for a unit of the currency in terms of goods and services. In today’s context when it is said that a currency is declining or being devalued, it is with respect to other currencies.

 Free Fall

According to BBC, this falling of Indian currency with respect to USD is mainly due to some reasons. They being.

  • HUGE TRADE DEFICIT

  • LOWER CAPITAL INFLOWS

  • HIGH CURRENT ACCOUNT DEFICIT

  • DEVALUATION PRESSURE

  • LOW GROWTH AND HIGH INFLATION

  • RUPEE SPECULATION

     

    What can be done?

    # We should stop or decrease our imports mainly oil and improve exports.  Currently oil import companies are making large purchases for which large amount of Dollar is required Nations like The united states such as Indian have arranged their oil sources and mostly transfer.

     # Now Govt of India has to be interested in enhancing manufacturing.  More discounts and rewards by means of tax refund or motivation for less publishing organizations to be announced, so that natural manufacturing will improve and there by transfer of such product will get decreased and unwanted manufacturing may be released. 

    # Traditional clear policy decision is needed.  The marketers,  traders will come forward to get and single window venture approval should be applied with firm guidelines.

     # RBI also prohibited financial institutions from dealing in rupee forex futures dealing and choices, except on part of their customers.

     

    May god be with us.

    THANKYOU.