Author Archive

Using Docker for Flask Application Development

March 2, 2019 Leave a comment


I’ve been using Docker for my staging and production environments, but I’ve recently figured out how to make Docker work for my development environment as well.

When I work on my personal web applications, I have three environments:

* Production – the actual application that serves the users
* Staging – a replica of the production environment on my laptop
* Development – the environment where I write source code, unit/integration test, debug, integrate, etc.

While having a development environment that is significantly different (ie. not using Docker) from the staging/production environments is not an issue, I’ve really enjoyed the switch to using Docker for development.

The key aspects that were important to me when deciding to switch to Docker for my development environment were:

* Utilize the Flask development server instead of a production web server (Gunicorn)
* Allow easy access to my database (Postgres)
* Maintain my unit/integration testing capability

This blog post shows how to configure Docker and Docker Compose for creating a development environment that you can easily use on a day-to-day basis for developing a Flask application.

For reference, my Flask project that is the basis for this blog post can be found on GitLab.

Categories: Interesting

Secure Docker in Production

March 1, 2019 Leave a comment

via Secure Docker in Production

Categories: Interesting

Speed up Development with Docker Compose

March 1, 2019 Leave a comment
Categories: Interesting

Mastering Markdown

February 27, 2019 Leave a comment

What is Markdown?

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists are just a few of the things we can do with Markdown. Mostly, Markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.

Categories: git

Naming Branches

February 26, 2019 Leave a comment

I was wondering if there is a convention for naming git branches. Though this really depends on what your organization has, what do you follow when there are no standards?

After a quick google I opted to go for:

* feat-short-name
* test-short-name
* fix-short-name
* bug-short-name
* chore-short-name

When naming branches. Then still have

* develop for most of the work and
* master for releases.


Categories: git Tags: ,

How to use `git mergetool` to resolve conflicts

February 18, 2019 Leave a comment

Have the following in .gitconfig

    tool = vimdiff  
Categories: git Tags: ,

Change the last line in a file

February 12, 2019 Leave a comment

I needed to remove a comma from the last line of a file.

Learnt that I can specify the last line with sed.

# File with commas
$ less minerals.csv
$ sed '$ s/,//' minerals.csv
$ less minerals.csv


Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is addr1,addr2 (i.e., the addresses are separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against the line that addr1 matched.

After the address (or address-range), and before the command, a ! may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match.

The following address types are supported:

Match only the specified line number.

Match every step’th line starting with line first. For example, ”sed -n 1~2p” will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
Match the last line.

Match lines matching the regular expression regexp.
Match lines matching the regular expression regexp. The c may be any character.
GNU sed also supports some special 2-address forms:
Start out in “matched first address” state, until addr2 is found. This is similar to 1,addr2, except that if addr2 matches the very first line of input the 0,addr2 form will be at the end of its range, whereas the 1,addr2 form will still be at the beginning of its range. This works only when addr2 is a regular expression.
Will match addr1 and the N lines following addr1.
Will match addr1 and the lines following addr1 until the next line whose input line number is a multiple of N.


Categories: bash, sed