Posts

Difference between Python classmethod and staticmethod with a better use case.

Personally, in python I believe, classmethod's and staticmethod's are about the use in terms of the case. When it comes to classmethod and instance method, the point is about you are maintaining a state (variables) to be processed. Couple of days back, I was working on the payment gateway implementation and have come across this best way to understand how to know what is good for the situation. Let's say we have three class, BasePaymentGateway FirstPaymentGateway SecondaryPaymentGateway Now, the BasePaymentGateway provides all the signature which the other payment gateways can follow. Considering the fact that each payment gateways will have their own settings and hence we need to fetch the settings from their respective item. # paymentgateway.py import settings import some_util class BasePaymentGateway(object): @staticmethod def get_payment_settings(): """Provides the settings for the given item""" ...

Setting up CRON via a python script without using external library

What is the best tool in computer that can do your job automatically and is something which otherwise, if not there would involve manual intervention? Life around computer is increasingly getting more complex with our lifestyle demanding more of automated work. Out of philosphy let's face it, we need tools that we can set up for doing tasks for us, run scripts for us whenever we want. When it comes to schedulers, it's like an alarm clock or a timer which goes of for whatever time we set it and then ensure we do our tasks. Now, in the world of Linux, we know this schedulers at system level as Cron. Cron is a system daemon which is used to execute desrired tasks (in the background) at specific designated time. It is used to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration Now, thinking of cron, it's a name we use, when we have to schedule a task. Now, I am ...

NGinx + Gunicorn + Flask-SocketIO based deployment.

It's been a long time I wrote a blog post!. Recently I realized I should at least write about my unwarranted account of solving problems which were hard, to just get some information online. So this post provides the details we need to know how to deploy the Flask-SocketIO app using Gunicorn and NGinx. Here are the links for NGinx , it is a web server with a focus on high concurrency, performance and low memory usage. Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX and Flask-SocketIO  gives Flask applications access to low latency bi-directional communications between the clients and the server. The client-side application can use the SocketIO Javascript library or any compatible client to establish a permanent connection to the server.  Version's I used: Nginx : 1.6.0 (Websocket support in Nginx was introduced in version 1.4 and above) Gunicorn : 17.5 Flask-SocketIO : 0.6.0 If you go through the document's of the tools, you will com...

Dijkstra's algorithm in OpenGL - Network simulation

Image
I and my friend late Mr. Padmaprasad Kusagundi (will always miss him), had created an OpenGL project for the syllabus in our college, G.I.T, college, Belgaum, Karnataka, India. We had worked day and night over this. The github repo is here:  https://github.com/tan31989/Dijkstra-opengl-network-simulation This project has used basic programming elements of OpenGL. Here we used   Dijkstra's algorithm  and modified it to any source to any destination (as opposed to single source and all the destination). The nodes of which looks like a box in here are hard coded as, we never had a chance to take it to the next level. (PS: hoping to increase its vicinity). The distance matrix, also was fixed in the code, to make it dynamic was just another step, but again, we kept it low :). When the program is run, it asks to select the source and a destination and later step to find the shortest path between the given source and the destination. The packets that ar...

Learning computer with low cost - Use open source OS.

Ever since i entered the stream of Computer Science, I use to always wonder how can an average person pay for all the software's when it comes to learning computer. As we know that for many years Microsoft ruled the computer software's, its not the same now. I mean for one to learn computer usage with Window (XP/Vista/7) it will cost him as either you need to buy the software for your use or you need to explore the knowledge in computers by visiting some computer academia. But this is not the best way one can experience learning. Then there is free software which are build by a group or might have even by a single person. When i talk about free software, its not just any application but entire Operating System(OS) like LINUX based Operating systems. For information on Linux based visit here --  WIKI Here we see that people contribute to develop a community based systems which is widely available for end users and also the users feedback to improve the bugs   if ...