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, |
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
# 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
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
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
# 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
from weakref import WeakValueDictionary | |
class Singleton(type): | |
_instances = WeakValueDictionary() | |
def __call__(cls, *args, **kwargs): | |
if cls not in cls._instances: | |
instance = super(Singleton, cls).__call__(*args, **kwargs) | |
cls._instances[cls] = instance | |
return cls._instances[cls] |
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
.PHONY: clean-pyc clean-build docs clean | |
define BROWSER_PYSCRIPT | |
import os, webbrowser, sys | |
try: | |
from urllib import pathname2url | |
except: | |
from urllib.request import pathname2url | |
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) | |
endef |
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 os | |
import pyspark.sql.functions as F | |
from pyspark.sql import SparkSession | |
if __name__ == "__main__": | |
spark = SparkSession.builder.master("local").getOrCreate() | |
spark.conf.set( |
OlderNewer