Skip to content

Instantly share code, notes, and snippets.

View ngoduykhanh's full-sized avatar
💭
have a good day!

Khanh Ngo ngoduykhanh

💭
have a good day!
View GitHub Profile
@ngoduykhanh
ngoduykhanh / google_secret_manager.py
Created September 17, 2021 15:26
GCP Secret Manager Ansible library
#!/usr/bin/env python
from google.cloud import secretmanager
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True),
version=dict(default='latest'),
@ngoduykhanh
ngoduykhanh / dijkstra.py
Last active January 28, 2020 15:00
dijkstra.py
#!/usr/bin/env python3
import sys
graph = {
'A': {'B': 4, 'D': 1, 'C': 7},
'B': {'C': 2},
'C': {'E': 2, 'F': 3},
'D': {'B': 2, 'E': 4},
'E': {'D': 3, 'B': 7},
'F': {'E': 1},
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var domStyle = document.createElement("style");
domStyle.append(
'* { color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\
* * { background-color: rgba(0,255,0,.2) !important; }\
* * * { background-color: rgba(0,0,255,.2) !important; }\
* * * * { background-color: rgba(255,0,255,.2) !important; }\
* * * * * { background-color: rgba(0,255,255,.2) !important; }\
@ngoduykhanh
ngoduykhanh / cmake_sysroot_add
Created February 16, 2017 08:04
sysroot in cmakelist
# Check for sysroot override via TARGET_SYSROOT environment variable.
if (DEFINED ENV{TARGET_SYSROOT})
set(TARGET_SYSROOT "$ENV{TARGET_SYSROOT}")
message("Target sysroot overridden by TARGET_SYSROOT environment variable")
else()
# Ask the compiler for its sysroot.
if(NOT USE_CLANG EQUAL 1)
execute_process(
COMMAND ${TARGET_CC} --print-sysroot
OUTPUT_VARIABLE TARGET_SYSROOT
@ngoduykhanh
ngoduykhanh / prometheus.md
Last active January 7, 2016 02:32
Prometheus monitoring system overview

Prometheus Server

demo url: http://10.103.1.62:9090

Client

demo url: http://10.103.1.62:9100/metrics

Prometheus is based on a 'pull' mechanism, that scrapes metrics from the configured targets (like passive agent check in Zabbix). However, for short-lived jobs, it provides an intermediary push gateway for scraping metrics.

Client can be written in:

  • Go, Python, Java, Ruby
set shell=/bin/bash " require for vim-gitgutter
set mouse=a " allow scroll up/down inside vim
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set expandtab " tabs are spaces
set showcmd " show command in bottom bar
set cursorline " highlight current line
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
# Fucntion
function fish_prompt
set_color cyan -o
if test $PWD = $HOME
echo -n "~"
else
echo -n (basename $PWD)
end
set_color green -o
echo -n " >> "
@ngoduykhanh
ngoduykhanh / wsgi_app.sh
Created December 28, 2014 10:04
init.d script file for uwsgi application
#!/bin/bash
# uwsgi - Use uwsgi to run python and wsgi web apps.
#
# chkconfig: - 85 15
# description: Use uwsgi to run python and wsgi web apps.
# processname: uwsgi
CONF=/opt/mydomain.com/server_config/uwsgi.ini
PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/uwsgi
@ngoduykhanh
ngoduykhanh / jira.py
Last active May 18, 2016 07:52
Getting jira webhook data for "issue_created" event
#!flask/bin/python
import json
import traceback
from flask import Flask, request, make_response, jsonify
app = Flask(__name__)
@app.route('/jira-create', methods=['POST'])
def create_ticket():
@ngoduykhanh
ngoduykhanh / bash_prompt.sh
Last active August 29, 2015 13:59
My custom bash environment
#!/bin/bash
# Ngo Duy Khanh
# Email: ngokhanhit[at]gmail.com
# Website: tips4admin.com
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository