Skip to content

Instantly share code, notes, and snippets.

@SunRed
SunRed / sync.sh
Last active December 23, 2022 18:28
Sync script for package mirrors that I use
#!/usr/bin/env bash
set -e
# Name of the mirror used for local directory names
mirror="${1}"
# Directory where the repo is stored locally.
target="/srv/ftp/${mirror}"
@SunRed
SunRed / player.html
Last active October 4, 2022 11:21
Simple video player using Plyr and Shaka Player from Google
<!DOCTYPE html>
<html lang="en">
<head>
<title>Player</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.7.2/plyr.min.css" integrity="sha512-1EV4ofS7XcLAlzTrHHfhk7UzxVEY8Qog2Jeve5UhGYrFm2BQylunV46RXUa5JJilEAmIAtIA2KbFxISjVmw+zg==" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.2.1/controls.min.css" integrity="sha512-+8BR6lbGCJm021MhjZMszue47HrhbLww8rZqeelgkqAgTWsWvYe7m8/H7V9lUVrPDI18vxBTdJogoxVPBB3Qjg==" crossorigin="anonymous" referrerpolicy="no-referrer">
<style>
@SunRed
SunRed / -systemd-email.md
Last active October 6, 2021 09:00
Send systemd service reports via encrypted multipart email on restart/stop or fail/success

systemd service report via encrypted email

Installation (Example setup)

  • Move systemd-email.sh to /usr/local/bin/ as systemd-email with permissions 755
  • Move systemd-email.conf to /usr/local/etc/systemd-email/
  • Move status-email-user@.service to /etc/systemd/system/
  • Create public keyring for GnuPG in /usr/local/etc/systemd-email/ with gpg --homedir /usr/local/etc/systemd-email/ --no-default-keyring --keyring pubring.gpg --fingerprint and set the permissions on pubring.gpg and trustdb.gpg accordingly or to 644
  • Import your public key with gpg --homedir /usr/local/etc/systemd-email/ --import

Usage

@SunRed
SunRed / particles.js
Last active July 4, 2022 20:05
Draw connected particles onto a canvas
const c = document.getElementById("particles");
const ctx = c.getContext("2d");
const maxParticles = 100 * (1/Math.pow(window.devicePixelRatio, .75));
const size = 2;
const r = size/2;
const cft = 1000/60;
let previous, stepratio;
let w, h, d;
resize();
@SunRed
SunRed / mirror.sh
Created March 23, 2021 15:03
Simple script utilizing rsync to sync two directories.
#!/bin/bash
set -e
read -e -p "Source Directory [./]: " SOURCE
SOURCE=${SOURCE:-./}
read -e -p "Destination Directory [../Mirror]: " DEST
DEST=${DEST:-../Mirror}
if [ $# -eq 0 ] || [ -z $1 ]
@SunRed
SunRed / nextcloud.conf
Last active November 30, 2020 11:09 — forked from fennb/gist:1283573
nginx microcaching config example for a Nextcloud instance behind a proxy (E.g. Nextcloud on Raspberry Pi tunnelled through WireGuard to a public server)
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 443;
listen [::]:443;
server_name yourhost.domain.com;
@SunRed
SunRed / motd.sh
Created October 20, 2020 07:30
Fancy login MOTD for the Raspberry Pi that can be placed in /etc/profile.d
#!/bin/bash
clear
function color (){
echo "\e[$1m$2\e[0m"
}
function extend (){
local str="$1"

Keybase proof

I hereby claim:

  • I am sunred on github.
  • I am sunred (https://keybase.io/sunred) on keybase.
  • I have a public key ASAjfKZEoC-AK8gqyJpBbfMlaDuzNiOWwemQ1wtzECZ_Zgo

To claim this, I am signing this object:

@SunRed
SunRed / channels.js
Last active September 11, 2019 05:36
Poorly written lurk bot for Twitch in node
var channels = {};
channels.required = [
// Channels you will always lurk in (as long as the list is smaller than config.maxChannels)
];
channels.pool = [
// Channels of which you randomly lurk in whenever the channels get rerolled (config.rerollCronjob)
// These are used to fill the pool of channels up to the config.maxChannels value in case channels.required doesn't reach that value in size
];
@SunRed
SunRed / userChrome.css
Last active June 14, 2018 19:00 — forked from Spaenny/userContent.css
Making Firefox Quantum dark
/*
Author: SpennyTF
Contributor: SunRed
How to install:
Just put the file under
%appdata%/Mozilla/Firefox/Profiles/<YOURPROFILE>/chrome/userChrome.css
You might have to create the chrome folder.
*/