This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
input_str = “This &is [an] example? {of} string. with.? punctuation!!!!” # Sample string | |
result = input_str.translate(string.maketrans(“”,””), string.punctuation) | |
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
import argparse | |
import urllib.parse | |
from bs4 import BeautifulSoup | |
from concurrent.futures import ThreadPoolExecutor as PoolExecutor | |
import requests | |
from termcolor import colored, cprint | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
NewerOlder