Skip to content

Instantly share code, notes, and snippets.

View usptact's full-sized avatar

Vladislavs Dovgalecs usptact

View GitHub Profile
@usptact
usptact / gst-tee.txt
Last active March 14, 2025 04:12
GStreamer: read a stream from video camera and use tee to (a) show the stream on display and (b) write to a file
$ gst-launch-1.0 -e v4l2src device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=640, height=480, framerate=30/1' ! tee name=t \
t. ! queue ! videoconvert ! autovideosink \
t. ! queue leaky=downstream ! videoconvert ! x264enc tune=zerolatency speed-preset=ultrafast key-int-max=30 byte-stream=true ! splitmuxsink muxer=mp4mux location=output.mp4
Notes:
x264enc appears to be not playing nice with streams. Removing its options blocks the pipeline. Replacing it with vaapih264enc works but then splitmuxsink has to be replaced with filesink for some reason...
vaapih264enc enables hardware acceleration on systems with Intel hardware. The plugin is available if you install an extra package: sudo apt install gstreamer1.0-vaapi
@usptact
usptact / ssh agent refused operation
Created January 16, 2024 19:57
Could not add card "/usr/lib/opensc-pkcs11.so": agent refused operation
System: MacOS Sonoma 14.1.2
First, try to unplug and plug back the Yubikey.
Second, try rebooting the system.
Make sure `opensc` package is up to date. I am using Macports to install utilities/libraries and other command-line utils.
```
$ sudo port upgrade opensc
```
@usptact
usptact / gist:ecbea82c6e2742461fbb0c27a58437f5
Created July 25, 2023 06:43
Do "git pull" in every git repo
$ find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && git pull" \;
@usptact
usptact / wif.md
Created July 11, 2023 08:28 — forked from t4sk/wif.md
How to convert private key to WIF

How to convert private key to WIF

0. Overview

WIF = base58check encode ([version byte][private key][checksum])

version byte = 80 for mainnet, ef for testnet and regtest

checksum = first 4 bytes of double SHA256 of private key
@usptact
usptact / GuassianDensity eval
Created December 31, 2022 02:58
Gaussian Density eval and comparison using Infer.NET
using Microsoft.ML.Probabilistic.Math;
using Vector = Microsoft.ML.Probabilistic.Math.Vector;
class Program
{
static void Main(string[] args)
{
Vector x = Vector.FromArray(new double[] { 0, 1 });
//Vector x = new Vector();
//Vector mean = new Vector(new double[] { 0.1, 1.1 });
// Two balls in the bag:
// (1) fifty/fifty red (true) or green (false)
// (2) 100% red
//
// Process:
// - pull out the first ball and observe it is red
// - Question: what is the probability the remaining ball is red too?
var model = function() {
var b1 = flip(0.5)
@usptact
usptact / HelloServlet.java
Created January 22, 2020 21:21
HelloServlet
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "HelloServlet", urlPatterns = {"hello"}, loadOnStartup = 1)
public class HelloServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
@usptact
usptact / codesign_gdb.md
Created October 25, 2019 01:07 — forked from hlissner/codesign_gdb.md
Codesign gdb on OSX

Note: these instructions are for pre-Sierra MacOS. Sierra and newer users see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow.

If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
using System;
using Microsoft.ML.Probabilistic.Models;
namespace twodice
{
class Program
{
static void Main(string[] args)
{
Variable<int> six = Variable.DiscreteUniform(6);
@usptact
usptact / zoo
Last active November 20, 2018 10:41
//
// Zoo: Infer prevalence of 3 animals after a zoo visit
//
// Observed: 3 lions, 2 tigers and 1 bear
//
// Questions:
// - Prevalence of each species
// - Probability of seeing a bear next time
//