Structuring a Python application

In this short article I will explain all the different ways of structuring a Python application, from a quick script to a more complex web application.

Single python file containing all the code

That’s okay for code without dependencies or using a virtual environment. This is generally used for a quick script that doesn’t need complexity in its file structure.

5 minute read…

Create a proxy with a Raspberry Pi 3 (or above)

If you need to use a proxy that has the same IP address as your home, here is a tutorial on how to do it.

Install and configure your Raspberry Pi OS

Install and configure a raspberry pi without a mouse nor a keyboard :

  1. Download the last version of raspbian lite here and download Etcher which we will use to flash the disk image on the SD card.
  2. Start Elena, select the Raspbian Lite imake disk, select the target which is the SD card you use for your raspberry pi and click on Flash!.

While the image disk is getting installed, we will create the file that contains the wifi information so the raspberry can connect to it automatically. Open a text note and paste this inside :

6 minute read…

How to cancel a pending ethereum transaction with MetaMask

Having a pending transaction can be quite annoying and usually happens when the network is heavy loaded and the fees are sky rocketing. Your transaction may have a too low gas fee and miner are just ignoring it to prefer others transaction with higher fees.

This result in you being stuck because until that transaction is resolved you cannot send any other transaction. Annoying right ?

Let’s dive right in on how to fix this !

6 minute read…

Please Don’t Say Just Hello In Chat

2010-07-19 12:32:12 you: Hi
2010-07-19 12:32:15 co-worker: Hello.
# CO-WORKER WAITS WHILE YOU PHRASE YOUR QUESTION
2010-07-19 12:34:01 you: I'm working on [something] and I'm trying to do [etc...]
2010-07-19 12:35:21 co-worker: Oh, that's [answer...]

It’s as if you called someone on the phone and said “Hi!” and then put them on hold!

Please do this instead:

2010-07-19 12:32:12 you: Hi -- I'm working on [something] and I'm trying to do [etc...]
2010-07-19 12:33:32 co-worker: [answers question]

2 minute read…

Create a blog with Pelican, hosted on Github/Netlify

I hope this article / tutorial will give you the essential knowledge and steps to create and deploy your Pelican static blog on Netlify for free !

Goals

  • Install Pelican
  • Create a website running on Pelican
  • Deploy a Pelican based site to Netlify.com

Prerequisites

  • Basic knowledge about git and python
  • Python 3 and git installed on your workstation
  • VSCode or other IDE

9 minute read…

Why does porn grills men’s brain ?

Beyond this catchy title hides a reality unfortunately similar. Before explaining why, let’s do a quick history of this particular cinematographic art.

Before talking about cinema, eroticism and pornography have been the focus of novels since the very beginning of writing. Whether through representations of the sexual act, desire and its many signs, this genre has always attracted interest over the centuries.

But what is an erotic book?

A text that arouses excitement to read?

It is a very subjective definition, a simple poetry can awaken some enthusiasts but leave others of marble.

14 minute read…

Create a blog using Nikola static website generator

If you don’t know what is Nikola, it is a static website/blog generator (like gatsby and other tools). It’s written in Python and it is working out of the box for rendering markdown, rst, latex math formula and jupyter notebook files.

I like to understand what I am using, and pushing it to some limits to really get what I want from it, and making a blog with Nikola was no exception. Here I tried to summarize all the informations I found, and all the experimentation I did. I hope you’ll enjoy ! 🙏🏼

1) Installation

The first step is to have Python 3 installed on your computer, I recommend using virtual environment management.

Once you have create your virtual environment :

pip install --upgrade pip setuptools wheel
pip install --upgrade "Nikola[extras]"

17 minute read…

Blackjack, The 21 Game

« Never be the biggest bettor at your table. »

Introduction

Blackjack can be beaten !

You will see how to be at least break even with the house, and maybe have a small advantage over the long run with easy methods to learn, and how and why they work. I tried to summarize many books that I read and kept only what I thought was useful and easily shareable. I’ll put the list of the book I read at the end if you want to dig deeper in the world of beating the blackjack game.

23 minute read…

Publish a package on PyPi using Poetry

First thing first, you need Poetry if you don’t have it already.

Poetry is the new standard for creating and managing virtual environment for your Python project. It is also a Python dependency management tool that is working differently as pip. It uses the new standard pyproject.toml decided by the Python Packaging Authority with PEP-518. This file merges all the previous config files that were necessary before, setup.py, requirements.txt, setup.cfg, MANIFEST.in et Pipfile, in one unique file to rule them all ! Ok, enough of Lord of the Ring.

I advise you to follow along with the documentation of poetry open.

4 minute read…

Using environment variables in a Flask + Heroku project

Using environment variables is fundamental in a project. This is how you tell your app if you are running in production or locally for example. This is where you also store more sensible information like SECRET_KEY or API credentials. Storing those directly in your web app code can be easy at first, but it is not safe when you will push your code in production, so taking good habits from the beginning is a good idea.

Before jumping in the topic of configuring environment variables, I will first make you set up and deploy a basic app.

5 minute read…