Skip to content

Instantly share code, notes, and snippets.

@dougpagani
dougpagani / .muttrc
Created June 8, 2018 16:02 — forked from shreeshga/.muttrc
mutt rc file
# A basic .muttrc for use with Gmail
# Change the following six lines to match your Gmail account details
set imap_user = "shreesh@kayak.com"
set copy=yes
set smtp_url = "smtps://shreesh@kayak.com@smtp.gmail.com:465/"
set from = "shreesh@kayak.com"
set realname = "shreesh ayachit"
# Change the following line to a different editor you prefer.
@dougpagani
dougpagani / grab_gh_password.py
Created August 27, 2018 04:34
Get macOS password from the 'security' command in python
import subprocess
import re
# Grab password from macOS keychain
def grab_gh_password():
invocation = ['security', 'find-internet-password', '-gs', 'github.com']
block = subprocess.Popen(invocation, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
lastline = block.stderr.read().strip().decode("utf-8")
parsed_password = re.sub('password: "(.*)"', '\\1', lastline)
return parsed_password
@dougpagani
dougpagani / timo-make.sh
Created November 27, 2018 15:15
Facilitated Teamocil.yml file creation
#!/usr/bin/env bash
# FILE: timo-make.sh
# readline for facilitating
set -euo pipefail
############################################################
#{{{ Helpers
tmuxdims ()
{
local WINDEX=${1:-$(tmux display-message -p '#I')};
tmux list-windows | \grep -i "^${WINDEX}" | cut -f 3- -d'[' | sed 's/layout //' | sed 's/ @.*//' | sed 's/.$//'
@dougpagani
dougpagani / posix-commandline-processing.sh
Last active January 19, 2019 21:03
Quick Cheatsheets when debugging bash command line construction
# https://bashrules.blogspot.com/2006/04/bash-order-of-expansions.html
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html
alias bashexpandorder='echo '\''
1. {} brace
2. ~ tilde
3. $VAR parameter & variable
4. $() command-substitution
5. $(()) arithmetic expansion
6. (IFS) word-splitting
7. * ? [ filename expansion (-f will disable)
@dougpagani
dougpagani / typify-file.sh
Created January 19, 2019 20:58
Ask what "tf" is up with this cmd, which is often a symlinked-file (think brew Cellars). Also good for getting to a python-cli wrapper's lib dir.
typify-file ()
{
opwd="$PWD";
type -a "$1";
cmdpath=$(type -P "$1");
if ( test -e "$cmdpath" ); then
count=0;
while ( test -L "$cmdpath" ); do
(( count++ ));
linkrelative=$(readlink -n "$cmdpath");
#!/bin/bash
unset PASSWORD
unset CHARCOUNT
echo -n "Enter password: "
stty -echo
CHARCOUNT=0
@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
@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 / 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 / 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