Skip to content

Instantly share code, notes, and snippets.

ssh-isolate-access() {
cat ~/.ssh/id_rsa.pub | command ssh "$@" '
cat > ~/newakeys;
nohup bash -c '"'"'trap "" HUP; echo $$ > ~/killme && sleep 10 && mv -f ~/authorized_keys ~/.ssh/authorized_keys;'"'"' </dev/null &>/dev/null & disown;
mv ~/.ssh/authorized_keys ~/authorized_keys &&
mv ~/newakeys ~/.ssh/authorized_keys;
echo DONE: close connection
'
}
function show-something-cool() {
thing
return 0
}
function asdf() {
return 0
}
# obviously need to modify this, just an example
examples=($(find "$EXAMPLE_FILES_DIR" -iname "*.${extension}"));
PS3='Select which file: ';
select opt in "${examples[@]}";
do
vim "${opt}" && printf "${opt}" | pbcopy && break;
done;
@dougpagani
dougpagani / add-espanso-entry-new.sh
Last active March 4, 2022 01:54
Dylan's Espanso script, before and after
#!/bin/bash
FORM_OUTPUT=$(zenity --forms \
--add-entry "trigger:" \
--add-entry "replacement:" \
--add-combo "word:" --combo-values="false|true" \
--add-combo "propagate case:" --combo-values="true|false")
TRIGGER=$(echo $FORM_OUTPUT | cut -d "|" -f1 | tr -d '[:space:]')
REPLACE=$(echo $FORM_OUTPUT | cut -d "|" -f2 | tr -d '[:space:]')

Keybase proof

I hereby claim:

  • I am dougpagani on github.
  • I am dougpagani (https://keybase.io/dougpagani) on keybase.
  • I have a public key ASDiMu-hDDGoUYTXGi1tF_AbUs6kNlSCiy1LjRPidaFkkAo

To claim this, I am signing this object:

@dougpagani
dougpagani / puppeteer-with-persistent-chromium.js
Created April 11, 2021 04:23
This has quite a few pieces of debugging instrumentation/dead-code, but it has some convenient magic to it.
const WSE_FILE = './.wsaddress'
const fs = require('fs')
// https://stackoverflow.com/questions/12871740/how-to-detach-a-spawned-child-process-in-a-node-js-script
// https://github.com/puppeteer/puppeteer/issues/4061
const LAUNCH_CONFIG = {
headless: false,
// handleSIGHUP: false,
// handleSIGINT: false,
// handleSIGTERM: false,
// args: dontBackgroundArgs
@dougpagani
dougpagani / 0-helper-thunks.js
Last active April 12, 2021 13:25
MEAT & POTATOES: Trying out an idea of using closure-leveraging nested snippets for enhancing readability (name == hoisted helpers?)
// does not work because-hoisting.js
function calculateWinnerRecursion(squares, possibleWinConditions) {
if (noMorePossibleWinConditions()) { return null }
if (winConditionIsMet()) { return theWinner() }
return SELF(squares, possibleWinConditions.shift()))
@dougpagani
dougpagani / new.js
Created March 18, 2021 18:44
comparing http error handlers
export async function uploadFileToS3(part, projectNumber, partNumber, attachmentBool, failureHandler) {
try {
// send http request to file-handler server
var requestResult = await uploadFileToS3Request(part, projectNumber, partNumber, attachmentBool)
// return the response of file-handler upload
return parseUploadFileToS3Response(requestResult)
} catch(error) {
failureHandler(part, projectNumber, partNumber, attachmentBool, requestResult, error)
}
@dougpagani
dougpagani / alias-last.sh
Created December 20, 2020 22:32
makes an alias of the last commandline, escaping properly & allowing for review (I have not reviewed this so use at your own risk)
# This function avoids having to:
# - vim into the right file
# - write out the alias syntax
# - quote a commandline's embedded quotes, which can get rather gnarly
# - reformat from line-squashing
# - add negative numbers (will auto-convert)
# TODO: Bug with aliasing THIS line: sed 's/\ -/ \\\n\t\-/g'
function aliaslast() {
#APPEND_LOCATION=~/.bp_local
if [[ -f ~/dotfiles/frags/bp_scratch ]]; then