Skip to content

Instantly share code, notes, and snippets.

View DaniruKun's full-sized avatar
:octocat:
Processing...

Daniils Petrovs DaniruKun

:octocat:
Processing...
View GitHub Profile
@DaniruKun
DaniruKun / backup.exs
Created April 9, 2021 13:27
Simple Elixir mnesia table backup
{:ok , name, nodes} = :mnesia.activate_checkpoint([{:max, :mnesia.system_info(:tables)}])
:ok = :mnesia.backup_checkpoint(name, 'backup0.bak')
@DaniruKun
DaniruKun / patch-ms-teams.sh
Created March 1, 2021 16:17
Patch MS Teams on macOS to detect non-USB only video input devices
#!/usr/bin/env zsh
echo "This script patches MS Teams on macOS to allow virtual cameras like OBS"
sudo codesign --remove-signature "/Applications/Microsoft Teams.app"
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper.app"
sudo codesign --remove-signature "/Applications/Microsoft Teams.app/Contents/Frameworks/Microsoft Teams Helper (GPU).app"
@DaniruKun
DaniruKun / capture-usb-video.sh
Last active February 17, 2021 17:14
Capture USB video device with FFmpeg on macOS from Rule capture card
#!/bin/sh
# Call the script with single argument like this
# ./capture-usb-video.sh out.avi
ffmpeg -f avfoundation \
-rtbufsize 100M \
-video_size 1920x1080 \
-pixel_format nv12 \
-framerate 30 \
@DaniruKun
DaniruKun / erlang_ls.config
Created September 29, 2020 17:51
Standard Erlang language server project configuration file
deps_dirs:
- "_build/default/lib/*"
diagnostics:
enabled:
- xref
disabled:
- dialyzer
include_dirs:
- "include"
- "_build/default/lib"
@DaniruKun
DaniruKun / rebar.config
Created June 17, 2020 16:27
Typical Elvis formatter configuration
{elvis,
[#{dirs => ["apps/*/src", "src"],
filter => "*.erl",
rules => [{elvis_style, line_length,
#{ignore => [],
limit => 100,
skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_style, macro_names, #{ignore => []}},
@DaniruKun
DaniruKun / lambda_handler.py
Last active June 8, 2020 20:32
Python Telegram weather radar bot
from html.parser import HTMLParser
import http.client
from http.client import HTTPException
import json
import os
from urllib.parse import urljoin
SRI_HOST = "lietus.lv"
TELEGRAM_API_HOST = "api.telegram.org"
@DaniruKun
DaniruKun / dragon.clj
Created May 20, 2020 21:36
Auto docking alignment demo
(defn align-y
"docstring"
[driv]
(let [y (@tel/telem :y)
vy (@tel/telem :vy)]
(if (pos? y)
(when (or (> (math/abs y) deadzone)
(pos? vy))
(translate driv "left"))
(when (or (> (math/abs y) deadzone)
@DaniruKun
DaniruKun / dragon.clj
Last active May 20, 2020 22:19
Automatic Docking Dragon alignment demo
(defn align-pitch-rot
"Align rotation on pitch axis."
[driv]
(if (pitch-within-error?)
(kill-pitch-rot driv)
(align-pitch driv))
(recur driv))
@DaniruKun
DaniruKun / telemetry.clj
Created May 20, 2020 21:02
Automatic Docking telemetry update
(defn poll
"Poll telemetry and update the state."
[driv]
(if true
(do
(Thread/sleep poll-interval)
(let [t (System/currentTimeMillis)
dt (* (+ poll-interval (- t (@telem :t))) 0.001)
x (get-x driv)
y (get-y driv)
@DaniruKun
DaniruKun / telemetry.clj
Created May 20, 2020 20:53
Automatic Docking Telemetry Demo
;; Yaw
(defn get-yaw-delta
""
[driv]
(let [yaw-delta-q (query driv {:css "#yaw > div.error"})
yaw-delta (get-element-text-el driv yaw-delta-q)]
(parse-delta yaw-delta)))
(defn get-yaw-rate