Skip to content

Instantly share code, notes, and snippets.

View luminousmen's full-sized avatar

Kirill luminousmen

View GitHub Profile
# Display calendar of given month of the year
import calendar
if __name__ == "__main__":
yy = int(input("Enter year: "))
mm = int(input("Enter month: "))
print(calendar.month(yy, mm))
import string
input_str = “This &is [an] example? {of} string. with.? punctuation!!!!” # Sample string
result = input_str.translate(string.maketrans(“”,””), string.punctuation)
print(result)
def tqdm(iteration, total: int, prefix: str = '', suffix: str = '', decimals: int = 1, bar_length: int = 100) -> None:
"""Call in a loop to create terminal progress bar
"""
str_format = "{0:." + str(decimals) + "f}"
percents = str_format.format(100 * (iteration / float(total)))
filled_length = int(round(bar_length * iteration / float(total)))
bar = '█' * filled_length + '-' * (bar_length - filled_length)
sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)),
@luminousmen
luminousmen / airflow-quick-start.sh
Created September 12, 2019 11:01 — forked from mmziyad/airflow-quick-start.sh
A really quick on-boarding for Apache airflow.
# install
mkdir ~/airflow
cd ~/airflow
pip install airflow
# Have a look here if you need additional packages: https://airflow.incubator.apache.org/installation.html
# setup mysql backend as given here. The default SQLite is not adequate for some workloads.
# http://site.clairvoyantsoft.com/installing-and-configuring-apache-airflow/
# start services
@luminousmen
luminousmen / check_links.py
Last active September 20, 2019 14:44
Check links on a page
@luminousmen
luminousmen / run.sh
Created August 1, 2019 18:34
Big Data file formats
#!/bin/bash
END=3
FUNC="stats"
for ((i=1;i<=END;i++)); do
for fmt in csv json avro parquet; do
spark-submit --packages org.apache.spark:spark-avro_2.11:2.4.0 script.py $fmt $FUNC
done
done
@luminousmen
luminousmen / dino.py
Last active April 23, 2020 15:35
T-Rex dino game script that will play for you, successfully
import numpy as np
import cv2
from mss import mss
import pyautogui as pg
# Please put here you location of t-rex, I used `$ xdotool getmouselocation` for that
MONITOR = {"top": 247, "left": 566, "width": 70, "height": 35}
def process_image(img):
@luminousmen
luminousmen / ubuntu-chrome-emoji.sh
Created July 14, 2019 09:51
How To Enable Color Emoji on Chrome for Linux
#!/usr/bin/env bash
cd /tmp
wget https://noto-website.storage.googleapis.com/pkgs/NotoColorEmoji-unhinted.zip
sudo mkdir -p /usr/local/share/fonts/truetype
sudo unzip NotoColorEmoji-unhinted.zip -d /usr/local/share/fonts/truetype/noto
sudo rm /usr/local/share/fonts/truetype/noto/LICENSE_OFL.txt
sudo apt remove ttf-ancient-fonts-symbola fonts-symbola
sudo chmod 644 /usr/local/share/fonts/truetype/noto/NotoColorEmoji.ttf
fc-cache -f -v
@luminousmen
luminousmen / preprocessor_fun.h
Last active September 14, 2015 09:38 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,