Skip to content

Instantly share code, notes, and snippets.

View bachloxo's full-sized avatar

Bach Ton That bachloxo

View GitHub Profile
@bachloxo
bachloxo / 2019-https-localhost.md
Created November 18, 2022 16:00 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@bachloxo
bachloxo / Different_style_guide_python.md
Created November 10, 2022 13:09 — forked from nipunsadvilkar/Different_style_guide_python.md
What is the standard Python docstring format?

Formats

Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on reStructuredText (reST). You can get some information about the main formats in that tuto.

Note that the reST is recommended by the PEP 287

There follows the main used formats for docstrings.

- Epytext

@bachloxo
bachloxo / python_naming_conventions.md
Created November 10, 2022 13:07 — forked from etigui/python_naming_conventions.md
Python naming conventions

Python naming conventions

This document gives coding conventions example for the Python code. This style guide evolves over time as additional conventions are identified and past conventions are rendered obsolete by changes in the language itself.

1. General

  • Avoid using names that are too general or too wordy. Strike a good balance between the two.
    • Bad: data_structure, my_list, info_map, dictionary_for_the_purpose_of_storing_data_representing_word_definitions
    • Good: user_profile, menu_options, word_definitions
  • Never use the characters as single character variable names:
  • “l“ : lowercase letter el
@bachloxo
bachloxo / python_idioms.md
Last active November 7, 2022 14:47 — forked from JohnStuartRutledge/python_idioms.md
A gist for tracking examples of idiomatic Python. The goal is to accrue a list of concrete examples to help develop an intuition of what constitutes "Pythonic" code.
@bachloxo
bachloxo / django_digitalocean.md
Created October 10, 2022 15:18 — forked from samwelkanda/django_digitalocean.md
A step by step process of deploying a django project to digital ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@bachloxo
bachloxo / a-mongodb-replica-set-docker-compose-readme.md
Last active April 12, 2021 10:21 — forked from DuongHieuMAI/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

Ourcase:

  • use setup.sh
  • make sure that network are same

Origin:

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
@bachloxo
bachloxo / resize_image.php
Created April 26, 2020 11:22 — forked from janzikan/resize_image.php
PHP: Resize image - preserve ratio of width and height
/**
* Resize image - preserve ratio of width and height.
* @param string $sourceImage path to source JPEG image
* @param string $targetImage path to final JPEG image file
* @param int $maxWidth maximum width of final image (value 0 - width is optional)
* @param int $maxHeight maximum height of final image (value 0 - height is optional)
* @param int $quality quality of final image (0-100)
* @return bool
*/
function resizeImage($sourceImage, $targetImage, $maxWidth, $maxHeight, $quality = 80)