Set up Amazon S3 to serve Django Static and Media files

Amazon S3 Buckets are a cheap way to store your staticfiles and media files. It also seems like the easiest way when serving a Django App.

1) Sign up to AWS S3 and create IAM user

After signing up to Amazon AWS we need to create a user using the …

Continue reading »

Deploy a Django app to Heroku

Index:

Requirements:

  • Git installed
  • Python >3.6
  • Heroku CLI (see step 1)

1) Install the Heroku CLI

Install the Heroku Command Line Interface (CLI) for your platform from here …

Continue reading »

Collection of useful Django snippets for several purposes

Index


Create a slug

Call the Django slugify function automatically by overriding the save method. It is preferable to generate …

Continue reading »

Editing photos metadata

You can do it in one line in the Terminal using jhead.

For example, adjust all EXIF times forward by 1 hour:

jhead -ta+1:00 *.jpg

Useful links:

jhead download page

jhead documentation

Continue reading »

Filter a table or list by typing in search box

Using a JS library:

From scratch:

For a table

1) HTML

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names..">

<table id="myTable">
  <tr class="header">
    <th style="width:60%;">Name</th>
    <th style="width:40%;">Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Germany …

Continue reading »

VPS providers

When you need to host your projects, you have several options available:

Shared hosting, where you share a server with lots of other users and have very limited control over the server. Dedicated hosting, where you have complete control over a server, a very flexible option, but requires you to …

Continue reading »

Installing Python 3.7 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

1) Install the required build-tools …

Continue reading »

Create a standalone exacutable from a Python scripy

Using pyinstaller

To install pyinstaller on your pc (more details can be found here: https://www.pyinstaller.org/)

pip install pyinstaller

Use cmd to go to your program directory and to turn it into a exe folder

pyinstaller yourprogram.py

What I run:

pyinstaller -F --windowed --icon=myapp.ico SumExcel …

Continue reading »

Regular expressions

Regex for finding URLs

Regex if you want to ensure URL starts with HTTP/HTTPS:

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)

If you do not require HTTP protocol:

[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)

Exemple usage in VSCode to find …

Continue reading »

Run Matlab programs in Python

This example shows how to create a Python package using a MATLAB function. You can then pass the generated package to the developer who is responsible for integrating it into an application. The target system does not require a licensed copy of MATLAB.

Requirements

  • A Matlab version with a license …

Continue reading »