Tag: python
- How to approach and evaluate programming languages for a project (21 Sep 2022)
While it’s a topic which has already invited hair splitting debates ad nauseam, it has also invited a lot of hype and there is a need to unclutter that hype and think about this topic objectively. The Toolbox Approach This has been the classic or traditional approach when programming used...
- dateutil.relativedelta: A must have tool in your python kitty (25 Apr 2021)
Making additions or subtractions to datetime variables is one of the most commonly encountered programming endeavors and that’s what the built-in datetime.datetime.timedelta object is for in python. Its very useful in adding hours or days to your datetime variables as follows: import datetime now = datetime.datetime.now() tea_time = now +...
- The right way to serve static files when using django with gunicorn (19 Apr 2021)
Yesterday, I learned during deployment that your Django app when used in combination with gunicorn will refuse to serve static files, do whatever you may. I looked up almost every Stack Overflow answer post on this topic including this, this and this. I meddled with almost every hopeful setting including...
- How to perform Microsoft OneDrive OAuth sign-in and authorization in a python web app (14 Nov 2020)
The methods and examples given in this article are based on flask framework but they should apply to django or something similar too with a little tweak. Few weeks ago, I had landed myself on a project of similar nature and though I found several helpful articles and blog posts...
- Intro to Message Flashing: A handy way to send messages across page requests in Flask (08 Jul 2020)
Message flashing is a very handy technique you must be aware of if you are a Flask developer. A common recurring pattern in web development is to send messages across web requests, especially in case of redirects when the route or controller that redirected wants to display some basic text...
- A crash course in python packaging (02 Jul 2020)
This guide isn’t for the newbie who is just learning python programming (they are better off doing a “proper” reading of the official docs instead). This is for the seasoned coder who dabbles in multiple technologies and needs a quick refresher on how to go about building a neat zip...
- Why you should never use the dict.get() method in python (28 Nov 2019)
There is an increasing trend towards using the dict.get() method in Python, it’s very widely used in many tutorials and examples too. Consider the below example for instance: >>> dd = {'a': 1} >>> dd.get('a') 1 This simple dictionary dd has only one key (‘a’) and its corresponding value is...
- Python recipe: Combine multiple images into one PDF (24 Oct 2019)
Many a times, you come across the need to combine multiple image files (.jpg, .png, etc.) into one single portable document format (.pdf). Maybe, you have a bunch of handwritten notes which you want to organize into one file. Doing that is very trivial if you know python. To being...
- Announcing gh_announce - A python bot that posts a tweet each time you make a release on github (27 Jun 2019)
I happen to maintain a lot of python projects on github such as distroverify and vtscan. And each time I make a tagged release on Github, I have to make a status tweet like this to let people know: So today I thought why not automate this process by writing...
- listdir vs scandir vs glob - The one and preferably only way to do it (26 Jun 2019)
You know, sometimes when I read those python aphorisms like “beautiful is better than ugly” I wonder whether the makers were being sarcastic or real, and I’m not kidding! Its not just about listdir and scandir, a whole lot of things are ambiguous and you’ll find a lot of different...
- Building a convention for configuration saver and reader module in Python (19 Jun 2019)
I maintain several python projects on github and some of them like VTScan has a need for user configuration. Now python has a plethora of ways and standards for parsing of configuration files like json, *.ini files, etc., but there is no standard about where to save them on the...
- Package signing in PIP - It works, in a roundabout sort of way (10 Jun 2019)
A few days ago, I made this DEV.to post about how Python’s PIP lacks GPG package signing. Well, it turns out that I’m wrong! It does have a package signing process after all, only its one of the most manual, archaic and cumbersome security practices I’ve seen till date. I...
- Wordpress to Pelican in 24 hours (21 May 2019)
Today, I finished migration of my blog from a self-hosted Wordpress site to a statically hosted Github Pages site. For the static site generator, instead of choosing Jekyll which is a hot favorite of rubyists, I went for Pelican instead as I figured my Python skills might be somewhat useful...
- Tux Drive - A Command Line Tool to Access Google Drive from Linux (20 Sep 2017)
One of the most boring things we need to perform in life is using the Google Drive. On one hand, so useful is this tool provided by Google (so many cloud GBs for free, yay!) but on the other hand, the web interface to access those files is not quite...
- Flask Recipe - RESTful CRUD using sqlalchemy (25 Jun 2017)
RESTful apps are a thing these days. When your application’s userbase gets quite large and the client could vary from a laptop to an android device to an iOS device, it pays to keep the backend code separate and use the server only for making RESTful calls using HTTP methods...
- How to create a Google Drive App in Flask (29 Dec 2016)
This is the first in a series of articles for web programmers that explain in detail about using the Google Drive API in your web applications to access files/folders on behalf of the users of your application. In my last project, I had to develop a python flask app for...
- Sqlalchemy Hack - How to convert a table to dict on the fly (04 Jul 2015)
In on of my recent projects, I came across the need to develop a JSON based REST API to fetch data from the sqlalchemy objects. Now, the Query object is a great way to access data using the powerful sqlalchemy orm, but it doesn’t give any built-in way to convert...
- How to host a Flask app on Openshift (06 Feb 2015)
Note: This article may no longer be relevant as Red Hat has recently changed the openshift stack with docker and kubernetes. Openshift free tier is an excellent way to host your python web app for staging or testing, and you can even host a low to medium traffic production site....
- How to host your own mail server using Google appengine (30 Dec 2013)
Google has an outstanding habit of bringing the power of elites to the masses. Firstly, they took over the world of smartphones with android, and now the buzzword everywhere is Google Appengine. Once you get the basics of GAE and start looking beyond your first HelloWorld application, you will start...
- How to create a Python app in Google App Engine (06 Dec 2013)
Whilst the official pythonic reference for Google app engine is the way I learnt how to build my first GAE app, I found it a bit frustrating to go through each and every link and understand large topics like caching and data stores in detail just to build a small hello world pythonic app in Google...
- How to Generate PDFs in Python for Google App Engine (26 Nov 2013)
One of my last projects based on google app engine and python involved storing form data in GAE datastore and generating PDF documents that the user can download. Whilst data storing was the easier part as google’s big data API it is pretty well documented, the trickier aspect was to convert...