Skip to content

Instantly share code, notes, and snippets.

View jb-alvarado's full-sized avatar

jb-alvarado

View GitHub Profile
@jb-alvarado
jb-alvarado / randomized_list.rs
Created September 5, 2023 12:27
fill list with randomized clips until limit is reached
View randomized_list.rs
use std::collections::HashMap;
use rand::Rng;
#[derive(Debug, Clone, Copy, PartialEq)]
struct Clip {
source: &'static str,
duration: f64,
}
@jb-alvarado
jb-alvarado / live_switcher.rs
Created March 21, 2022 14:10
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 March 21, 2022 14:09
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,
@jb-alvarado
jb-alvarado / watch_folder.rs
Created March 21, 2022 14:06
Rust watch folder
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 March 21, 2022 14:05
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 February 17, 2022 08:41
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 June 30, 2021 13:15
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 September 29, 2020 10:10
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