if (condition) {
//stuff
} else {
//stuff
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="^([\"])(.*)([\"])(.*)([\"])$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
NewerOlder