Skip to content

Instantly share code, notes, and snippets.

View stringsn88keys's full-sized avatar

Thomas Powell stringsn88keys

View GitHub Profile
@stringsn88keys
stringsn88keys / change_pass.applescript
Last active April 21, 2022 15:47
"Type" old and new passwords into Windows Server 2016 change password screen when WorkSpaces doesn't allow pasting from your Mac.
#!/usr/bin/osascript
# Usage:
# export OLDPASS="oldpasswordhere!"
# export NEWPASS="newpasswordgoeshere."
# get to change password screen in WorkSpace prior to running this script and make sure you're on the "old password" field.
# run script without args
on sysKeyCode(kc)
tell application "System Events" to key code {kc} using {command down}
@stringsn88keys
stringsn88keys / .zlogin
Last active July 25, 2018 01:55
.zlogin hooks to switch your config back from "production"
function safety_preexec() {
# Store the command that we're running.
CMD_NAME="$1"
}
function safety_precmd() {
if [[ "$CMD_NAME" =~ 'kubectl config use-context whatever-your-prod-is' ]]; then
PROD_TIME=$(date +%s)
@stringsn88keys
stringsn88keys / getuielementsinhipchat.scpt
Created April 8, 2018 00:43
UI Elements debug for the HipChat application
tell application "System Events"
entire contents of process "HipChat" of application "System Events"
-- UI elements of process "HipChat" of application "System Events"
end tell
@stringsn88keys
stringsn88keys / gist:b0bb6ba514e474a364606adbac9bd2a8
Last active April 7, 2018 16:08
AppleScript to track who you're chatting with and save it to a parseable file.
set myFile to open for access (choose file name) with write permission
try
repeat
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
if (frontApp = "HipChat") then
-- set things to entire contents of group 1 of group 1 of group 1 of window 1
-- set things to UI elements of group 1 of group 1 of group 1 of window 1
@stringsn88keys
stringsn88keys / postgres_setup.sh
Created December 7, 2017 15:32
Setting up old version of Postgres via Homebrew
# doh this is a keg-only formula. Had to manually link CLI regardless of install method
# run these to set up
brew tap homebrew/versions
brew install homebrew/versions/postgres94
brew services start postgresql@9.4 export
# in your shell's RC file:
PATH=/usr/local/opt/postgresql@9.4/bin:$PATH
LDFLAGS=-L/usr/local/opt/postgresql@9.4/lib
CPPFLAGS=-I/usr/local/opt/postgresql@9.4/include
@stringsn88keys
stringsn88keys / gosha3.go
Created July 22, 2017 16:31
Go Sha3 hash search, single threaded and with concurrency of 2.
package main
import (
"encoding/base64"
"fmt"
"golang.org/x/crypto/sha3"
"strings"
"time"
)
@stringsn88keys
stringsn88keys / stub_settings.rb
Created July 7, 2017 14:34
Stubbing Rails Settings
# a module included
module StubSettings
def stub_setting(setting_name, setting_value)
allow(Setting).to receive(:[]).with(setting_name).and_return(setting_value)
end
def stub_setting_assignment
allow(Setting).to receive(:[]=) { |setting, value| stub_setting(setting, setting) }
end
end
@stringsn88keys
stringsn88keys / indent.c
Created July 6, 2017 10:57
C indentation styles from wikipedia "Indent Style"
// From https://en.wikipedia.org/wiki/Indent_style
// K & R
while (x == y) {
something();
somethingelse();
}
// 1TBS
if (x < 0) {
puts("Negative");
@stringsn88keys
stringsn88keys / crontab
Created July 3, 2017 17:07
Let's Encrypt crontab
0 0 1 * * /opt/letsencrypt/letsencrypt-auto certonly --quiet --standalone --renew-by-default -d example.com >> /var/log/letsencrypt/letsencrypt-auto-update.log
@stringsn88keys
stringsn88keys / letsencrypt.sh
Created July 3, 2017 17:04
get certs via lets encrypt
#first time setup only
sudo apt-get install git
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# I had to restart apache with a stubbed *.443 section, do this, and then
# add the SSL* directives in.
sudo -H ./letsencrypt-auto certonly --standalone -d example.com