Skip to content

Instantly share code, notes, and snippets.

@jb-alvarado
jb-alvarado / live_switcher.rs
Created Mar 21, 2022
Switch ffmepeg source <> live input
View live_switcher.rs
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 / file_loop_watch.ts
Created Mar 21, 2022
Loop over files and watch folder
View file_loop_watch.ts
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,
View watch_folder.rs
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 / custom_logging.rs
Created Mar 21, 2022
Custom logging in Rust, for example to send log entries over mail
View custom_logging.rs
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 / custom_iter.rs
Last active Feb 17, 2022
Simple custom Iterator in Rust
View custom_iter.rs
use std::{
thread::sleep,
time::Duration,
};
struct List {
arr: Vec<u8>,
msg: String,
i: usize,
}
@jb-alvarado
jb-alvarado / urlify.js
Created Jun 30, 2021
Find URLs in text and create links out of it.
View urlify.js
function urlify(text) {
const hyperlink = /<a [^>]+>([\w\d./=:"-]+)<\/a>/g
const urlRegex = /(https?:\/\/|www\.)([\w\d./-]+)/g
return text.replace(/(?:\r\n|\r|\n)/g, '<br>')
.replace(hyperlink, '$1')
.replace(urlRegex, (url, protoOrSub, domain) => {
domain = domain.replace(/\/$/, '')
if (protoOrSub.match(/https?/)) {
@jb-alvarado
jb-alvarado / edge.conf
Created Sep 29, 2020
HLS - Origin / Edge Cache
View edge.conf
proxy_cache_path /mnt/ramdisk/cache_temp use_temp_path=off keys_zone=cache_temp:10m max_size=1536m inactive=1h;
server {
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/edge.example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/edge.example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_name edge.example.org;
View default-server-conf.sh
#!/bin/bash
# nano syntax highlighting
cat <<EOT > /usr/share/nano/config.nanorc
# config file highlighting
syntax "conf" "(\.(bashrc|zshrc|conf|config|cfg|cnf|cf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|shadow|fstab|inittab|inputrc|protocols|sudoers)$|conf.d/|.config/)"
# default text
color magenta "^.*$"
View install-centos8-on-ibm-x3650.md

Install CentOS 8.2 on IBM x3650 M3

  1. prepare 2 USB sticks
  • first with Centos 8.2 minimal
  • second with correct version of dd-megaraid_sas driver from elrepo.org
  • the USB stick for the megaraid driver should have the lable OEMDRV, other while the drive is not recognize
  1. plug both USB sticks on server and boot
  2. go with F12 in boot menu and select USB device
  3. go truth the steps from CentOS install process
@jb-alvarado
jb-alvarado / pci-passthrough.md
Last active Oct 5, 2022
PCI Passthrough on Fedora 31
View pci-passthrough.md

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)