Skip to content

Instantly share code, notes, and snippets.

@fnky
fnky / ANSI.md
Last active May 17, 2024 16:33
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@winny-
winny- / force-inet4-or-inet6.c
Last active May 7, 2024 07:20
Force IPv4 or IPv6 in applications such as Lynx
/*
force-inet4-or-inet6.c - hack to force applications to use IPv4 or IPv6 exclusively
compilation: cc -fPIC -shared -DUSE_INET4 -o force-inet4.so force-inet4-or-inet6.c
cc -fPIC -shared -DUSE_INET6 -o force-inet6.so force-inet4-or-inet6.c
usage: LD_PRELOAD=/path/to/library.so program args ...
This file is in the public domain.
*/
@nielsvanvelzen
nielsvanvelzen / jf-dev-auth.md
Last active May 6, 2024 03:07
Jellyfin API Authorization

Jellyfin API Authorization

To start using the Jellyfin API, authorization is probably the first thing you'll need to do. Jellyfin's authorization options can be a bit confusing because there are a lot of deprecated options.

Generally there are three ways to authenticate: no authorization, user authorization with an access token or authorization with an API key. The first way is easy, just do nothing. But most often you'll need to use either the access token or API key.

Sending authorization values

There are multiple methods for transmitting authorization values, however, some are outdated and scheduled to be removed. It's recommend to use the Authorization header. If header auth isn't an option, the token may be sent through the ApiKey query parameter. Sending secure data in a query parameter is unsafe as the changes of it leaking (via logs, copy-paste actions or by other means) are high. Only use this method as a last resort.

@vladbabii
vladbabii / mount_x.service
Created January 29, 2018 16:54
Systemd run script after mount
# original: https://askubuntu.com/questions/25071/how-to-run-a-script-when-a-specific-flash-drive-is-mounted
# you can find your device unit with: sudo systemctl list-units -t mount
# put this into /etc/systemd/system/your.service
[Unit]
Description=SharedMountTrigger
Requires=mnt-shared.mount
After=mnt-shared.mount
[Service]
@swarminglogic
swarminglogic / watchfile.sh
Last active March 4, 2024 14:44
watchfile - monitor file(s) and execute a command when files are changed
#!/bin/bash
version=1.0.1
versionDate="2014-02-14"
function showHelp() {
echo "watchfile - monitor file(s)/command and perform action when changed
Possible ways of usage
----------------------------------------
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@damienrg
damienrg / git-multi-hook-template
Last active November 24, 2023 14:22
Script to allow multi hooks per hook type for git
#!/usr/bin/env bash
# Allow multiple hooks.
#
# To use it copy this script with executable permission in ".git/hooks/hook-name"
# where hook-name is the name of the hook (see man githooks to know available hooks).
# Then place your scripts with executable permission in ".git/hooks/hook-name.d/".
hook_type=${BASH_SOURCE##*/}
@lypanov
lypanov / elinkify.rb
Created January 9, 2020 22:46
Post-process step using elinks -dump to create OSC-8 style hyperlinked terminal output
require "json"
require "pp"
state = false
references_raw, content = *(`elinks -dump /tmp/dump4`.lines.partition { |line| state = true if line == "References\n" ; state } )
content_began, delayed_link = false, nil
references = references_raw.inject({}) do |hsh, line|
if line =~ /Visible links$/
content_began = true
next hsh
@jimschubert
jimschubert / README.md
Last active October 30, 2023 01:33
prepare-commit-msg which adds branch name and description to the end of a commit message (git hook)

Installation

To install globally, copy prepare-commit-msg to /usr/local/share/git-core/templates/hooks and execute:

chmod +x /usr/local/share/git-core/templates/hooks/prepare-commit-msg

To install per-repository, copy prepare-commit-msg to /path/to/repo/.git/hooks/prepare-commit-msg and mark it as executable.

#!/bin/bash
#updated ffmpeg progress indicator
#by Rupert Plumridge
#for updates visit www.prupert.co.uk
#Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales Licence
# Based on the ffmpegprogress bar from: http://handybashscripts.blogspot.com/2011/01/ffmpeg-with-progress-bar-re-work.html
# which was based on my initital progress script - circle of life and all that ;)
# version 2.0
# 07.04.2011
# now uses apparently better progress detection, based on duration of overall video and progress along the conversion