Skip to content

Instantly share code, notes, and snippets.

View pkubik's full-sized avatar

Paweł Kubik pkubik

  • Warsaw University of Technology
  • Warsaw
View GitHub Profile
@pkubik
pkubik / view.py
Created December 29, 2024 16:30
Minimal image view in NiceGUI
from nicegui import events, ui
def mouse_handler(e: events.MouseEventArguments):
color = "SkyBlue" if e.type == "mousedown" else "SteelBlue"
ii.content += f'<circle cx="{e.image_x}" cy="{e.image_y}" r="15" fill="none" stroke="{color}" stroke-width="4" />'
ui.notify(f"{e.type} at ({e.image_x:.1f}, {e.image_y:.1f})")
src = "https://picsum.photos/id/565/640/360"
@pkubik
pkubik / nihao.py
Created September 9, 2024 22:30
Fake Nihao
import numpy as np
from pathlib import Path
names = [
str(p).replace("/", "-").replace("\\", "-").replace("C:-", "").lower().strip("-")
for p in Path("/mnt/c/Windows").glob("*/*")
if len(str(p)) < 40
]
@pkubik
pkubik / python-daemon.sh
Created November 28, 2023 12:11
Daemonized python interpreter
# setup FIFO and hang python interpreter
fifo_path=$TMPDIR/"pysh-"$(date +%s)
mkfifo $fifo_path
python3 <$fifo_path &
exec 3>$fifo_path
# perform some commands
echo 'import os' >$fifo_path
cat >$fifo_path <<EOF
import json
@pkubik
pkubik / nice-custom-name-with-timestamp.md
Created May 28, 2023 23:32
nice-custom-name-with-timestamp

Nice custom name

run_name = f"{tag_name}-{datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%f')}"
@pkubik
pkubik / README.md
Created April 28, 2023 10:42
An entrypoint that sets umask before running user script

Entrypoint for docker with host dir mountpoint

The idea is to use this along with -v $PWD:/app option.

Whenever you use this workflow all files created in your working directory will be created by the docker user (e.g. root) requiring you to use sudo for clean-up...

... random sudo rm -rf something is just what you need in your life.

Legend:

  • orange: no decay
  • pink: wd=1e-4
  • cyan: wd=1e-5

obraz

@pkubik
pkubik / nh2.py
Last active July 1, 2022 17:48
K8s job control with fzf frontend and HTTP flask backend
from __future__ import annotations
from flask import Flask
from flask import request
from flask import abort
from multiprocessing import Process
import subprocess as sp
import sys
import os
import json
@pkubik
pkubik / fzf_http_frontend.py
Last active July 1, 2022 11:04
Setup Flask HTTP server as backend for simple counters storage and use fzf+curl for frontent. I have my reasons, ok?
from __future__ import annotations
from flask import Flask
from flask import request
from flask import abort
from multiprocessing import Process
import subprocess as sp
import sys
import os
from dataclasses import dataclass, field
@pkubik
pkubik / mobilenetv2.py
Created October 24, 2021 14:54
Keras implementation of MobileNetV2 for CIFAR-10 translated from Pytorch model
"""
Based on the model from:
https://github.com/kuangliu/pytorch-cifar
"""
import tensorflow as tf
import tensorflow.keras as keras
import tensorflow.keras.layers as kl