Skip to content

Instantly share code, notes, and snippets.

Kirill luminousmen

Block or report user

Report or block luminousmen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@luminousmen
luminousmen / run.sh
Created Aug 1, 2019
Big Data file formats
View run.sh
#!/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 Jul 27, 2019
T-Rex dino game script that will play for you, successfully
View dino.py
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):
You can’t perform that action at this time.