Skip to content

Instantly share code, notes, and snippets.

View luminousmen's full-sized avatar

Kirill luminousmen

View GitHub Profile
@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,
@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 / 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
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)),
import string
input_str = “This &is [an] example? {of} string. with.? punctuation!!!!” # Sample string
result = input_str.translate(string.maketrans(“”,””), string.punctuation)
print(result)
# 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))
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]
@luminousmen
luminousmen / Makefile
Created October 31, 2019 08:40 — forked from lumengxi/Makefile
Makefile for Python projects
.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
@luminousmen
luminousmen / test_bucketing.py
Created November 10, 2019 09:08
Example bucketing in pyspark
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(