Skip to content

Instantly share code, notes, and snippets.

View bukowa's full-sized avatar

Buk Bukowski bukowa

View GitHub Profile
@bukowa
bukowa / .env.sh
Last active November 2, 2022 14:21
bootstrap install k3s via ssh on alpine
#!/bin/sh
export SERVER1="192.168.0.201"
export SERVER2="192.168.0.202"
export SERVER3="192.168.0.203"
export SERVER4="192.168.0.204"
export HOST1="g3w.dell.baza"
export HOST2="g50.dell.baza"
export HOST3="h3m.dell.baza"
@bukowa
bukowa / bash.sh
Last active November 11, 2022 13:08
bash
#!/bin/bash
# kubernetes delete objects
kubectl get crd -o=json | jq -r '.items[] | .metadata.name' | grep cert-manager.io | xargs kubectl delete crd
# helm get chart latest version
helm search repo jetstack/cert-manager --versions --output=json | jq -r '.[0].version'
# docker delete exited containers
docker ps -q -a --filter status=exited | xargs docker rm
@bukowa
bukowa / ducky.MD
Last active January 18, 2023 14:07
ducky one 2 sf
  • to rebind capslock into fn:

    • fn + alt + k for 5 seconds
    • press caps once, it should turn blue press esc
    • done
    • to use caps normally in that mode pres caps + tab
  • function lock (all keys working like holding fn):

    • hold fn (also hold to exit)
  • record macro:

@bukowa
bukowa / github-gpg-key-web-flow
Last active January 20, 2023 01:37
github gpg key pull request trust web flow trust
$ curl https://github.com/web-flow.gpg | gpg --import
$ gpg --edit-key noreply@github.com
gpg> trust
gpg> save
$ gpg --lsign-key noreply@github.com
to delete
$ gpg --delete-key noreply@github.com
@bukowa
bukowa / main.py
Last active January 20, 2023 23:50
python pillow simple benchmark
import json
import os.path
import timeit
from collections import namedtuple
from PIL import Image
SizeUnit = namedtuple('SizeUnit', ['size', 'name'])
KB = SizeUnit(1024, 'KB')
MB = SizeUnit(1024*1024, 'MB')
@bukowa
bukowa / Makefile
Created January 30, 2023 16:37
download node
getnode:
mkdir venvnode || true && wget -c https://nodejs.org/dist/v18.13.0/node-v18.13.0-linux-x64.tar.xz -O - | tar --strip-components=1 -xJ -C venvnode
@bukowa
bukowa / __init__.py
Created January 30, 2023 16:38
django don't cache static files wrapper no-cache
from functools import wraps
import django.http
import django.views.static
def no_cache_static(f):
@wraps(f)
def static(*a, **kw):
response: django.http.response.HttpResponse = f(*a, **kw) # type:
@bukowa
bukowa / models.py
Created February 6, 2023 21:36
django cascade on related change foreign key
class CascadeOnRelatedChangeForeignKey(models.ForeignKey):
"""
ForeignKey that deletes all instances of the "related_name"
whenever the related instance changes.
For example while using this field in a token model, if the user
changes, all the tokens will be deleted.
"""
def contribute_to_related_class(self, cls, related):
@bukowa
bukowa / constraint.py
Last active February 7, 2023 22:22
django constraint error message for field
from django.core.exceptions import ValidationError
from django.db import models
class ViolationFieldNameMixin:
"""
Mixin for BaseConstraint subclasses that builds custom
ValidationError message for the `violation_field_name`.
By this way we can bind the error to the field that caused it.
This is useful in ModelForms where we can display the error
@bukowa
bukowa / gunicorn.conf.py
Last active February 11, 2023 06:05
django + gunicorn proper logging setup
from .logging import GunicornLogger, gunicorn_logconfig_dict, gunicorn_access_log_format
wsgi_app = "conf.wsgi"
bind = "0.0.0.0:8000"
workers = 2
proxy_protocol = True
proxy_allow_ips = "*"