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 -x | |
## this runs on the Synergy *server* Mac and assumes the *client* is connected via bridge0 | |
## server: 169.254.168.87 ; client: 169.254.168.86 | |
## use e.g. ControlPlane to run the script on wake | |
## brew install terminal-notifier | |
## use ssh-copy-id to enable passwordless ssh from the server to the client | |
## add to /etc/sudoers.d/youruser e.g. $YOUR_USER ALL=(ALL) NOPASSWD: /usr/bin/killall,/sbin/ifconfig | |
## replace $YOUR_USER with your username on the client | |
echo "bouncing Synergy..." | terminal-notifier -title controlplane |
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/local/bin/bash | |
set -eux -o pipefail | |
## this runs on both the client and server Mac | |
## configure CLIENT and SERVER appropriately | |
## brew install terminal-notifier | |
## use with e.g. ControlPlane (launch this script when Thunderbolt network connection becomes active) | |
CLIENT=my-client-mac.local | |
SERVER=the-server-mac.local |
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 | |
##### | |
# usage: just run days-countdown.sh to get a countdown until the default date of October 25 | |
# or specify "from" (e.g. today) and "to" (your target date) in this terrible, terrible format: | |
# days-countdown.sh "$(gdate)" "$(gdate -d 25-Dec)" | |
# result is ~/tmp/days-countdown.png | |
# the png's text color is the hex interpretation of the three-digit days-remaining number ;) | |
# I use Geektool to position the png on my desktop, and run the script in crontab every hour: | |
## 44 * * * * /Users/andrewrich/Documents/scripts/days-countdown.sh >/dev/null 2>&1 | |
# |
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
## path | |
export PATH="/usr/local/opt/ruby/bin:$PATH" | |
## prompt | |
export PS1='\h:\W \u\$ ' | |
## aliases | |
# /etc/sudoers.d/andrewrich: andrewrich ALL=(ALL) NOPASSWD: /sbin/ifconfig | |
alias bouncewifi='sudo ifconfig en0 down && sudo ifconfig en0 up && ifconfig en0' | |
alias brewup='/usr/local/etc/brewupdate.sh' |
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 | |
set -eu -o pipefail | |
about () { | |
cat <<EOF | |
$( basename "$0" ) by Andrew Rich <[email protected]> | |
Based on @cassidoo's interview question from https://tinyletter.com/cassidoo/letters/be-curious-read-widely-try-new-things-what-people-call-intelligence-just-boils-down-to-curiosity-aaron-swartz | |
Definition and table of logic gates: https://whatis.techtarget.com/definition/logic-gate-AND-OR-XOR-NOT-NAND-NOR-and-XNOR | |
EOF |
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 | |
set -eu -o pipefail | |
# shellcheck source=/Users/andrewrich/etc/functions.sh | |
. "$HOME/etc/functions.sh" | |
readonly R="ROCK" P="PAPER" S="SCISSORS" | |
about () { | |
cat <<EOF | |
$( basename "$0" ) by Andrew Rich <[email protected]> | |
Based on @cassidoo's interview question from https://buttondown.email/cassidoo/archive/be-careful-with-your-words-once-they-are-said/ |
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 | |
function htmlValidator () | |
{ | |
if xmllint --noout --nowarning - 2> /dev/null <<< "$1"; then | |
echo "valid"; | |
else | |
echo "not valid"; | |
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
#!/usr/bin/env bash | |
set -eu -o pipefail | |
if [ $# -eq 0 ] || [ -n "$(printf '%s\n' "$1" | sed 's/[0-9]//g')" ]; then | |
echo "$(basename $0): enter a positive integer" | |
exit 1 | |
else | |
echo "$(basename $0): you entered $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
#!/usr/bin/env ruby | |
=begin | |
This week’s question: | |
Given a list of people with their names and the time slots when they are available in a given week, and a meeting length, return the first meeting time available (if possible). Format the input however you’d like to receive it! | |
=end | |
=begin | |
Andrew Rich [email protected] | |
https://projectinsomnia.com/ | |
=end |
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 | |
set -eu -o pipefail | |
# lonelyNumber.sh | |
# @cassidoo 2021-06-06 | |
# Given three numbers, return their product. But, if one of the numbers is the same as | |
# another, it does not count: If two numbers are similar, return the lonely number. If all | |
# numbers are same, return 1. | |
if [ $# -ne 3 ] || ! ([[ $1 =~ ^[0-9]+$ ]] && [[ $2 =~ ^[0-9]+$ ]] && [[ $3 =~ ^[0-9]+$ ]]); then |
OlderNewer