Skip to content

Instantly share code, notes, and snippets.

View bugcy013's full-sized avatar
🪄
Focusing

Dhanasekaran Anbalagan bugcy013

🪄
Focusing
View GitHub Profile
@bugcy013
bugcy013 / decorator_time_it.py
Created September 17, 2020 06:20
Decorator Time it
from functools import wraps
from time import time
def measure(func):
@wraps(func)
def _time_it(*args, **kwargs):
start = int(round(time() * 1000))
try:
return func(*args, **kwargs)
finally:
@bugcy013
bugcy013 / infra-secret-management-overview.md
Created June 26, 2020 13:48 — forked from maxvt/infra-secret-management-overview.md
Infrastructure Secret Management Software Overview

Currently, there is an explosion of tools that aim to manage secrets for automated, cloud native infrastructure management. Daniel Somerfield did some work classifying the various approaches, but (as far as I know) no one has made a recent effort to summarize the various tools.

This is an attempt to give a quick overview of what can be found out there. The list is alphabetical. There will be tools that are missing, and some of the facts might be wrong--I welcome your corrections. For the purpose, I can be reached via @maxvt on Twitter, or just leave me a comment here.

There is a companion feature matrix of various tools. Comments are welcome in the same manner.

@bugcy013
bugcy013 / Python MySQLdb- using multiple database tables in query.md
Created June 22, 2020 01:33
Python MySQLdb- using multiple database tables in query

Was looking for an answer to the same question. Found that connecting without specifying the database will allow you to query multiple tables:

db = _mysql.connect('localhost', 'user', 'password')

Then you can query different tables from different databases:

select table1.field1,
       table2.field2
from database1.table1 inner join
 database2.table2 on database2.table2.join_field = database1.field1.join_field
Tips to pass Certified Kubernetes Application Developer (CKAD) exam
Getting started Kubernetes :-
a) Book : Kubernetes: Up & Running
b) Practice practice & practice with CKAD Exercises
the Best Kubernetes CKAD sample exercises which cover all parts of the exam https://github.com/dgkanatsios/CKAD-exercises.
c) Again, the best practice is use kubectl command well. Use kubectl to create resources (such as deployment, service, cronjobs, secret, configmap…) instead of creating them from manifest files.
Incase you have to edit manifest, use dry-run and -o yamlto save yaml file then edit manifest files.
d) Kubernetes in Action by Mario Luksa. The book is the holy bible of Kubernetes, and it basically answer all questions you may have ;
e) Whether or not you use Kubernetes at work, you should still provision your own cluster somewhere and play with it.
@bugcy013
bugcy013 / chrt_helper.sh
Last active March 20, 2020 03:18
Change Process scheduling to Realtime scheduler
#!/usr/bin/env bash
print_usage() {
echo "Usage: $( basename $1 ) <process name> <SCHED_FIFO | SCHED_RR> <priority (1-99)>"
}
if [ $# != 3 ]; then
print_usage $0
exit 1
fi
import pandas as pd
import numpy as np
randn = np.random.randn
df = pd.DataFrame(randn(15, 20))
df1 = pd.DataFrame(randn(10, 5))
df2 = pd.DataFrame(randn(5, 10))
writer = pd.ExcelWriter("test.xlsx", engine='xlsxwriter')
import os
import subprocess
def run_cmd(cmd="hostname", work_dir=None):
try:
logging.critical("let's execute cmd=%s", cmd)
pipe = subprocess.Popen(cmd, shell=True, cwd=work_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, error = pipe.communicate()
print(out, error)
pipe.wait()
import difflib
from termcolor import colored
# Colorize text.
#
# Available text colors:
# red, green, yellow, blue, magenta, cyan, white.
# Available text highlights:
# on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
# Available attributes:
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
from datetime import datetime
import pytz
date_str = "2019-10-22T10:45:35Z"
utc_datetime_obj = pytz.utc.localize(datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ"))
ist_datetime_obj = utc_datetime_obj.astimezone(pytz.timezone("Asia/Kolkata"))\
# .strftime("%Y-%m-%d %H:%M:%S")
# print(type(datetime_obj))
# datetime_obj_utc = datetime_obj.replace(tzinfo=timezone('UTC'))