Skip to content

Instantly share code, notes, and snippets.

@kfatehi
kfatehi / _list-github-pull-requests.md
Last active April 29, 2024 00:26
list pull requests across entire organization
@kfatehi
kfatehi / _README.md
Created June 5, 2016 03:42
Rebroadcasting an icecast stream to another icecast server with inline transcoding

What?

A one-liner that pulls an AAC stream, pipes it into ffmpeg which transcodes it to mp3, then pipes it into ezstream with your settings (in the xml file) which streams it your radio.

Dependencies

sudo apt-get install ficy ffmpeg ezstream

@kfatehi
kfatehi / 1pass_dups.js
Last active December 25, 2023 00:35 — forked from thehesiod/1pass_dups.py
1password duplicate remover (alpha, only run in debugger with breakpoints everywhere *g*)
// you need `op` tool for this, download it here https://support.1password.com/command-line/
// create items.json like so:
// op list items | jq > items.json
// then run this script
// this script outputs uuids of dupes as keyed by item title, create, and modified date,
// feed it into the delete command like so:
// node process.js | xargs -I{} op delete item {}
const items = require('./items.json');
@kfatehi
kfatehi / proxmox_get_vm_name.sh
Last active October 20, 2023 17:17
Get a Proxmox VM's name via MAC address via API and use it in a telegraf override
#!/bin/bash
PROXMOX_SERVER="pve:8006"
USERNAME="root@pam"
PASSWORD="<your pve password>"
NODE="pve"
INTERNAL_BRIDGE="vmbr1"
NIC="ens18" # nic name inside the vm to be templatized
MAC_ADDRESS="$(ip addr show $NIC | grep -m 1 -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tr 'a-f' 'A-F' | head -n1)"
# Step 1: Login and get ticket and CSRF token
@kfatehi
kfatehi / _wireguard_nat_guide.txt
Last active September 30, 2023 05:10
wireguard nat
apt install wireguard-tools
cd /etc/wireguard
# https://www.wireguard.com/quickstart/
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
# https://stanislas.blog/2019/01/how-to-setup-vpn-server-wireguard-nat-ipv6/
echo "net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1" > /etc/sysctl.d/wg.conf
@kfatehi
kfatehi / grafana_alert_maint.py
Created August 2, 2023 00:13
Reveal dashboards and panels that have alerts but no notification channels
# Reveal dashboards and panels that have alerts but no notification channels
# Works on Grafana v8 Alerts (v9 changes alerts a lot)
# This script is useful for when you accidentally change alert notification channel
import requests
from config import base_url, api_key
headers = {'Authorization': f'Bearer {api_key}'}
def get_dashboards():
url = f'{base_url}/api/search'
response = requests.get(url, headers=headers)
@kfatehi
kfatehi / gist:adee7a5019473f3f07679f21889c9d07
Created December 12, 2022 04:12
fix subscribestar urls
document.querySelectorAll('[data-href]').forEach((a)=>{ a.href = a.dataset.href; a.onclick=(e)=>{e.preventDefault(); e.stopPropagation(); window.open(a.href, 'blank')}} )
@kfatehi
kfatehi / output.txt
Created November 19, 2022 23:26
M1 Mac Mini GCC Preprocessor Defines (output of echo | gcc -dM -E -)
#define _LP64 1
#define __AARCH64EL__ 1
#define __AARCH64_CMODEL_SMALL__ 1
#define __AARCH64_SIMD__ 1
#define __APPLE_CC__ 6000
#define __APPLE__ 1
#define __ARM64_ARCH_8__ 1
#define __ARM_64BIT_STATE 1
#define __ARM_ACLE 200
#define __ARM_ALIGN_MAX_STACK_PWR 4
@kfatehi
kfatehi / dance.sh
Created October 5, 2022 22:12
ascii dance script
B=' o \ o / _ o __| \ / |__ o _ \ o / o '
C='/|\ | /\ ___\o \o | o/ o/__ /\ | /|\'
D='/ \ / \ | \ /) | ( \ /o\ / ) | (\ / | / \ / \'
E='55555555556666668888888777777555557777777766666666666677777775555'
P=0
function dance() {
if [ $P -ge ${#B} ]; then
P=0
fi
N=${E:$P:1}
@kfatehi
kfatehi / _test.spec.mjs
Created July 28, 2022 18:06
Playwright parallel independent sessions
import { test, expect } from '../helper/test.mjs';
import { signInProcess} from '../helper/sign_in_helper.mjs'
test('test', async ({ page, bpd, playwright }) => {
await Promise.all([
(async ()=>{
const browser2 = await playwright.chromium.launch();
const context2 = await browser2.newContext();
const page2 = await context2.newPage();
const pc2 = await bpd.createCompanyWithUsersContacts();