Skip to content

Instantly share code, notes, and snippets.

View mej's full-sized avatar

Michael Jennings mej

  • Los Alamos National Laboratory
  • Los Alamos, NM
  • 17:26 (UTC -07:00)
  • X @mej0
View GitHub Profile
@mej
mej / errno.py
Created October 29, 2024 18:05
Python script to create Bash hashmaps for, and/or provide translations among, `errno`, symbolic error identifiers, and `strerror()`-provided error strings
#!/bin/python3
### -*- Mode: Python; fill-column: 132; comment-auto-fill-only-comments: t; tab-width: 4; eval: (local-set-key "\C-i" 'indent-according-to-mode); eval: (auto-fill-mode 1); -*-
#
# Map `errno` names or codes to num+name+strerror tuples and/or generate Bash
# arrays that do the same mappings. For use in MEJSH, NHC, and/or daily life.
#
# Michael Jennings <mej@lanl.gov>
# 23 Sep 2024
#
@mej
mej / Advanced-setup.md
Created February 5, 2024 22:23 — forked from nandordudas/00-setup.md
Setup WSL 2 on Windows 11

Install [Scoop] a command-line installer for Windows

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iex "& {$(irm get.scoop.sh)} -ScoopDir ${Env:USERPROFILE}\Scoop"
scoop install git
scoop bucket add extras
scoop install delta exiftool
@mej
mej / test-args
Created April 6, 2023 23:47
Argument-quoting Testing Tool & Output
#!/bin/bash -x
set -- "This... " This "can't" \*really\* be a '<bleep>ing' "\"test,\"" can it\?$'\n'
OFFLINE_NODE="echo -e -n"
exec >$0.out 2>$0.err
TESTSTR="$*"
printf 'Beginning testing; test string is: "%s"\n' "${TESTSTR}"
@mej
mej / extract_cookies.sh
Created March 9, 2022 23:18 — forked from hackerb9/extract_cookies.sh
Extract cookies.sqlite to cookies.txt for use in wget or curl.
#!/bin/sh -e
# extract_cookies.sh:
#
# Convert from Firefox's cookies.sqlite format to Netscape cookies,
# which can then be used by wget and curl. (Why don't wget and curl
# just use libsqlite if it's installed?)
# USAGE:
#
# $ extract_cookies.sh > /tmp/cookies.txt
@mej
mej / Vagrantfile
Last active January 13, 2020 19:24
Vagrantfile for LANL Docker class
# -*- mode: ruby -*-
# vi: set ft=ruby :
#### Check https://goo.gl/9N7e3S for the latest version of this gist!
#
#### Installs Docker, Charliecloud, and Mezzanine by default during provisioning. Run:
#### $ vagrant up
#### To connect to the VM and play around with the above software, simply run:
#### $ vagrant ssh
#### Then, to build, convert, and test several example containers with Charliecloud, use:
#### $ vagrant provision --provision-with ctr-build,ctr-install,ch-test
@mej
mej / .gitconfig
Last active October 15, 2024 21:20
mej's .gitconfig
### -*- Mode: conf-toml; fill-column: 80; comment-auto-fill-only-comments: t; tab-width: 4; eval: (local-set-key "\C-i" 'indent-according-to-mode) -*-
################################################################################
# Git Configuration
#
# Michael Jennings <mej@eterm.org>
# 15 Mar 2013
#
# Evolved over time and cobbled together from innumerable sources.
#
################################################################################
@mej
mej / Vagrantfile
Last active January 9, 2020 18:34
Vagrantfile for Charliecloud VM
# -*- mode: ruby -*-
# vi: set ft=ruby :
#### Check https://goo.gl/9N7e3S for the latest version of this gist!
#
#### Installs Docker, Charliecloud, and Mezzanine by default during provisioning. Run:
#### $ vagrant up
#### To connect to the VM and play around with the above software, simply run:
#### $ vagrant ssh
#### Then, to build, convert, and test several example containers with Charliecloud, use:
#### $ vagrant provision --provision-with ctr-build,ctr-install,ch-test
@mej
mej / nsrun.c
Last active May 21, 2016 01:47
A small program to wrap namespace creation
#define _GNU_SOURCE
#define _BSD_SOURCE
#include <errno.h>
#include <sched.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mount.h>
@mej
mej / mac_to_ipv6.bash
Created August 18, 2015 18:53
[BASH] Function to convert MAC address to IPv6 link-local address
mac_to_ipv6() {
local HWADDR="$1" IFACE="$2"
local -a OCTETS
local IPV6ADDR
if [[ -z "$IFACE" ]]; then
IFACE=$(ip route | grep ^default | sed 's/^.* dev //')
fi
OCTETS=( ${HWADDR//:/\ } )
OCTETS[0]=$(printf %02x $((16#${OCTETS[0]}+0x02)))
@mej
mej / command.sh
Last active August 29, 2015 14:27
[P1L] Alphabetize non-system group members in /etc/group (in-place edit)
perl -ni.presort -e '@F = split /:/; $F[3] = join(",", sort(grep{$_}split(",", (chomp($F[3]),$F[3]))))."\n" if ($F[2] >= 100); print join(":", @F);' /etc/group