Jinja2 Custom Template Tags

Posted on Tue 23 March 2021 in posts • Tagged with jinja2, flask, flask-meld

Building custom template tags in Jinja2 is not an easy task. That used to be the case, which you will see below.

tl;dr: Give jinja2-simple-tags a try.

Why would you create a custom template tag?

From the docs:

By writing extensions you can add custom tags to Jinja. This …


Continue reading

Form Validation With Flask-Meld

Posted on Fri 18 December 2020 in flask-meld • Tagged with python, Flask-Meld, Flask-WTF, Flask, WTforms, Meld

Real-time form validation with Flask-Meld  

Flask-Meld now integrates with Flask-WTF to handle form validation.

What's the big deal? Real-time form validation without writing any Javascript!

Flask-Meld form validation

Of course I wouldn't leave you hanging without a way to try it yourself! Here's a link to the demo

Building your form

While you …


Continue reading

Configuring uWSGI and NGINX for use with Flask-SocketIO

Posted on Fri 11 December 2020 in posts • Tagged with conveyor, meld, flask-meld

Now that Flask-Meld is working, it's time to start getting things ready for production. I've been wanting to start developing Meld components for Conveyor. Flask-Meld utilizes WebSockets, which Conveyor does not currently support. To make all of the magic happen NGINX and uWSGI configurations will need to be updated to …


Continue reading

Flask-Meld, ditch JavaScript frameworks for pure Python joy!

Posted on Fri 04 December 2020 in flask-meld • Tagged with python, Flask, Flask-Meld, Meld

Introducing a new way to build web applications: Flask-Meld  

Flask-Meld demo

Try the demo yourself

Before we dive in, I would like to give credit where credit is due. This extension was heavily inspired by the following projects and people:


Continue reading

Goodbye Gmail.

Posted on Thu 26 November 2020 in posts • Tagged with developer journal

After switching from Gmail to self-hosted email, managing the inbox has become more difficult. Making the switch made me realize something; I miss some of the features from Gmail. On my search for an alternative email client, I have seen RoundCube suggested as a web-based, open-source alternative. I started using …


Continue reading

Adding Digital Ocean to Flask-Dance

Posted on Fri 13 November 2020 in conveyor • Tagged with flask, python flask-dance

In the last article we learned how to set up and use a Digital Ocean Oauth app. Now that we understand how that works, let's make all of that hard work more accessible to the rest of the Flask community. Flask-Dance is an extension that is used to complete the …


Continue reading

OAuth with Digital Ocean and Flask

Posted on Tue 03 November 2020 in conveyor • Tagged with python, conveyor, flask

The OAuth flow can be confusing the first time you do it. This article and example project should help you feel more comfortable specifically for people who would like to use OAuth with Digital Ocean.

The code for this application can be found at https://github.com/mikeabrahamsen/flask-digitalocean-oauth-example

Conveyor …


Continue reading

How to create a KVM template on Arch Linux

Posted on Fri 30 October 2020 in arch • Tagged with arch, kvm, qemu

If you are deploying many virtual machines, templates can be leveraged to save time and even storage if using thin provisioning.

The process of creating a template is two steps:

  1. Create and configure the base operating system image
  2. Use sysprep to remove system-specific settings

Once completed we can create virtual …


Continue reading

How to structure Flask applications part 2 - Growing up

Posted on Fri 16 October 2020 in python • Tagged with python, flask, webdev

My first introduction to Flask was Miguel Grinberg's original Flask Megatutorial. After using Django as my framework of choice for several years. Miguel's simple use of Flask allowed me to see just far enough under the hood that I started understanding much more of the web stack, hidden in some …


Continue reading

How to structure Flask applications part 1 - Small Apps

Posted on Fri 02 October 2020 in python • Tagged with python, flask, webdev

One of the benefits of using Flask is it is straightforward to get an application up and running. When you are first starting, you can create your application with a single file. The structure of the application is left entirely up to the developer.

Starting with a single file application …


Continue reading

Arch Linux installed on ZFS

Posted on Fri 25 September 2020 in arch • Tagged with arch, zfs

ZFS is both a filesystem and a volume manager. If you have extra RAM in your system it will increase the read speed of your system dramatically by caching the system's most-used files in RAM.

How to use ZFS:

  1. The easiest way to use ZFS with Arch Linux is to …

Continue reading

Building Dynamic Web Applications with Python primer

Posted on Fri 18 September 2020 in python • Tagged with python

If you are a full-stack developer, whether you like it or not, you are going to use Javascript. It's an incredible language that allows developers to create dynamic applications. The amount of Javascript you use is up to you. Javascript can be used to power an entire application or it …


Continue reading

Using Brave Browser flags in linux

Posted on Sun 23 August 2020 in dev-journal • Tagged with developer journal

The easiest solution to add flags to your Brave Browser startup is to use the brave AUR package. It has a brave-launcher script that will check for a .config/brave-flags.conf file. All you need to do is create and populate the .config/brave-flags.conf

Alternative if using the brave-bin …


Continue reading

Grub Boot repair

Posted on Wed 19 August 2020 in dev-journal • Tagged with developer journal, linux, grub

One of my servers had a failure over the weekend and caused some corruption of the boot loader. This is the first time I have experienced this with a setup built on LVM and LUKS, which provided a little extra complexity to solve the problem.

This time, the Ubuntu Boot …


Continue reading

Incremental UI improvements

Posted on Tue 04 August 2020 in dev-journal • Tagged with developer journal, conveyor

Small UI updates today

Added a card to show additional information:

info card

Just for convenience a link was added to get from the register screen to the login page.

Add link back to log in


Vim regex grouping

Posted on Tue 28 July 2020 in dev-journal • Tagged with developer journal, vim

Wrote a regex in vim today that used a grouping in the find and replace. Needed to update 936 instances..

From a statement that calls a custom module function {% if entry.getEnableVal('conveyorDevToggle') == 1 to be a simple statement.. {% if entry.conveyorDevToggle %}

This is the regex used: :%s/\ventry.getEnableVal …


Continue reading

Overhauling the registration page

Posted on Fri 24 July 2020 in conveyor • Tagged with developer journal, conveyor

In this iteration a few small changes are going to be made. Here is the current state of the Conveyor registration page:

2020-07-23-210006_1455x812.png

Here it is after the following changes:

  • The width of the form imports are too long
  • Add a referral code input
  • Make the submit button smaller
  • Right align …

Continue reading

Recaptcha Uncaught (in promise) null error with Flask

Posted on Fri 24 July 2020 in dev-journal • Tagged with developer journal, recaptcha, flask-wtf

When trying to implement Recaptcha2 Invisible with Flask-WTF I ran into the following error:

Uncaught (in promise) null

This seemed to be a pretty obscure problem as I could not get any additional information from the application about what was going wrong. What finally got me to the solution was …


Continue reading

The newgrp command

Posted on Mon 20 July 2020 in dev-journal • Tagged with newgrp, linux

newgrp is a convienient command I ran across today. You can run this command after you add your user to a group. This allows you to continue without having to logout and log back in for the group changes to take effect.

Here is the man page:

 Manual page newgrp …

Continue reading

Developer Journal: 19 July 2020

Posted on Sun 19 July 2020 in dev-journal • Tagged with developer journal

Finished documentation for a client website. Remove database backups that are more than 30 days old

Otherwise a server maintenance day:

  • Cleaned internals of home server
  • Ran RAM test as I have had some crashes a couple times
  • Loosened the CPU heatsync screws a half turn each. There are reports …

Continue reading

Adding Matomo to Pelican Flex theme

Posted on Wed 15 July 2020 in dev-journal • Tagged with developer journal

After setting up an account with Matomo you can add the following to your peliconconf.py file.

# pelicanconf.py
MATOMO_SITE_ID = 2
MATOMO_URL = "ma.matomo.cloud"

Remove spaces from filenames

Posted on Wed 15 July 2020 in dev-journal • Tagged with developer journal

Here is a great little bash command to remove all of the spaces of a filename and replace them with an underscore for all files in the current directory.

for f in *\ *; do mv "$f" "${f// /_}"; done

Changing struts on a 2005 Toyota Corolla

Posted on Sun 12 July 2020 in dev-journal • Tagged with corolla, toyota, vehicle

This also applies to 2003, 2005, 2006, 2007, and 2008 models.

With 152k miles it was finally starting to feel time to replace the suspension in The Rolla. Replacing the struts in a 2005 Corolla is a fairly easy task.
I was planning 4 hours just to replace the back …


Continue reading

Developer Journal: 09 July 2020

Posted on Thu 09 July 2020 in dev-journal • Tagged with developer journal

Spent some time today working with Github actions for the first time. I set up a workflow that allowed me to lint the repo and run the tests on push.

Of course, this meant running my tests for the first time in a different environment and there was 37 tests …


Continue reading

If you were granted a wish, what would it be?

Posted on Wed 08 July 2020 in dev-journal • Tagged with developer journal

Today I was filling out a survey for a product I signed up for Python Morsels to help continue my Python education and one of the questions was:

If you could wave a magic wand (written in Python) and I could grant a wish, what would suddenly be different for …


Continue reading

Paving the way for Python 3.8

Posted on Wed 08 July 2020 in conveyor • Tagged with flask, conveyor, migrations

Currently Conveyor will install Python 3.6 when you create a server as 3.6 is the version that is used with Ubuntu 18. However, it would be great to have the ability to install more recent versions of Python and be able to use different versions depending on the …


Continue reading

Adding a test for the new site button

Posted on Tue 07 July 2020 in conveyor • Tagged with flask, conveyor, testing

When refactoring the new flow for creating a site the + New Site button was removed so there was only one option to add a site. If you already have a site with Conveyor we need to make sure the add site button is available.

To start I have written two …


Continue reading

Open markdown links in a new tab

Posted on Tue 07 July 2020 in dev-journal • Tagged with developer journal, markdown

While this is not supported with all Markdown interpreters, the following will work with Pelican and many others. You can add {:target="_blank"} following the Markdown link.

[Conveyor](www.conveyor.dev){:target="_blank"}

Here is an example, this link will open in a new tab: Conveyor


Return all items from a Github resource from the API

Posted on Tue 07 July 2020 in dev-journal • Tagged with developer journal, github

If you want to get the list of repos (or any other resource) from Github, the items are paginated once there are more than 30. Here is an example of how you can use a recursive function to follow the pagination and return all items of a particular resource.

Given …


Continue reading

Reset UUID of virtualbox disk file

Posted on Wed 01 July 2020 in dev-journal • Tagged with virtualbox

Use this command to reset the UUID

VBoxManage internalcommands sethduuid ubuntu-vm/xubuntu-vm.vdi