Skip to content

Instantly share code, notes, and snippets.

@sarjsheff
sarjsheff / dserver.py
Created March 16, 2025 11:12
Docker Registry server on python3
from flask import Flask, request, Response, abort, jsonify, send_file, make_response
import os
import hashlib
import uuid
import logging, base64
import argparse
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
@sarjsheff
sarjsheff / README.md
Last active November 18, 2022 11:38
FFMPEG

UDP streaming

ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:none" -codec:v libx264 -bsf:v h264_mp4toannexb -f h264 udp://localhost:1234

DASH 3-5 seconds

ffmpeg -y \
    -probesize 42M \
    -rtsp_transport tcp \
@sarjsheff
sarjsheff / BENCHMARK.md
Last active November 9, 2022 06:26
ncnn

Apple m1 pro

4 threads GPU

# cd ../benchmark
# ../build/benchmark/benchncnn 10 10 0 0
[0 Apple M1 Pro]  queueC=0[1]  queueG=0[1]  queueT=0[1]
[0 Apple M1 Pro]  bugsbn1=0  bugbilz=0  bugcopc=0  bugihfa=0
[0 Apple M1 Pro]  fp16-p/s/a=1/1/1  int8-p/s/a=1/1/1
@sarjsheff
sarjsheff / Dockerfile
Last active July 16, 2022 06:49
motioneye docker
FROM debian:11
RUN apt update && apt-get install motion ffmpeg v4l-utils -y
RUN apt-get install python2 curl -y
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && python2 get-pip.py
RUN apt-get install python-dev-is-python2 python-setuptools libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev libffi-dev libzbar-dev libzbar0 -y
RUN apt install -y fdisk lsb-release
@sarjsheff
sarjsheff / gre.sh
Created April 25, 2022 13:58
ip netns gre
#!/bin/sh
./simple_lan.sh # https://gist.github.com/sarjsheff/1b5b088c18e237c9aa28fcc218578536#file-simple_net-sh
set -x
ip -n ve1 tunnel add ve1tun mode gre remote 10.20.1.6 local 10.20.1.1
ip -n ve1 addr add 10.20.2.1/24 dev ve1tun
ip -n ve4 tunnel add ve4tun mode gre remote 10.20.1.1 local 10.20.1.6
ip -n ve4 addr add 10.20.2.2/24 dev ve4tun
@sarjsheff
sarjsheff / map.md
Last active April 25, 2022 09:02
ip netns simple virtual net + static route
flowchart LR
    ve1e1 --- ve2e1
    ve1e2 --- ve3e1
    ve3e2 --- ve4e1

subgraph ve1
   ve1e1(ve1e1<br/><small>.1</small>)
   ve1e2(ve1e2<br/><small>.2</small>)
end
@sarjsheff
sarjsheff / base.properties
Created April 9, 2022 19:14
Install kafka kraft
#
process.roles=broker,controller
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
@sarjsheff
sarjsheff / doc.md
Last active September 26, 2021 11:04
Generate kubectl config for user

Kube config client

srv# kubectl create ns test
srv# kubectl create sa testuser
srv# SNAME=`kubectl get sa testuser -o go-template="{{ (index .secrets 0).name }}"`
srv# kubectl get secret $SNAME -o go-template='{{ index .data "ca.crt" }}' | base64 -d > server.ca

cli# kubectl config set-cluster ofd --server=https://<kube server ip>:6443 --embed-certs --certificate-authority=./server.ca
@sarjsheff
sarjsheff / uid.js
Created August 6, 2021 07:03
js uuids
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
@sarjsheff
sarjsheff / config.sh
Created June 8, 2021 12:23
kafka key compaction
kafka-topics.sh --bootstrap-server localhost:9092 --create --topic testunique --config cleanup.policy=compact --config max.compaction.lag.ms=60000 --config min.cleanable.dirty.ratio=0.1