Skip to content

Instantly share code, notes, and snippets.

@markizano
markizano / dnssec-new-sig.sh
Created April 29, 2024 02:02
Signs dnssec security keys so our DNS records are always signed.
#!/bin/bash
# Source: https://www.digitalocean.com/community/tutorials/how-to-setup-dnssec-on-an-authoritative-bind-dns-server--2
DOMAIN="$1"
PKIDIR="${PKIDIR:-/etc/bind/pki}"
ZONEDIR="${ZONEDIR:-/etc/bind/kizano}"
DOMAIN_KEY=""
# Set domain key in a config file under protected permissions.
@markizano
markizano / opensea-bids2db.sh
Last active April 19, 2024 14:28
Watch for bids against my NFT and store the price history so I can see how popular it gets.
#!/usr/bin/env python3
'''
Use case: I have an NFT for sale and I want to know when someone makes an offer on it.
I'm tired of refreshing the page at https://opensea.io/assets/ethereum/0x583f608324bce3569472d750b45ae5892d546a04/128
so I can have a custom dashboard if I wish to know the fluctuations of the offers against this item I'm wathing until sold.
This script will suscribe to updates on OpenSea's API and will insert the offers into a MongoDB database.
In this way, I can track updates withouth having to refresh the page so intently and can build my own price graph.
Documentation:
@markizano
markizano / syslog-ng.conf
Created March 19, 2024 17:57
Simple syslog-ng configuration for collecting everything in the system to logging to just a single destination file.
# Configuration file to replace `/etc/syslog-ng/syslog-ng.conf`
@version: 3.38
@include "scl.conf"
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation.
# First, set some global options.
options {
chain_hostnames(off);
@markizano
markizano / espanol.py
Created February 16, 2024 04:15
Clipboard command to convert English to Spanish and back.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Usage: I created a symlink to this file as ~/bin/es2en and ~/bin/en2es, but you can do this with any country code pairs.
# I put this in my `~/.fluxbox/keys`
# Mod4 Shift E :Exec /home/markizano/bin/es2en
# Mod4 Shift S :Exec /home/markizano/bin/en2es
#
# Restart fluxbox and now I can Win+Shift+E for English
# Win+Shift+S for Spanish
@markizano
markizano / update-discord.sh
Created February 9, 2024 17:44
Using aptly? update your repos with Discord automatically!
#!/bin/bash
. common.sh
exec > >(log update-discord)
exec 2>&1
function aptly() {
sudo -H -uaptly -gapps aptly $@
}
@markizano
markizano / nginx.conf
Last active February 3, 2024 18:49
Nginx Configuration File Sample (even logs in JSON format)
user nginx apps;
worker_processes 2;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
multi_accept on;
}
http {
#log_format extended "$http_host $remote_user@$remote_addr/$remote_port($proxy_add_x_forwarded_for, proxy=$http_proxy) $status($body_bytes_sent) \"$request\" \"$http_referer\" \"$http_user_agent\"";
log_format extended "JSON: {\"time\": \"$time_iso8601\", \"host\": \"$http_host\", \"user\": \"$remote_user\", \"remote\": \"$remote_addr:$remote_port\", \"proxy\": \"$proxy_add_x_forwarded_for\", \"status\": $status, \"response\": $body_bytes_sent, \"request\": \"$request\", \"upstream\": \"$upstream_addr\", \"t_req\": $request_time, \"t_upconn\": \"$upstream_connect_time\", \"t_upheaders\": \"$upstream_header_time\", \"t_upresponse\": \"$upstream_response_time\", \"referer\": \"$http_referer\", \"agent\": \"$http_user_agent\"}";
@markizano
markizano / ffmpeg-test-emoji.sh
Last active January 29, 2024 16:38
Test a font for being able to render an emoji using ffmpeg
#!/bin/bash
# Tests out the generation of subtitles using a smiley emoji and the "sparkles" emoji.
# Note that some fonts like sans and sans-serif may have the smiley (0xf09f9884), but not the sparkles (0xe29ca8).
# Some fonts will have neither.
# I think support for emojis in FFMPEG/mpv/fonts could use some improvement.
exec 4>subs.srt
echo "1" >&4
echo "00:00:00.000 --> 00:00:02.000" >&4
@markizano
markizano / teams.sh
Last active January 29, 2024 13:20
Run teams as its own user in Linux!
#!/bin/bash
# Teams shell you can add to ~teams/bin/teams and use `update-alternatives` to point to this instead.
# Be sure to add this to `/etc/sudoers.d/teams`
# %apps ALL=(msteams:apps) NOPASSWD: /usr/bin/teams
#
# I create a `teams` user using this:
# sudo addgroup --gid=200 apps
# sudo adduser --home=/home/apps/teams --shell=/usr/bin/teams --gid=200 --system msteams
#
@markizano
markizano / wifi.conf
Created November 1, 2023 02:42
Connect to Wi-Fi service for sysv-init.
# Set NETFILE to the location containing the wpa_supplicant network configuration.
# Uncomment the line that is the active network.
export NETFILE=/etc/wifi/My-NET.wifi
#export NETFILE=/etc/wifi/Work-NET.wifi
#export NETFILE=/etc/wifi/Public.wifi
@markizano
markizano / common.sh
Created October 5, 2023 10:48
Common functions to be used in scripts for formatted logging
#!/bin/bash
# This script not intended to run by itself, nor have exec permissions.
# This script intended only for sourcing from other scripts to reduce copy-paste code.
# Redirect STDOUT and STDERR to the system logger (syslog-ng).
function log () {
log_args='-i'
log_args="$log_args -u/dev/log"
log_args="$log_args -t $1"