Skip to content

Instantly share code, notes, and snippets.

View aslafy-z's full-sized avatar
👻

Zadkiel AHARONIAN aslafy-z

👻
View GitHub Profile

update-host-aliases

This Gist provides a script that updates host aliases in the /etc/hosts file based on comments following the pattern # alias ${sourcehostname}=${targethostname}. It ensures that entries for the specified source hostnames are updated with the correct IP addresses for their corresponding target hostnames.

Features

  • Automatically updates /etc/hosts based on alias comments.
  • Resolves IP addresses using DNS if not found in /etc/hosts.
  • Supports a dry-run option to preview changes before applying them.
package main
import (
"fmt"
"strings"
"github.com/distribution/reference"
)
// Converts Golang regex counterparts to JavaScript equivalents
@aslafy-z
aslafy-z / livetv.m3u8
Last active December 16, 2024 10:55
Sample Live TV M3U8
#EXTM3U
#EXTINF:-1 tvg-id="20MinutesTV.fr" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/20_Minutes_TV_IDF_logo_%282023%29.png/320px-20_Minutes_TV_IDF_logo_%282023%29.png" group-title="General",20 Minutes TV
https://lives.digiteka.com/stream/86d3e867-a272-496b-8412-f59aa0104771/index.m3u8
#EXTINF:-1 tvg-id="TVTarn.fr" tvg-logo="https://i.imgur.com/MJdY1m3.png" group-title="General",TV Tarn
https://live.creacast.com/albi-tv-ch1/stream/playlist.m3u8
#EXTINF:-1 tvg-id="BFMBusiness.fr" tvg-logo="https://i.imgur.com/psqIHn4.png" group-title="Business;News" user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",BFM Business
#EXTVLCOPT:http-user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
https://ncdn-live-bfm.pfd.sfr.net/shls/LIVE$BFM_BUSINESS/index.m3u8?end=END&start=LIVE
#EXTINF:-1 tvg-id="BFMTV.fr" tvg-logo="https://i.imgur.com/YJCcczD.png" group-title="News" user-agen
@aslafy-z
aslafy-z / jellyfin-init.sh
Created August 7, 2024 15:55
Init jellyfin programatically
#!/bin/sh
set -x
jellyfin_server="http://localhost:8096"
username="jellyfin"
password="jellyfin"
storage_path="/home/library"
log_file="/tmp/jellyfin-init.log"
#!/bin/sh
git_endpoint=https://
git_branch=main
git_username=foo
git_password=bar
if [ -n "$git_username" ] && [ -n "$git_password" ] && echo "$git_endpoint" | grep -qE '^https?://'; then
encoded_git_username=$(echo "$git_username" | yq @uri)
encoded_git_password=$(echo "$git_password" | yq @uri)

Dex: encode Oauth2Client CRD name

Source dexidp/dex#1606 (comment)

Dex OAuth2Client CRD metadata.name field should match spec.id and spec.name but needs a special encoding.

Generate it with:

wget https://gist.github.com/aslafy-z/c7e6cc1e2efb15b33fe497e4adbbf6f5/raw/dex-encode-crd-name.go
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
@aslafy-z
aslafy-z / descheduler-grafana-dashboard.json
Last active September 10, 2024 07:42
Very rough Kubernetes descheduler Grafana dashboard
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
{
"streams": [
{
"stream": {
"container": "controller",
"container_id": "cec7f4ad43cf5d883a04d6a612e65fb6429ea671b7757ef0643b74a20511a666",
"fluentd_host": "logging-operator-logging-fluentd-1",
"host": "ci01-a3np-ingress-wan-a-vmss000000",
"namespace": "nginx-ingress-wan",
"pod": "nginx-ingress-wan-controller-86656594b5-bd7qb",