Skip to content

Instantly share code, notes, and snippets.

@z11i
z11i / waitForKeyElements.js
Last active June 11, 2021 12:51 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@z11i
z11i / check-aws-sso.sh
Last active June 6, 2023 01:28
Auto check AWS SSO credentials validity, and login if invalid. You can set this as a cronjob.
#!/usr/bin/env bash
PROFILE=${PROFILE:-my-profile-to-use}
AWS=/opt/homebrew/bin/aws
SSO_ACCOUNT=$($AWS sts get-caller-identity --query "Account" --profile "$PROFILE")
# kill existing pending sessions
pgrep -f 'aws sso login' | xargs kill
if [ ${#SSO_ACCOUNT} -eq 14 ]; then # 14 because 2 quotes + 12-digit account number
exit 0