Skip to content

Instantly share code, notes, and snippets.

View kingspp's full-sized avatar
🎯
Focusing

Prathyush SP kingspp

🎯
Focusing
View GitHub Profile
@kingspp
kingspp / logging.py
Created April 22, 2017 07:14
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@kingspp
kingspp / A Language Snippets
Last active November 3, 2023 16:35
Language Snippets #MySnippet
This gist reveals language snippets
@kingspp
kingspp / us_rmv_appointment_finder.py
Last active October 13, 2023 01:21
Search and locate latest appointments for RMV. Needs Python v3.5+. Tested on Mac and Linux Environments
# %% [markdown]
# RMV Appointment Finder v1.0
# %%
# Install Required Libraries
# !python3 -m pip install selenium pandas tqdm webdriver-manager -q
#
# Execution:
# python3 us_rmv_appointment_finder.py
#
@kingspp
kingspp / numpy_transfer_over_kafka.py
Created October 4, 2018 05:01
Efficient Transfer of Numpy Arrays over kafka
"""
Requirements
1. Numpy
2. Pympler or a recursive sys.getsizeof()
3. PIL
"""
import numpy as np
from pympler.asizeof import asizeof
import json
@kingspp
kingspp / overleaf_compile_on_focus.js
Last active July 21, 2023 01:26
Compile document on window focus
// Run below code in respective window console
window.addEventListener("focus", e => document.getElementsByClassName("split-menu-button")[0].click());
@kingspp
kingspp / mpi_installation.sh
Created March 28, 2019 13:12
OpenMPI v4 Installation
#!/usr/bin/env bash
# Install Open MPI v4
wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.0.tar.gz
tar -xvf openmpi-4.0.0.tar.gz
cd openmpi-4.0.0
./configure --prefix=/usr/local
make all
sudo make install
sudo ldconfig
@kingspp
kingspp / human_readable_time.py
Created January 6, 2019 06:19
Time delta in a human readable format
def humanize_time_delta(td_object):
seconds = td_object
periods = [
('year', 60 * 60 * 24 * 365),
('month', 60 * 60 * 24 * 30),
('day', 60 * 60 * 24),
('hour', 60 * 60),
('minute', 60),
('second', 1),
('milli_second', 1 / 10 ** 3),
@kingspp
kingspp / JsonEncoder.py
Last active September 12, 2021 00:29
Custom Json Encoder for json.dump()
# -*- coding: utf-8 -*-
"""
| **@created on:** 18/07/18,
| **@author:** prathyushsp,
| **@version:** v0.0.1
|
| **Description:**
|
|
| **Sphinx Documentation Status:** --
@kingspp
kingspp / Tee.py
Last active September 12, 2021 00:29
Tee functionality replicated for python - Simultaneously `print` to a file and `std out`
import traceback
import sys
# Context manager that copies stdout and any exceptions to a log file
class Tee(object):
def __init__(self, filename):
self.file = open(filename, 'w')
self.stdout = sys.stdout
def __enter__(self):
@kingspp
kingspp / convert_bash_alias_to_scripts.sh
Created May 26, 2020 14:51
Convert Bash Aliases to bash scripts for support for fish executables
#!/bin/bash
# Convert bash aliases to bash scripts.
#
# Copyright 2018 <hoijui.quaero@gmail.com>, licensed under the GPL-3.0+
#
# Usage:
# convert_bash_aliases_to_scripts # converts all bash aliases to script files
# convert_bash_aliases_to_scripts clean # removes all scripts previously converted by this script
COLOR_RED=$'\e[0;31m'