Skip to content

Instantly share code, notes, and snippets.

View KristobalJunta's full-sized avatar
🇺🇦

Eugene KristobalJunta

🇺🇦
View GitHub Profile
@KristobalJunta
KristobalJunta / .celery timezones.md
Last active June 21, 2022 15:29
Example for Celery 4.4.0 with timezoned beat task

Example for timezoned beat task with Celery 4.4.0. Two ways to create datetime object inside crontab's nowfun that seemingly produce same result actually behave differentlty.

const dino = `
__
/ _)
_.----._/ /
/ /
__/ ( | ( |
/__.-'|_|--|_|
`
console.log(dino)
@KristobalJunta
KristobalJunta / progress.py
Created February 18, 2022 09:38
Simple progress indicator in python (string rewrites itself)
from time import sleep
n = 10
for i in range(n + 1):
print(f"\rsleeping ... {i} / {n}", end="\r")
sleep(.5)
print()
@KristobalJunta
KristobalJunta / split_csv.py
Created June 1, 2021 14:57
Fast (probably) splitting of csv files by number of rows (accounts for linebreaks inside cell values)
#!/usr/bin/env python2
import os
import sys
def split(filehandler, delimiter=',', row_limit=700000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
import csv
reader = csv.reader(filehandler, delimiter=delimiter)
current_piece = 1
@KristobalJunta
KristobalJunta / pyproject.sample.toml
Created April 24, 2020 07:36
Sample pyproject file with the fields used for PyPi metadata
[tool.poetry]
name = "poetry_tutorial_project"
version = "0.1.0"
description = "Simple Python project built with Poetry."
authors = ["Todd Birchard <toddbirchard@gmail.com>"]
maintainers = ["Todd Birchard <toddbirchard@gmail.com>"]
license = "MIT"
readme = "README.md"
homepage = ""
repository = "https://github.com/hackersandslackers/python-poetry-tutorial/"
@KristobalJunta
KristobalJunta / pyproject.toml
Created March 6, 2020 09:57
This set of dependencies makes poetry resolve them for a very long time
[tool.poetry]
name = "example_project"
version = "0.1.0"
description = "Dependencies for this resolve for eternity"
authors = []
[tool.poetry.dependencies]
python = "^3.5"
awscli = "^1.15"
google-api-python-client = "^1.7.4"
@KristobalJunta
KristobalJunta / heididecode.py
Last active October 29, 2019 10:05
Decode passwords stored in HeidiSQL
#!/usr/bin/env python
from __future__ import print_function
import sys
def heidi_decode(hexstr):
shift = int(hexstr[-1])
l = [int(hexstr[i:i+2], 16) for i in range(0, len(hexstr), 2)]
return ''.join(chr(v - shift) for v in l)
@KristobalJunta
KristobalJunta / JSONSerializable.py
Created August 27, 2019 20:12
A dict-serializable (JSON compatible) mixin for SQLAlchemy models
# -*- coding: utf-8 -*-
class JSONSerializable:
def _serialize(self, value):
if type(value) not in (int, float, bool, type(None)):
return str(value)
return value
def as_dict(self):
@KristobalJunta
KristobalJunta / carbon-config.json
Created July 9, 2019 18:28
My config for carbon.now.sh
{
"paddingVertical": "6px",
"paddingHorizontal": "9px",
"marginVertical": "45px",
"marginHorizontal": "45px",
"backgroundImage": null,
"backgroundImageSelection": null,
"backgroundMode": "color",
"backgroundColor": "rgba(255,255,255,1)",
"dropShadow": true,