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 / expecting.md
Created May 28, 2021 12:54 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@troglobit
troglobit / rtdump.c
Last active May 3, 2021 09:46
Read IPv4 routes from main routing table in Linux using netlink
/* Read kernel IPv4 routes from main routing table
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@troglobit
troglobit / settings.ini
Created May 3, 2021 01:07
Adwaita Dark mode for Firefox when running plain Awesome
# ~/.config/gtk-3.0/settings.ini
[Settings]
gtk-icon-theme-name = Adwaita-dark
gtk-theme-name = Adwaita-dark
gtk-font-name = DejaVu Sans 11
@troglobit
troglobit / rc.lua
Created May 3, 2021 01:01
.config/awesome/rc.lua
-- Copy from /etc/xdg/awesome/rc.lua to .config/awesome/rc.lua
--
-- My additions
local r = require("runonce")
...
-beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
+beautiful.init(gears.filesystem.get_themes_dir() .. "zenburn/theme.lua")
...
- }, properties = { titlebars_enabled = true }
@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 / .Xresources
Created May 3, 2021 00:55
Xterm setup on Debian 11
Xft.antialias: true
!xterm.termName: xterm-256color
xterm*metaSendsEscape: true
xterm*scrollBar: false
xterm*scrollbar.width: 8
xterm*reverseVideo: on
xterm*renderFont: default
[ 0.243765] PM: Magic number: 13:418:885
[ 0.243832] block2mtd: Using custom MTD label 'Config' for dev /dev/sda
[ 0.867417] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3
[ 0.868154] block2mtd: mtd0: [0] erase_size = 4KiB [4096]
[ 0.868224] printk: console [netcon0] enabled
@troglobit
troglobit / espressobin-uboot.md
Last active January 21, 2021 11:37
EspressoBIN U-Boot defaults and HowTo

Default 1

Marvell>> printenv 
baudrate=115200
bootargs=console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000 root=/dev/mmcblk0p1 rw rootwait net.ifnames=0 biosdevname=0
bootcmd=mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name;ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p1 rw rootwait net.ifnames=0 biosdevname=0; booti $kernel_addr - $fdt_addr
bootdelay=2
console=console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000
eth1addr=00:51:82:11:22:01
@troglobit
troglobit / emacs-over-ssh
Last active September 10, 2020 10:03
Open file in Emacs over SSH
C-x C-f /sshx:amazon:
@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!