Skip to content

Instantly share code, notes, and snippets.

View hnaderi's full-sized avatar

Hossein Naderi hnaderi

View GitHub Profile
@hnaderi
hnaderi / dproxy.sh
Created December 7, 2023 12:06
Set proxy for a daemon
#!/usr/bin/env bash
CMD=$1
SVC="${2:-nix-daemon}"
PROXY="${3:-socks5://localhost:9999}"
BASE_DIR=/run/systemd/system
SVC_DIR="$BASE_DIR/$SVC.service.d"
OVERRIDE_FILE="$SVC_DIR/proxy-override.conf"
@hnaderi
hnaderi / approve-csr.sh
Created December 2, 2023 09:03
Create and approve Kubernetes certificates for users
#!/usr/bin/env bash
export USERNAME="$1"
export BASE64_CSR="$2"
cat <<EOF | kubectl apply -f -
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
name: $USERNAME
# First we need to get the modeline string for xrandr
# Luckily, the tool "gtf" will help you calculate it.
# All you have to do is to pass the resolution & the-
# refresh-rate as the command parameters:
gtf 1920 1080 60
# In this case, the horizontal resolution is 1920px the
# vertical resolution is 1080px & refresh-rate is 60Hz.
# IMPORTANT: BE SURE THE MONITOR SUPPORTS THE RESOLUTION
@hnaderi
hnaderi / gpg-ssh-setup.md
Created August 22, 2023 06:11 — forked from mcattarinussi/gpg-ssh-setup.md
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@hnaderi
hnaderi / reset-nix-proxy.sh
Created August 21, 2023 14:45
Set temporary proxy for nix-daemon
#!/usr/bin/env bash
rm /run/systemd/system/nix-daemon.service.d/proxy-override.conf
systemctl daemon-reload
systemctl restart nix-daemon
@hnaderi
hnaderi / zebh
Last active July 29, 2023 13:15
Shouts کوشته شد after killing a program using pkill
#!/usr/bin/env sh
shout='exit 1'
type aplay >/dev/null 2>&1 && shout='aplay -q -'
type play >/dev/null 2>&1 && shout='play -q -'
pkill "$@" && tail -n 1 $0 | base64 -d | $shout
exit $?
UklGRs5YAQBXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAATElTVBoAAABJTkZPSVNGVA4AAABMYXZmNTguNzYuMTAwAGRhdGGIWAEAJwFQAR8BQwGCAX8BkwHUAcgBegFpAZgBsAGxAboBuQG4AeUBLQJYAmYCdAKFApgClgJxAk0CTQJOAjcCKQI3AkECQAJEAkUCNwIcAgAC8gH9ARYCGwIIAgcCMgJ3AqcCnQJiAjYCOAI+Ai8CKAItAigCGgIQAg0CDAIBAu4B6wH9ARECFQIBAtcBqQFzASMBzgCcAI8AgwBbAB0A9P/y//b/2P+V/0n/FP8K/yD/Nv8z/xf/A/8X/z7/R/8i//D+2/7l/uX+wf6R/ob+q/7W/tr+xf7F/uj+Hf9S/4T/vv/v//r/5v/U/87/x/+4/6P/kv+S/5r/mP+G/2T/L//n/pj+Wf45/in+E/7+/fL96/3l/d/94v36/SX+Uf6C/sL+AP8h/xz/AP/w/v7+Ef8N//T+5/4C/0H/fv+W/4b/av9e/2f/ff+S/5//pv+t/67/pf+a/5j/n/+s/7f/wP/T//j/JABLAGYAbQBoAGoAcwBzAGEAQQAoACQAJQAIAMT/d/9L/1D/Yv9b/z//Lv86/1z/ef+B/4D/ff9w/1b/PP8v/zb/S/9b/1//X/9c/1X/Sf83/yP/Fv8Y/yf/Ov9B/zT/Hf8R/xf/If8a/wX/8/70/gr/KP9K/3P/nf+0/6v/kP+F/6b/6v8lADwAPABEAGEAhACRAIIAbgBmAGYAYwBcAF0AcgCRAKcAtQDMAPsAOQFrAYIBigGYAbIBygHSAc0ByAHG
@hnaderi
hnaderi / stream-to-file.sh
Last active January 13, 2019 18:50
stream all m3u8 playlist files to mp4 files using ffmpeg
#!/bin/bash
mkdir output;
for f in $2; do
output=$(echo $f| sed "s/.m3u8/.mp4/");
echo "streaming '$f' to '$output' ..."
echo from $(cat "$f" | grep -A 1 -i "$1" | tail -n 1);
ffmpeg -i "$f" -bsf:a aac_adtstoasc -vcodec copy -c copy output/"$output";