Skip to content

Instantly share code, notes, and snippets.

View troglobit's full-sized avatar

Joachim Wiberg troglobit

View GitHub Profile
@fergiemcdowall
fergiemcdowall / README.md
Last active March 8, 2025 10:51
How to use pandoc to generate HTML from GitHub-flavoured markdown

Here is a little recipe for generating html from github-flavoured markdown. CSS extracted and modified from https://github.com/sindresorhus/github-markdown-css on 22-05-2019. At some point this CSS will probably have to be updated, but for now it works.

  1. Install pandoc 2.x or higher

  2. Save github-markdown.css (below) to ´~/.pandoc/github-markdown.css´

  3. To convert a file called README.md (change as appropriate) run ´pandoc --standalone -c ~/.pandoc/github-markdown.css -f gfm -t html README.md´

@ryukinix
ryukinix / lock.sh
Last active March 24, 2023 13:46
How lock your system before suspend with openrc init via elogind using slock
#!/bin/sh
#
# /lib/elogind/system-sleep/lock.sh
# Lock before suspend integration with elogind
username=lerax
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0.0"
@fnky
fnky / ANSI.md
Last active May 20, 2025 08:24
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@umohi
umohi / download-github-artifact
Created September 21, 2018 22:48
use curl to download release artifact from github private repository
# in order to download release artifacts from github, you have to first retreive the
# list of asset URLs using the github repo REST API. Use the asset URL to download
# the artifact as a octet-stream data stream. You will need to get an access token
# from "settings -> developer settings -> personal access tokens" on the github UI
#!/bin/bash -e
owner="MY_ORG_NAME"
repo="MY_REPO_NAME"
tag="ARTIFACT_TAG"
artifact="ARTIFACT_NAME"

In a terminal start a server.

$ python -m SimpleHTTPServer 8000

In another terminal set up the cgroups freezer.

@wkz
wkz / sniff.sh
Created April 28, 2018 15:02
Mirror a set of interfaces to a sniffer interface, ignoring 802.1Q tag information.
#/!bin/sh
# usage: sniff.sh <interface> [<interface>...]
# create a dummy to mirror all traffic to
ip link add dev sniffer type dummy
ip link set dev sniffer up
# intermediate dummy, needed because AF_PACKET-sockets gets the packet
# as seen before any tc-actions have been applied to it.
ip link add dev untag type dummy
@OndraZizka
OndraZizka / switchHeadphones.sh
Last active May 29, 2024 13:43
Bluetooth headset - switch between quality sound + no mic (A2DP) and crappy sound and mic (HSP/HFP)
#!/bin/bash
#### Restart Bluetooth
if [ "$1" == "resetBT" ] ; then
sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
exit;
fi;
#### Toggle listen/speak
if [ "$1" == "" -o "$1" == "toggle" ] ; then
@mcastelino
mcastelino / tc mirroring.md
Last active April 29, 2025 12:00
Using tc redirect to connect a virtual machine to a container network

Connecting a veth device to tap

  • veth device from CNI/CNM plugin: eth0
  • tap device that connects to the VM: tap0

Redirecting traffic between the two devices

tc qdisc add dev eth0 ingress
tc filter add dev eth0 parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev tap0
@wkz
wkz / lisp.c
Created October 21, 2017 22:13
/* {
* @t[0] = time();
* @reads[pid()] = quantize(arg2)
* }
*/
prog->ast =
node_expr("",
node_expr("=",
node_expr("[]",
node_ident("@t"),
@xentec
xentec / setup-cross-cc.sh
Last active February 6, 2025 19:49
Alpine Linux cross-compiler setup script
#!/bin/sh
CTARGET="$1"
if [ -z "$CTARGET" ]; then
program=$(basename $0)
echo "usage: $program TARGET_ARCH"
return 1
fi
# get abuild configurables