Skip to content

Instantly share code, notes, and snippets.

View miraculixx's full-sized avatar
💭
working on https://github.com/omegaml

miraculixx

💭
working on https://github.com/omegaml
  • Switzerland
View GitHub Profile
@miraculixx
miraculixx / example.py
Created December 10, 2020 11:48
omegaml async task chaining
# this will chain the fit and predict, i.e. fit will run only on predict success
with om.runtime.chain() as crt:
crt.model('regmodelx').fit('sample[y]', 'sample[x]')
crt.model('regmodelx').predict([5], rName='foox')
result = crt.run()
# sometime later
print(result.get())
@miraculixx
miraculixx / rancher-install-18.09.sh
Last active November 20, 2020 11:46
rancher-docker installer
#!/bin/sh
set -e
# https://unix.stackexchange.com/a/315517
sudo systemctl stop apt-daily.service apt-daily-timer apt-daily-upgrade.timer || true
sudo systemctl kill --kill-who=all apt-daily.service || true
# https://github.com/rancher/rancher/issues/27353#issuecomment-706103308
sudo killall dpkg || true
sudo rm -f /var/lib/dpkg/lock || true
@miraculixx
miraculixx / timeit.py
Created September 20, 2020 11:26
a straight forward statement timer for Python
@contextmanager
def timeit():
""" straight forward statement timer for Python
Usage:
with timeit() as timer:
...
print(timer.elpased()) # prints the timedelta, timer also has .start, .end
"""
@miraculixx
miraculixx / omx_launch.py
Last active August 14, 2020 01:03
simple gpu launcher
import subprocess
subprocess.run("getgist miraculixx progress.py".split(' '))
import omegaml as om_
from progress import progress
om = om_
def match_active_queues(queue=None, nodes=None):
queues = om.runtime.celeryapp.control.inspect().active_queues()
@miraculixx
miraculixx / progress.py
Last active August 14, 2020 01:02
a progress decorator for any python function
def progress(fn):
"""decorator to run fn until timeout in seconds, or wait forever if timeout < 0
Usage:
@progress
def fn(..):
return stop-flag, result
stopped, result = fn(.., timeout=SECONDS, stop_on_error=True|False, interval=SECONDS)
@miraculixx
miraculixx / Makefile
Last active August 12, 2020 17:57
create a locally hosted helm repository to use in dependencies, serve using python http.server
# put this in ./dependencies
# add external dependencies that cannot be added as a repository
# then add this directory as a file
# for every external chart, script the download as shown in localpath example, add to build target dependencies
# use $ make build to download all dependencies, build packages and local repo index
localpath:
mkdir -p staging
curl https://codeload.github.com/rancher/local-path-provisioner/tar.gz/v0.0.15 -o staging/localpath.tgz
cd staging && tar -xzf localpath.tgz
@miraculixx
miraculixx / README
Last active August 31, 2021 01:30
ffmpeg green screen chromakey virtual background for linux
setup
1. Install video 4 linux (v4l)
https://github.com/umlaeute/v4l2loopback
2. Install ffmpeg
https://linuxize.com/post/how-to-install-ffmpeg-on-ubuntu-18-04/
@miraculixx
miraculixx / markup.py
Last active April 12, 2023 17:13
an extensible multi-markup reader in less than 100 lines of python code
# (c) miraculixx, licensed as by the terms of WTFPL, http://www.wtfpl.net/txt/copying/
# License: DO WHATEVER YOU WANT TO with this code.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
from io import StringIO
from contextlib import contextmanager
@miraculixx
miraculixx / nvidia-docker.sh
Created June 10, 2020 09:44
rancher nividia docker 19.03
#!/usr/bin/env bash
# this is the rancher docker installation script with nvidia support
# apply to NVIDIA GPU nodes only
# sources
# https://www.tensorflow.org/install/docker
# https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions
# https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#how-do-i-install-the-nvidia-driver
# https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ubuntu-installation
@miraculixx
miraculixx / index.html
Last active April 24, 2020 16:38
test
<html>
<head>
<style>
#canvas {
border-color: black;
border-style: solid;
width: 128px;
height: 128px;
}
#resized {