Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / Kafka.drawio
Created September 5, 2022 20:18 — forked from alexandreaquiles/Kafka.drawio
draw.io Kafka Diagram (open it in https://draw.io)
<mxfile host="app.diagrams.net" modified="2020-06-03T21:01:58.638Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" etag="a1-ix2r6zzVVSPH3lcE_" version="12.9.3" type="device"><diagram id="h7GPxYbChwaNLsouTysn" name="Page-1">7V1pd9rG1/80nKYvyNEu8ZJ4SZ3EsWPcp+3/TY9AA6gGDZWEHfrpnxltSHMvi40WhMk5sY0kJLi/ufsyHfVi/vOzby+mt9Qhs44iOT876mVHUWSjp7Nf/MgqPqJpVnxg4rtOctH6wMD9jyQHpeTo0nVIULgwpHQWuoviwRH1PDIKC8ds36cvxcvGdFZ86sKeEHBgMLJn8OgfrhNO46OWYq6P/0bcyTR9MvvG8Zm5nV6cfJNgajv0JXdIveqoFz6lYfzX/OcFmXHipXSJ33e94Wz2wXzihfu84Z9H25ldvHxR/9a1fx/Gtvbb5KGra/Ftnu3ZMvnGX+xnu6MYM3bTT0Of/TXhf11QL1jOiQ/PbDkiHhhT9lEZJcJVQl7j3yVNT3SDCPw+u0CWFj/XJ9O7XA0pffpMPOLbIfUHxH92RyS9Nfve8d2LT2SHc59CKTxc8enScwgnj8xOv0zdkAwW9oiffWGrmR2bhvNZcnrszmYXdEb96L0qkR2dmOx4EPr0ieTO9AxTtY3sTLpqlOwT5CFLUHwmfkh+5g4lEH4mdE5Cf8UuSc7qSoJYwk+yoiXr62W9POV0zU1zS9NIjtkJR0yye68XDfsjWTf4Grob3F9fXy97N18WxuAfpSvfeNddtubBIjqM1mXQySySSe5BMqmmCsmk6FXRSdlNJTtYxEJs7P7kxPq0IL7Lnk742mKPYFKP3K8P5Wlmz9yJx/4eMZpF5zJ5I7
@jonathanhle
jonathanhle / parse_access_log.py
Last active September 10, 2022 21:57
parse_access_log.py
import logging
import re
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')
nginx_access_log_path = "/var/log/nginx/access.log"
def parse_with_split():
response_code_count = {}
@jonathanhle
jonathanhle / strace.md
Created September 5, 2022 02:46 — forked from shaikhul/strace.md
Strace cheat sheet

Strace cheat sheet

  • trace an executable: strace ls
  • trace specific system call: strace -e open ls
  • trace multiple system call: strace -e trace=open,read,write ls
  • save trace output: strace -o ls.txt ls
  • trace a running linux process: sudo strace -p pid
  • print timestamp: strace -t ls
  • gerate stat: strace -c ls
@jonathanhle
jonathanhle / install_pyenv.sh
Created September 5, 2022 02:28 — forked from styk-tv/ubu22 pyenv
Install pyenv on Ubuntu
#!/bin/bash
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
@jonathanhle
jonathanhle / python map example
Last active September 5, 2022 19:40
python map example
https://realpython.com/python-map-function/#coding-with-functional-style-in-python
# with a for loop
numbers = [1, 2, 3, 4, 5]
squared = []
for num in numbers:
squared.append(num ** 2)
@jonathanhle
jonathanhle / docker-shell.sh
Created September 2, 2022 06:15 — forked from falvarez/docker-shell.sh
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp DOCKER_IMAGE /bin/bash
@jonathanhle
jonathanhle / parser.py
Created September 1, 2022 13:10 — forked from hreeder/parser.py
Python nginx Log Parser
#!/usr/bin/env python
import gzip
import os
import sys
import re
INPUT_DIR = "nginx-logs"
lineformat = re.compile(r"""(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])""", re.IGNORECASE)
@jonathanhle
jonathanhle / unbound-cheat-sheet.md
Created February 10, 2022 19:02 — forked from f9n/unbound-cheat-sheet.md
Unbound Cheat Sheet

Unbound Cheat Sheet

Installation

$ yum install -y unbound

Setup SSL keys for unbound-control

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

@jonathanhle
jonathanhle / .bash_profile
Created January 6, 2022 18:55 — forked from fieg/.bash_profile
.bash_profile for OSX including autocomplete for ssh hosts, default variables and some aliases
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/sbin:$PATH
export EDITOR=vim
export APPLICATION_ENV="development"
export CLICOLOR=1
export LSCOLORS=dxfxcxdxbxegedabagacad
alias composer="php /usr/local/bin/composer.phar"
_complete_ssh_hosts ()
{