Skip to content

Instantly share code, notes, and snippets.

View jb-alvarado's full-sized avatar
💭
I may be slow to respond.

jb-alvarado

💭
I may be slow to respond.
View GitHub Profile
@jb-alvarado
jb-alvarado / custom_logging.rs
Created March 21, 2022 14:05
Custom logging in Rust, for example to send log entries over mail
extern crate log;
extern crate simplelog;
use std::{thread::sleep, time::Duration};
use simplelog::*;
use file_rotate::{compression::Compression, suffix::AppendCount, ContentLimit, FileRotate};
use log::{Level, LevelFilter, Log, Metadata, Record};
@jb-alvarado
jb-alvarado / watch_folder.rs
Created March 21, 2022 14:06
Rust watch folder
use notify::DebouncedEvent::{Create, Remove, Rename};
use notify::{watcher, RecursiveMode, Watcher};
use std::{
sync::{
mpsc::{channel, Receiver},
{Arc, Mutex},
},
thread::sleep,
time::Duration,
};
@jb-alvarado
jb-alvarado / file_loop_watch.ts
Created March 21, 2022 14:09
Loop over files and watch folder
use notify::DebouncedEvent::{Create, Remove, Rename};
use notify::{watcher, RecursiveMode, Watcher};
use std::{
ffi::OsStr,
path::Path,
sync::{
mpsc::{channel, Receiver},
{Arc, Mutex},
},
thread::sleep,
@jb-alvarado
jb-alvarado / live_switcher.rs
Created March 21, 2022 14:10
Switch ffmepeg source <> live input
use std::{
io::{prelude::*, BufReader, Error, Read},
process::{Command, Stdio},
sync::{
mpsc::{sync_channel, Receiver, SyncSender},
Arc, Mutex,
},
thread::sleep,
time::Duration,
};
@jb-alvarado
jb-alvarado / randomized_list.rs
Created September 5, 2023 12:27
fill list with randomized clips until limit is reached
use std::collections::HashMap;
use rand::Rng;
#[derive(Debug, Clone, Copy, PartialEq)]
struct Clip {
source: &'static str,
duration: f64,
}
@jb-alvarado
jb-alvarado / playbin_about-to-finish.py
Last active October 12, 2023 12:26
gstreamer python snips
#!/usr/bin/env python3
import gi
from urllib.parse import quote
gi.require_version('Gst', '1.0')
gi.require_version('GLib', '2.0')
from gi.repository import GLib, Gst
@jb-alvarado
jb-alvarado / pci-passthrough.md
Last active October 27, 2023 02:16
PCI Passthrough on Fedora 31

PCI Passthrough

Hardware:

  • Mainboard ASUS PRIME Z390-A Z390
  • ASUS Dual-GTX1650-O4G
  • Intel i9 9900
  • 32GB Ram
  • NEC Corporation uPD720200 USB 3.0 Host Controller
  • Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983 (1 TB)
@jb-alvarado
jb-alvarado / hls.conf
Last active January 23, 2024 20:58
srs rtmp server with hls multiple bitrates
listen 1935;
max_connections 20;
daemon on;
pid /usr/local/srs/objs/srs.pid;
srs_log_tank file; # console;
srs_log_file /var/log/srs.log;
ff_log_dir /dev/null;
# can be: verbose, info, trace, warn, error
srs_log_level warn;
@jb-alvarado
jb-alvarado / podman-container-to-host-bridge.sh
Last active March 18, 2024 12:59
Add poddman container to existing host bridge
#!/usr/bin/bash
# This script manages network interfaces for Podman containers. Podman is a daemonless container engine
# for developing, managing, and running OCI Containers on your Linux System.
#
# The script takes three arguments: an operation (either "start" or "stop"), a container name, and an IPv4
# address for the container. If any of these arguments are missing, the script will exit with an error message.
#
# The script first checks if it's being run as root. If not, it prepends `sudo` to certain commands to ensure
# they have the necessary permissions.