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 / vis.py
Created March 23, 2026 02:36
Ugly, dirty example of interactive feature-map visualization in Plotly Dash
from dash import Dash, Patch, dcc, html, Input, Output, callback
import plotly.express as px
import numpy as np
import torch
import torchvision
app = Dash(__name__)
def load_image(image_path):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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