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 / TimePicker.vue
Created May 6, 2024 11:53
Vue/Nuxt 3 custom time picker that support 24 hours in HH:mm:ss.ms format.
<template>
<div id="timeField" class="input input-sm input-bordered flex px-3 py-0">
<div class="grow">
<input
ref="timeInput"
:value="secToTime(props.modelValue)"
type="text"
pattern="([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]{1,3})?"
class="w-full px-1 py-0"
@click="setCursorPos"
@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.
@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 / 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 / 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 / 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 / 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 / custom_iter.rs
Last active February 17, 2022 08:41
Simple custom Iterator in Rust
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.
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
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;