Skip to content

Instantly share code, notes, and snippets.

View dungdt88's full-sized avatar

Richard Dam dungdt88

  • Ho Chi Minh City, Vietnam
View GitHub Profile
@dungdt88
dungdt88 / xlmsec-mac-issue.md
Created December 6, 2023 03:59
Solve issue with xmlsec installation in Mac
@dungdt88
dungdt88 / urrl-regex-pattern.py
Last active July 23, 2020 09:18
Python URL regex pattern
URL_PATTERN = (
r'(?i)('
r'(?:(?:(?:https?|ftp):)?//)'
r'(?:\S+(?::\S*)?@)?'
r'(?:'
r'(?!(?:10|127)(?:\.\d{1,3}){3})'
r'(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})'
r'(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})'
r'(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])'
r'(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}'
@dungdt88
dungdt88 / aws-ec2-cloud-init-users.md
Created June 12, 2020 07:39
AWS EC2 Cloud Init - Used when you lost key to ssh to your EC2 instance

Add this to your instance user data. You need to stop the instance before set this.

Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
@dungdt88
dungdt88 / Python-Cheatsheets.md
Last active October 30, 2019 05:20
Python Cheatsheets

Install Python 3.7 on Ubuntu

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y virtualenv python3.7 python3.7-dev

Python - MySQL Connector

mongodump

Dump a single collection

mongodump -h "mongodb0.example.com:27017" -d dbname -u user -p password -c collectionname -o path-to-output

Make a backup (dump all collections)

mongodump -h "mongodb0.example.com:27017" -d dbname -u user -p password -o path-to-backup

Source: https://www.toptal.com/python/tips-and-practices

This resource contains a collection of Python best practices and Python tips provided by our Toptal network members. As such, this page will be updated on a regular basis to include additional information and cover emerging Python techniques. This is a community driven project, so you are encouraged to contribute as well, and we are counting on your feedback.

Python is a high level language used in many development areas, like web development (Django, Flask), data analysis (SciPy, scikit-learn), desktop UI (wxWidgets, PyQt) and system administration (Ansible, OpenStack). The main advantage of Python is development speed. Python comes with rich standard library, a lot of 3rd party libraries and clean syntax. All this allows a developer to focus on the problem they want to solve, and not on the language details or reinventing the wheel.

Check out the Toptal resource pages for additional information on Python. There is a Python hiring guide, Python job

@dungdt88
dungdt88 / k8s-cheatsheets.md
Last active December 2, 2019 04:45
Kubernetes Cheetsheets

Kubernetes Cheetsheets

Get authorized for a new cluster

  1. List all available clusters
gcloud --project=<project-name> container clusters list
  1. Get credentials for a cluster in the list
@dungdt88
dungdt88 / tmux-cheatsheet.markdown
Created August 14, 2019 12:03 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

Postgres Cheat Sheet

List all tables

\dt

List tables together with their sizes:

@dungdt88
dungdt88 / bq-cheat-sheet.md
Created March 12, 2019 07:47
BigQuery Cheat Sheet

Copy a partition

bq cp -f [PROJECT]:[DATASET].[SOURCE_TABLE]\$[SOURCE_PARTITION] [PROJECT]:[DATASET].[DESTINATION_TABLE]\$[DESTINATION_PARTITION]