Skip to content

Instantly share code, notes, and snippets.

@qs-wang
qs-wang / .gitmessage
Last active December 12, 2017 22:57 — forked from RichardBronosky/.gitmessage
Use this Git commit message template to write better commit messages. Made the changes to fit my project.
# Provide links to any relevant tickets, articles or other resources
# SC-12: The ticket title
# If applied, this commit will...
# Why is this change needed?
Prior to this change,
#------------------------------------------------^---------------------^
# 50^ 72^
@qs-wang
qs-wang / gist:cb74517888a3b36318c1e43e6289e4bc
Created October 10, 2018 00:00
Pandas read_csv to parse the date time column
chat_history_raw_file = os.path.abspath(os.path.dirname(
__file__)) + '/../resources/chat_history_raw.csv'
chat_history_raw_df = pd.read_csv(chat_history_raw_file, parse_dates=['created_at'])
@qs-wang
qs-wang / docker-aliases.sh
Created October 11, 2018 09:17 — forked from jgrodziski/docker-aliases.sh
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@qs-wang
qs-wang / kubectl-shortcuts.sh
Created October 18, 2018 23:32 — forked from tamas-molnar/kubectl-shortcuts.sh
aliases and shortcuts for kubectl
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcdd='kubectl describe deployment'
alias kcdf='kubectl delete -f'
import logging
import os
from logging.config import fileConfig
def create_logger(name):
if "PYTHON_LOGGING_CONFIG_FILE" in os.environ:
logging_config_file_from_environ = os.environ["PYTHON_LOGGING_CONFIG_FILE"].strip("\"").strip("'")
if logging_config_file_from_environ:
fileConfig(logging_config_file_from_environ)
elif os.path.exists(os.path.abspath(os.path.dirname( \
@qs-wang
qs-wang / foo.py
Created November 9, 2018 03:05
mock the module with from
# foo.py
from collections import defaultdict
def bar():
return defaultdict()
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
export const getLogger = function(label) {
const localFormat = printf(info => {
return `${info.timestamp} [${info.label}] ${info.level}: ${info.message}`;
});
return createLogger({
format: combine(label({ label }), timestamp(), localFormat),
kubectl get job "your-job" -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -
mongodump --host localhost:20719 --db flamingolife_go_live_small --archive | mongorestore --host localhost:27018 --archive
@qs-wang
qs-wang / k8s_logs_deployment
Last active December 19, 2018 04:51
Keep pulling the logs fro all pods of one kubernetes deployment
#!/usr/bin/env bash
DEPLOYMENT=$1
while :
do
for p in $(kubectl get pods | grep ^${DEPLOYMENT}- | cut -f 1 -d ' '); do
echo ---------------------------
echo $p
echo ---------------------------