Upload and Download files from AWS S3 with Python 3

If you are trying to use S3 to store files in your project. I hope that this simple example will be helpful for you.

Install Boto3 via PIP

Please take a look to the source code at https://github.com/thanhson1085/python-s3 before reading this post.

With boto3, It is easy to push file to S3. Please make sure that you had a AWS account and created a bucket in S3 service.

And it is not difficult to save file from S3 to local:


Install PostgreSQL 9.4 in Ubuntu 14.04

I am sure that you will hate me when you read this post. Because It is very easy to install PostgreSQL 9.4 in Ubuntu 14.04. However, It works for me. And I hope you too.

Create file  /etc/apt/sources.list.d/pgdg.list, with content:

Import key and update repositories:

And install PostgreSQL 9.4:

Finally, test it:

The result should be:


And try to create a account with database:

To support remote access with account you just created. You should change file /etc/postgresql/9.4/main/pg_hba.conf.

The below is some commands we usually use in PSQL

Export data to sql file:

Import from SQL file

Reset serial number:


Update NPM to latest version

Actually, I do not have many opportunities to work with NodeJS. However, sometimes, I have to deploy some applications that request to install some npm packets. So easy with “npm install”. But what you think if npm command get errors? I think that it is time you need to upgrade NPM to the latest version.

It is really simple with commands bellow:

Update Node to latest version:

Finally, link node executed file to /usr/bin/node:


Run a Flask application in Nginx uwsgi

As you know uWSGI is the most popular to deploy a Python Application.  And Nginx is a powerful web server to run website in production. So this post will show a simple way to run your application (uses Flask Framework)  with WSGI and Nginx


Peace. It does not mean to be in a place where there is no noise, trouble or hard work. It mean to be in the midst of those things and still be calm in your heart

Create wsgi.py in your root directory of the application:

(Please make note that you understand the meaning of the source code above. So you can modify it to match your situation) 

And a config file for WSGI – wsgi.ini:

Install uwsgi with PIP:

Test your uWSGI config with command below:

Make sure that WSGI works with your application properly. Now, you can config NGINX to run over socket file(your_app_name_here.sock). Please create nginx config file with content below

Enable your site in Nginx:

And restart Nginx to apply your changes:

Test your site now!!!

Create upstart script:

With content: