This file contains hidden or 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/osascript -l JavaScript | |
// Apple JXA script to create and populate an album with a random sample of favorite photos | |
// Author: @n8henrie | |
// Rename from .applescript.js to .applescript (.js for GitHub syntax highlighting) | |
// https://stackoverflow.com/a/11935263/1588795 | |
function getRandomSubarray(arr, size) { | |
var shuffled = arr.slice(0), i = arr.length, temp, index; | |
while (i--) { | |
index = Math.floor((i + 1) * Math.random()); |
This file contains hidden or 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 python3 | |
import argparse | |
import sys | |
import typing as t | |
__author__ = "Benjamin Kane" | |
__version__ = "0.1.0" | |
__doc__ = f""" | |
Pretty-print simple Bash command from one line of stdin |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 python3 | |
"""Send files to MacOS trash bin via applescript.""" | |
import os | |
from pathlib import Path | |
import sys | |
import subprocess | |
from typing import Iterable, Union | |
def trash(paths: Iterable[Union[str, Path]]) -> int: |
This file contains hidden or 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 -Eeuf -o pipefail | |
if [ ! "$(whoami)" = root ]; then | |
echo "Please run as root" | |
exit 1 | |
fi | |
TMP="$(mktemp -d)" |
This file contains hidden or 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 | |
# http://tonylawrence.com/post/unix/fixing-corrupted-time-machine-backups/ | |
set -euf -o pipefail | |
set -x | |
if [[ $(whoami) != 'root' ]]; then | |
echo "Please run as root" > /dev/stderr | |
exit 1 | |
fi |
This file contains hidden or 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 | |
echo '# Begin n8henrie settings' >> "${HOME}"/.inputrc | |
echo '" Begin n8henrie settings' >> "${HOME}"/.vimrc | |
echo '# Begin n8henrie settings' >> "${HOME}"/.bash_aliases | |
echo '# Begin n8henrie settings' >> "${HOME}"/.bashrc | |
curl 'https://gist.githubusercontent.com/n8henrie/c69de3e3c9d99668965473d1d315c855/raw' >> "${HOME}"/.inputrc | |
curl 'https://gist.githubusercontent.com/n8henrie/3e251bfe9ac9d5ce7421/raw' >> "${HOME}"/.vimrc | |
curl 'https://gist.githubusercontent.com/n8henrie/6cf7785d0ae025e706522e6e64c3fba2/raw' >> "${HOME}"/.bash_aliases |
This file contains hidden or 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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# Reset path (or else it gets longer each time this is sourced) | |
export PATH=$(getconf PATH) | |
# http://unix.stackexchange.com/questions/40678/can-i-make-there-are-stopped-jobs-harder-to-kill | |
prompt_command() { | |
job_count=$(jobs | wc -l | tr -d ' ') | |
if [ $job_count -gt 0 ] ; then | |
prompt_job="[$job_count]" |
This file contains hidden or 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
aur_download() { | |
aur_url="https://aur.archlinux.org$(curl -s "https://aur.archlinux.org/packages/$1" | ack -o "(?<=href=\").*?tar.gz(?=\">)")" | |
echo "$aur_url" | |
read -p "Download the above url? [yn] " response | |
case $response in | |
[Yy]) | |
wget "$aur_url" | |
echo "You still need to do the usual: tar -xvf; cd; makepkg -s; pacman -U;" | |
;; | |
*) |
This file contains hidden or 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 -euf -o pipefail | |
function cleanup { | |
for pid in "${opencv_download_pid:-''}" "${contrib_download_pid:-''}" "${pip_install_pid:-''}"; do | |
if [ -z "${pid}" ]; then | |
kill "${pid}" | |
fi | |
done |