Blog / Tech

Some tips with integrating Stripe with a subscription-based Django application

August 12, 2013

I just finished integrating Stripe with a subscription-based Django application a few weeks ago for processing credit card payments. This was the first time I've used this service and found the Stripe API and documentation to be very well written. Below are some things I learned while working on this project.

Avoid storing any credit card data in your database if you can for Payment Card Industry (PCI) compliance

One of the main reasons to …

How to share your local web server to the Internet using a reverse SSH tunnel

July 25, 2013

I was recently working with integrating Stripe payments with a Django app. Since it's a subscription-based web application, it made a lot of sense for us to use webhooks, which Stripe supports. You basically set a URL in your Stripe account settings where Stripe could POST when an event occurs (eg. trial ends, subscription canceled due to an unpaid invoice, etc.). This eliminates the need of having to poll the Stripe server to check …

How to set an older kernel version as the default in GRUB during bootup (Ubuntu 12.04)

May 23, 2013

I updated my Ubuntu's kernel (Sputnik kernel for the Dell XPS 13) a couple of days ago but I quickly noticed that this new kernel (verson 3.2.0-43-generic) broke the backlight brightness adjustment setting of my laptop. It was basically stuck at the highest setting which is way too bright for me when working in the dark.

I thought about possibly rolling back the version, but then realized there's actually no need to roll …

A simple Python program for exporting a list of dictionaries to a PDF table using ReportLab

April 16, 2013

I’m currently working on a project where I need to generate some reports in PDF format. Pretty much all of them use tables to display some data from a database, so I created this small program for easily exporting a list of dictionaries to a table in a PDF file.

data_to_pdf.py

from operator import itemgetter

from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter
from reportlab.platypus import Paragraph, …

How to submit a form in a POST request using JavaScript

April 16, 2013

I was working on a Django project a couple of days ago where I needed to use JavaScript to submit a form in a POST request. The response of this request is a PDF file generated with ReportLab. I wanted the browser to prompt the user to download the file or open it in the browser in another window.

I was trying to do this with AJAX at first, but apparently you’re not really supposed …