Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
@onjin
onjin / fastapi_with_django.py
Created April 22, 2021 19:19
Use django with fastapi - python
import os
from importlib.util import find_spec
from configurations.wsgi import get_wsgi_application
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
from fastapi.staticfiles import StaticFiles
from api import router

Keybase proof

I hereby claim:

  • I am onjin on github.
  • I am onjin (https://keybase.io/onjin) on keybase.
  • I have a public key ASCwD1OeHWmiu_hIv3OxMq8D2bUMqYLzdO_e5x-8mCINTgo

To claim this, I am signing this object:

@onjin
onjin / enable_zoom_at_apt.sh
Created July 29, 2021 08:05
install/upgrade zoom by apt
#!/bin/bash
url=https://zoom.us/client/latest/zoom_amd64.deb
debdir=/usr/local/zoomdebs
aptconf=/etc/apt/apt.conf.d/100update_zoom
sourcelist=/etc/apt/sources.list.d/zoomdebs.list
sudo mkdir -p $debdir
( echo 'APT::Update::Pre-Invoke {"cd '$debdir' && wget -qN '$url' && apt-ftparchive packages . > Packages && apt-ftparchive release . > Release";};' | sudo tee $aptconf
echo 'deb [trusted=yes lang=none] file:'$debdir' ./' | sudo tee $sourcelist
@onjin
onjin / update-nvim.sh
Created September 10, 2021 07:24
update nvim nightly bash script
update-nvim () {
target=${1:-nightly}
tmp_bin=/tmp/nvim.appimage.${target}
previous=$(nvim --version|grep '^NVIM')
url="https://github.com/neovim/neovim/releases/download/${target}/nvim.appimage"
echo "[update-nvim] target version ${target}"
echo "[update-nvim] current version ${previous}"
echo "[update-nvim] downloading file ${url}"
curl --output ${tmp_bin} --silent -L ${url}
file_type=$(file ${tmp_bin})
@onjin
onjin / create-k3d-cluster-with-registry.sh
Created October 30, 2021 14:14
create k3d/k3s cluster with registry
k3d registry create myregistry.localhost --port 5555
k3d cluster create local --registry-use k3d-myregistry.localhost:5555
@onjin
onjin / python_typed_decorator.py
Created July 13, 2022 12:09
Python typed decorator
RT = TypeVar('RT') # return type
def inject_user() -> Callable[[Callable[..., RT]], Callable[..., RT]]:
def decorator(func: Callable[..., RT]) -> Callable[..., RT]:
def wrapper(*args, **kwargs) -> RT:
# ...
@onjin
onjin / advent.py
Last active December 3, 2022 23:07
advent of code executor
#!/usr/bin/env python
"""
Example layout
2022/01/input_test.txt
2022/01/input_prod.txt
2022/01/code.py
Example code.py:
def phase_1(input: List[str]) -> Any:
# lines have '\n' at end
@onjin
onjin / obsidian-web-clipper.js
Last active June 28, 2024 07:09 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@onjin
onjin / set_wallpaper.sh
Last active July 27, 2023 11:20
set wallpaper by url | directory | file, using hyprpaper | feh | betterlockcreen | print - random or last used
#!/bin/bash
## ---------------------------------------------------------------------------------- ##
## Sets random image as wallpaper, trying remote url, local folder and fallback ##
## image. Then using executor like hyprpaper, feh, betterlockscreen or just prints ##
## found image to the output. ##
## ---------------------------------------------------------------------------------- ##
## https://gist.github.com/onjin/411d7f9c6ebcaf66aa75abe6941bea55
## ---------------------------------------------------------------------------------- ##
## Example usage
@onjin
onjin / errors.txt
Created July 31, 2023 13:04 — forked from benjaminoakes/errors.txt
BeOS (NetPositive) haiku error messages
Not a pretty sight
When the web dies screaming loud
The site is not found.
Morning and sorrow
404 not with us now
Lost to paradise.