Skip to content

Instantly share code, notes, and snippets.

import { mode } from '@chakra-ui/theme-tools';
import { extendTheme } from '@chakra-ui/core';
const styles = {
global: props => ({
":root": {
"--app-title-color": "#718096",
"--card-minw": "160px",
"--blackwhite": mode("black", "white")(props),
"--whiteblack": mode("white", "black")(props),
@bsitruk
bsitruk / docker-registry.sh
Created September 12, 2019 13:15
Commands and configuration file to configure docker registry
# Run a docker registry
# https://docs.docker.com/registry/deploying/
docker run -d -p 5000:5000 \
--restart=always \
--name registry\
-v /mnt/registry:/var/lib/registry \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
registry:2
# Add private registry as insecure
@bsitruk
bsitruk / event-loop.py
Created September 10, 2019 07:51
Asyncio event loop wrapper
import asyncio
import logging
import signal
logger = logging.getLogger(__name__)
class EventLoop:
def __init__(self, loop=None, debug=False):
self.loop = loop or asyncio.get_event_loop()
@bsitruk
bsitruk / lightgbm.py
Last active August 20, 2019 13:55
LightGBM Optimized Parameters
# configuration params are copied from @artgor kernel:
# https://www.kaggle.com/artgor/brute-force-feature-engineering
LGB_PARAMS = {
'objective': 'regression',
'metric': 'mae',
'verbosity': -1,
'boosting_type': 'gbdt',
'learning_rate': 0.2,
'num_leaves': 128,
'min_child_samples': 79,
@bsitruk
bsitruk / promise-thread.py
Created August 4, 2019 14:25
Promise implementation using ThreadExecutor and Future in Python
from concurrent.futures import ThreadPoolExecutor, Executor, Future
class Promise:
def __init__(self, fn, *args, **kwargs):
self.fn = fn
self.callbacks = []
self.last_result = None
self.executor: Executor = ThreadPoolExecutor(max_workers=1)
self.future: Future = self.executor.submit(fn, *args, **kwargs)
@bsitruk
bsitruk / seaborn-palettes.txt
Last active July 30, 2019 10:08
List of Seaborn Palettes
Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, deep, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnupl
@bsitruk
bsitruk / functional.py
Last active July 30, 2019 08:20
Some functional utilities in python.
from tempfile import NamedTemporaryFile, TemporaryDirectory
def compose(g, f):
"""Right to left function composition."""
return lambda *args, **kwargs: g(f(*args, **kwargs))
def temporarify(action, directory=False):
"""
@bsitruk
bsitruk / reset_tables.plpgsql
Created July 5, 2017 13:57
PostgreSQL function: Remove all data from the db's tables, and restart id sequences.
DECLARE
statements CURSOR FOR
SELECT tablename FROM pg_tables
WHERE schemaname = 'public';
BEGIN
FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;';
EXECUTE 'ALTER SEQUENCE ' || quote_ident('' || stmt.tablename || '_id_seq') || ' RESTART WITH 1';
END LOOP;
END;
@bsitruk
bsitruk / string2Number
Created February 22, 2017 21:10
Fastest way to convert a string to a number
var numberOne = +'1'; // 1
@bsitruk
bsitruk / animations.css
Created February 26, 2016 12:50
SVG2CSS : output files
@keyframes dropball {
0% {
bottom: 200px;
}
2% {
bottom: 198.89046144485474px;
}
4% {
bottom: 197.5577425956726px;
}