Skip to content

Instantly share code, notes, and snippets.

@xrat
xrat / sshpingpong
Last active March 16, 2023 21:44
Calculate time needed to send 1 byte back and forth within an SSH connection
#!/bin/bash
#
me=sshpingpong
#
# Measure close to minimal packet latency (RTT) of an SSH connection
#
prgversion="$me * 2022-07-27 (c) Andreas Schamanek"
#
# @author Andreas Schamanek <https://andreas.schamanek.net>
# @license GPL <https://www.gnu.org/licenses/gpl.html>
@lelandbatey
lelandbatey / columnize.py
Last active August 9, 2024 13:12
columnize.py parses STDIN as column-based data, printing as nicely formatted columns
#!/usr/bin/env python3
#
# Copyright (c) 2022 Leland Batey. All rights reserved.
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
columnize.py reads column-oriented text data and prints that data as
nicely-padded columns to STDOUT. Input data *must* be line-oriented; data that
spans multiple lines will not be correctly understood and will not be correctly
version: "3.7"
services:
project-zomboid:
image: ghcr.io/cyrale/project-zomboid
restart: unless-stopped
environment:
SERVER_NAME: "pzserver"
ADMIN_PASSWORD: "pzserver-password"
ports:
@erwiese
erwiese / check-http.sh
Last active November 26, 2022 03:43
Monitor a HTTP service, search for strings and reports connection times
#!/bin/bash
# Check availability and response time for a website
# Output is in InfluxDB line protocol
measurement="http.stat"
function dorequest () {
local url=$1
local chkstr=$2
@Neo-Desktop
Neo-Desktop / .links
Last active February 6, 2025 08:22
Modern.ie Hyper-V (2012) Instances
@rlaphoenix
rlaphoenix / _restream_cenc.md
Last active January 8, 2025 21:14
Ways to re-stream and decrypt MPEG-CENC live streams. (or just play on desktop)

Disclaimer

  1. All content keys were redacted, they should be 128-bit hex strings.
  2. These methods involve the use of ffmpeg and -cenc_decryption_key which is not part of stable releases as of July 2022. Use nightlies from gyan.dev or some other autobuild in the meantime. Hopefully it gets added in the next stable release.
  3. On my end none of these were particularly reliable. This may change in the future as FFmpeg evolves. The direct method of playing with ffplay is currently the most reliable out of the listed methods.

xTeVe (for Emby/Plex)

@wchargin
wchargin / pct.sh
Last active March 14, 2023 23:26
unix filter for computing percentiles / quantiles
#!/bin/sh
die() {
printf >&2 'fatal: %s\n'
exit 1
}
case $# in
0) die 'no percentiles provided' 'usage: pct P [P ...]' ;;
1) ps="$1" ;;
*)
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@arc279
arc279 / elapsed_millisec.sh
Created July 4, 2022 04:01
bash + awk で経過時間をミリ秒で取得
function elapsed_millisec() {
BEFORE=$(date +%s%3N)
eval "${@}"
AFTER=$(date +%s%3N)
awk -v OFMT="%.3f" -v before=${BEFORE} -v after=${AFTER} 'BEGIN { print (after - before) / 1000 }'
}
elapsed_millisec sleep 1.234
@plowsec
plowsec / systemd_dependencies_printer.py
Created June 30, 2022 14:07
Quick and dirty script to display systemd services as a directed graph
import networkx as nx
import sys
import os
import logging
import configparser
import traceback
from typing import List
from collections import OrderedDict
logging.basicConfig(level=logging.DEBUG)