Skip to content

Instantly share code, notes, and snippets.

Avatar

Kirill luminousmen

View GitHub Profile
View Toxic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Exploratory Data Analysis.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luminousmen
luminousmen / test_bucketing.py
Created Nov 10, 2019
Example bucketing in pyspark
View test_bucketing.py
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(
@luminousmen
luminousmen / Makefile
Created Oct 31, 2019 — forked from lumengxi/Makefile
Makefile for Python projects
View Makefile
.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
View singleton.py
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]
View calendar.py
# 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))
View no_puntuation.py
import string
input_str =This &is [an] example? {of} string. with.? punctuation!!!!” # Sample string
result = input_str.translate(string.maketrans(“”,””), string.punctuation)
print(result)
View pprint.py
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 Sep 12, 2019 — forked from mmziyad/airflow-quick-start.sh
A really quick on-boarding for Apache airflow.
View airflow-quick-start.sh
# 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 Sep 20, 2019
Check links on a page
View check_links.py