Skip to content

Instantly share code, notes, and snippets.

View troglobit's full-sized avatar
🎯
Focusing

Joachim Wiberg troglobit

🎯
Focusing
View GitHub Profile
@troglobit
troglobit / howto-use-dd.md
Last active January 20, 2024 14:24
HowTo use dd to write a disk image/iso to USB on Linux

The UNIX utility dd is actually inherited from VMS, hence the opt=arg instead of --opt=arg syntax.

Here we write the input file (if) to the output file (of), using a larger block size (bs) than default (512 bytes). We'd like to see the progress of the write, this is not the default, and we want to avoid caching in the Linux VFS, so we set output flag (oflag) to direct, i.e. write-through.

sudo dd if=linuxmint-20-cinnamon-64bit.iso of=/dev/sdb bs=1M status=progress oflag=direct

Watch out, check the output file (/dev/sdb) matches your USB stick, otherwise you'll kill all the kittens!

@troglobit
troglobit / linux-leds.md
Created October 19, 2023 16:22
Blinking LEDs in Linux

Blinking LEDs in Linux

First check you have the timer trigger loaded:

root@gimli:~# lsmod |grep led
snd_ctl_led            24576  0
input_leds             16384  0
snd                   135168  45 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_sof,snd_timer,snd_compress,thinkpad_acpi,snd_soc_core,snd_pcm,snd_rawmidi
soundcore              16384  2 snd_ctl_led,snd
@troglobit
troglobit / shell-script-tips.md
Last active May 12, 2023 14:17
Shell Scripting Tips

Debug a script callback to console

exec >/dev/console 2>&1
set -x

Ignore error on a particular line in set -e

possibly-failing-command ||:

Redirect STDERR to STDOUT

@troglobit
troglobit / runonce.lua
Created May 3, 2021 00:57
Fixed runonce.lua for AwesomeWM
-- @author Peter J. Kranz (Absurd-Mind, peter@myref.net)
-- Any questions, criticism or praise just drop me an email
local awful = require("awful")
local M = {}
-- get the current Pid of awesome
local function getCurrentPid()
-- get awesome pid from pgrep
@troglobit
troglobit / unicode-in-emacs.md
Created December 19, 2022 16:24
Unicode in Emacs
grep Vm /proc/$(ps aux | grep inadyn |head -1 |awk '{print $2}')/status
@troglobit
troglobit / mping-howto.md
Created May 23, 2022 08:10
Using mping to script multicast switching/routing verification

HowTo: using mping for (fun and) profit

Ever since I started working with multicast back in the early 2000's, I've had to make my own tools. There weren't that many useful ones available, at least not in the Open Source space where I worked.

The first tool made, mcjoin, was based on an example an IBM'er had made public. I used that, the standard ping(1) tool, and tcpdump(1), to check my multicast flows.

@troglobit
troglobit / libnl-debug.md
Last active April 22, 2022 14:10
Developing and debugging libnl

Developing & debugging libnl

When I started out learning about libnl, around 10 years ago, I did not fully understand it. Mostly because I didn't (want to) understand Netlink. A great way to learn something is to try to fix a bug, or develop a new feature, because then you will want to write both tests and demo applications, which you may end up having to debug! Debuggers give you backtraces, which will help you understand how your program works.

Note: for debugging embedded systems using gdb-server, see the following blog post I wrote

@troglobit
troglobit / local.mk
Created April 5, 2022 08:50
Buildroot local.mk extensions and overrides
#BR2_ROOTFS_OVERLAY := $(BR2_ROOTFS_OVERLAY) $(BR2_EXTERNAL_NETBOX_PATH)/jocke
LINUX_OVERRIDE_SRCDIR = /home/jocke/src/linux
#IPROUTE2_OVERRIDE_SRCDIR = /home/jocke/src/iproute2
#MDIO_TOOLS_OVERRIDE_SRCDIR = /home/jocke/src/github.com/jocke/mdio-tools
#MDIO_TOOLS_AUTORECONF = YES
#PLY_OVERRIDE_SRCDIR = /home/jocke/src/github.com/jocke/ply
#PLY_AUTORECONF = YES
#TCPDUMP_OVERRIDE_SRCDIR = /home/jocke/src/github.com/the-tcpdump-group/tcpdump
#LIBPCAP_OVERRIDE_SRCDIR = /home/jocke/src/github.com/the-tcpdump-group/libpcap
@troglobit
troglobit / ANSI.md
Created January 18, 2022 06:33 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27