Skip to content

Instantly share code, notes, and snippets.

View chexov's full-sized avatar

Anton P. Linevich chexov

  • Los Angeles
View GitHub Profile
@chexov
chexov / bin-sensor-light.yaml
Created June 3, 2022 20:15
homeassistant binary-sensor triggered light
blueprint:
name: Binary Sensor Activated Light
description: Turn on a light when binary sensor is on
domain: automation
source_url: https://gist.github.com/chexov/2f49874b4e499bf873972f7a9fff6458
input:
bin_sensor:
name: Binary Sensor
selector:
entity:
@chexov
chexov / nmcli-modem-connect.sh
Created October 9, 2020 18:38
connect usb modem on ubuntu startup. nmcli
root@elmer:/home/pi# cat /etc/rc.local
#!/bin/sh
echo "nameserver 8.8.8.8" > /etc/resolv.conf
e=1
while [ $e -ne 0 ]; do
echo "gaga";
@chexov
chexov / nginx-simplehttpserver.sh
Last active May 22, 2020 00:04
How to serve current directory under nginx. As simple as python's SimpleHTTPServer
#!/bin/sh
#
# Serves current folder as NGINX project
# Send beer or coffee.
#
cat > /tmp/nginx.conf<<EOF
worker_rlimit_nofile 8192;
events {
@chexov
chexov / gaussian_heatmap.py
Last active August 22, 2021 08:35
How to Generate Gaussian Heatmap on numpy
import cv2
import numpy
def gaussian_heatmap(sigma: int, spread: int):
extent = int(spread * sigma)
center = spread * sigma / 2
heatmap = numpy.zeros([extent, extent], dtype=numpy.float32)
for i_ in range(extent):
for j_ in range(extent):
@chexov
chexov / inhouse-kubernetes.md
Last active July 12, 2019 16:40
Inhouse Kubernetes Setup
@chexov
chexov / kubectl delete namespace
Created May 31, 2019 13:55
Delete Namespace Stuck At Terminating State
Problem
Sometimes after deleting a namespace (for example foo), it sticks on “Terminating” state, and when you enter:
kubectl delete namespace foo
You get:
Error from server (Conflict): Operation cannot be fulfilled on namespaces "foo": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.
Solution
Let’s get rid of foo namespace!
@chexov
chexov / a.cu
Created April 10, 2019 09:39
Test CUDA with "nvcc a.cu; ./a.out"
#include <iostream>
using namespace std;
void _cudaCheck(cudaError_t err, const char *file, int line) {
if (err != cudaSuccess) {
cerr << "cuda error: " << cudaGetErrorString(err)
<< file << line << endl;
exit(-1);
}
@chexov
chexov / vmm-alpine.sh
Created December 29, 2018 01:45 — forked from voutilad/vmm-alpine.sh
Installing Alpine Linux in OpenBSD's VMM Hypervisor
# Assuming you're a regular user that has doas allowances for vmctl
mkdir -p ~/vmm
cd ~/vmm
# Grab the the one of the virt iso's of Alpine Linux
curl https://nl.alpinelinux.org/alpine/v3.6/releases/x86_64/alpine-virt-3.6.0-x86_64.iso -o alpine-virt-3.6.0-x86_64.iso
# Make a new virtual disk image, change the size as needed
vmctl create alpine-virt.img -s 6G
@chexov
chexov / ffmpeg-concat-list.py
Created June 20, 2018 18:32
concat list input for ffmpeg from dash m4s chunks
#!/usr/bin/env python
import sys
import os
def ffmpegconcatlist(ts_list, isPlain):
tslist = []
for f in ts_list:
f = f.strip()
if not f or not os.stat(f).st_size:
@chexov
chexov / opsguide.md
Last active April 20, 2018 12:48
hitchhiker's guide to the ops

Hitchhiker's guide to the ops

Burnt-in timecodes

DASH

    _local/bin/ffmpeg -i  http://kote.videogorillas.com/vmir/car_damage_detection/mp4/AugmentedReality.mp4 -f dash \
        -vcodec libx264 -acodec copy -crf 22 -g 24 \
        -vf drawtext="fontsize=15:fontfile=/Users/chexov/Library/Fonts/Anonymous \Pro\ B.ttf:timecode='00\:00\:00\:00':rate=30:text='':fontsize=32:fontcolor='white':boxcolor=0x000000AA:box=1:x=40:y=20" -y out.dash/out.mpd

MP4

_local/bin/ffmpeg -i http://kote.videogorillas.com/vmir/car_damage_detection/mp4/AugmentedReality.mp4 -vcodec libx264 -acodec copy -crf 22 -g 24 \