Skip to content

Instantly share code, notes, and snippets.

View thatguychrisw's full-sized avatar

Christopher Willard thatguychrisw

View GitHub Profile
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
@thatguychrisw
thatguychrisw / thatguychrisw.terminal
Created June 5, 2017 12:06
thatguychrisw.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjEyOTQxMTc3MTkgMC4xMjk0MTE3NzE5IDAuMTI5NDExNzcxOQAQAoAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@thatguychrisw
thatguychrisw / wait-for-db.sh
Created January 17, 2018 21:18
Will keep trying indefinitely till a postgres database is available, helpful when scripts depend on docker-compose up
+#!/bin/bash
+
+if [ "$#" -lt 2 ]; then
+ echo "Usage: wait-for-db.sh [host] [port] [database]"
+ exit 1
+fi
+
+host="$1"
+port="$2"
+database="$3"
@thatguychrisw
thatguychrisw / ifttt_toggle_device_state.sh
Last active December 26, 2019 15:12
Shell script to toggle a device using a smart switch
# In IFTTT create two webhooks named using the pattern, "$DEVICE_on" and "$DEVICE_off"
DEVICE="desk_fan"
# This is where the state of the device is kept
DEVICE_STATE_FILE=~/.${DEVICE}.state
IFTTT_KEY=""
# Set the default state of the device to "off" if the status file does not exist
[ -s $DEVICE_STATE_FILE ] || echo "off" > $DEVICE_STATE_FILE
@thatguychrisw
thatguychrisw / lower-case-object-values-functional.js
Last active October 17, 2020 17:23
A functional approach to lower casing object values
import { expect } from 'chai'
const lowerCaseValues = (object, paths) =>
Object.assign(lowerCaseObjectValues(object), partialObject(object, paths))
const lowerCaseObjectValues = object => {
return Object.entries(object).reduce((updated, [key, value]) => {
const isString = typeof value === 'string'
const isObject = typeof value === 'object'