Skip to content

Instantly share code, notes, and snippets.

@egladman
egladman / generate-m3u.sh
Created April 5, 2023 01:56
Create m3u playlist for multi disk media/games
#!/bin/bash
set -eu
# Usage: ./generate-m3u.sh <path/to/dir>
# Creates a .m3u playlist for media/games that have one .cue/.bin file per disk
# Expects the following directory structure
# FooBarBaz
@egladman
egladman / aws-vault
Created May 27, 2022 18:48
aws-vault shim
#!/usr/bin/env bash
set -e
# Shim for aws-vault that supports overriding sso_role_name via environment
# variable. Install to ~/.local/bin/aws-vault for best results.
# If environment variable AWS_SSO_ROLE_NAME is set, then a copied/modified
# to use the desired sso_role_name. The original aws config is never touched.
@egladman
egladman / mvp.sh
Last active June 10, 2021 13:54
Move a file, and create the destination directory if it doesn't exist
#!/bin/sh
# Usage: mvp <src> <dest>
# Move a file, and create the destination directory if it doesn't exist
__dirname() {
# Usage: dirname "path"
# https://github.com/dylanaraps/pure-sh-bible
@egladman
egladman / parse_ini_example.sh
Created June 24, 2020 13:46
parse ini files with pure bash. Read more about it here: eli.gladman.cc/blog/2020/06/23/parsing-ini-file-with-bash.html
parse_ini() {
# Usage: parse_ini "path/to/file"
# parse_ini "path/to/file" false
# By default variables will be evaluated. Disable this by passing in "false"
local regex_contains_variable="^([a-zA-Z0-9_]{1,})([[:space:]]\=[[:space:]])(.*)$"
local regex_contains_wrapped_quotes="^([\"\'])(.*)([\"\'])$"
local regex_contains_inside_quotes="^([\"])(.*)([\"])(.*)([\"])$"
From 1a74985b2a404639b08882c57f3147229605dfd5 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 19 Apr 2016 06:50:31 -0400
Subject: [PATCH] extlinux: pull in sys/sysmacros.h for major/minor/makedev
https://wiki.syslinux.org/wiki/index.php?title=Building
These functions are defined in sys/sysmacros.h, so add the include to
main.c. This is already handled correctly in mountinfo.c. Otherwise
we get build failures like:
@egladman
egladman / roundedcube.scad
Created November 22, 2019 01:48 — forked from groovenectar/roundedcube.scad
roundedcube.scad - Fork me and make me better!
// More information: https://danielupshaw.com/openscad-rounded-corners/
// Set to 0.01 for higher definition curves (renders slower)
$fs = 0.15;
module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") {
// If single value, convert to [x, y, z] vector
size = (size[0] == undef) ? [size, size, size] : size;
translate_min = radius;
@egladman
egladman / roundedcube.scad
Created November 22, 2019 01:48 — forked from groovenectar/roundedcube.scad
roundedcube.scad - Fork me and make me better!
// More information: https://danielupshaw.com/openscad-rounded-corners/
// Set to 0.01 for higher definition curves (renders slower)
$fs = 0.15;
module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") {
// If single value, convert to [x, y, z] vector
size = (size[0] == undef) ? [size, size, size] : size;
translate_min = radius;
@egladman
egladman / extractFrames.js
Last active May 30, 2018 22:09
Extract all frames of a gif to their respective images
// Quick and dirty script that I'll only use once...
// Grabs all the frames in a gif and write them to individual files
//
// Example
// node extractFrames.js --gif path/to/gif
const gifFrames = require('gif-frames');
const argv = require('yargs').argv
const fs = require('fs');

Cuddled

if (condition) {
  //stuff
} else {
  //stuff
}
@egladman
egladman / git_approval.sh
Created February 12, 2017 21:47
Prevent accidental changes from being committed to git
#Append the following snippet to your bash.rc
#Whenever "git add foo" is ran "git diff" will first run
#and require user confirmation before changes are added.
git() {
if [[ $1 == "add" ]]; then
command git diff
read -p "Are you sure? " -n 1 -r
echo