Skip to content

Instantly share code, notes, and snippets.

View AdamGagorik's full-sized avatar

Adam Gagorik AdamGagorik

View GitHub Profile
#!/usr/bin/env bash
INP=main.tex
OUT=main.docx
REF=reference.docx
if [[ $# -ge 1 ]]; then
INP="${1%.*}.tex"
OUT="${1%.*}.docx"
fi
@AdamGagorik
AdamGagorik / zcon
Created October 25, 2023 15:02
Helper function for editing zshrc
#!/usr/bin/env bash
function zcon() {
time_0=`date -r ~/.zshrc`
nvim ~/.zshrc
time_1=`date -r ~/.zshrc`
echo $time_0
echo $time_1
@AdamGagorik
AdamGagorik / brew-pyenv.sh
Last active October 18, 2023 15:02
Compile pyenv python using brew OpenSSL
CPPFLAGS="-I$(brew --prefix [email protected])/include" LDFLAGS="-L$(brew --prefix [email protected])/lib" pyenv install -v 3.10.13
@AdamGagorik
AdamGagorik / gist
Last active April 23, 2024 14:56
Interactive gh gist callback
#!/usr/bin/env python3
"""
EXTRAS
path: Get path of local clone
link: Register a gist locally
sync: Sync all registered gists
debug: Debug script configuration
status: Get status of registered gists
select: Select a gist using fuzzy finder
attach: Attach a gist to the local registry
@AdamGagorik
AdamGagorik / nightly
Last active April 20, 2024 21:23
cron script to update brew and python
#!/usr/bin/env bash
set -e
######################################################################
NOT_FOUND="EXECUTABLE NOT FOUND"
get_first_path() {
for path in "$@"; do
if [ -e "$path" ]; then
@AdamGagorik
AdamGagorik / example.cron
Last active October 18, 2023 15:02
cron.txt
0 0 * * * /usr/local/bin/timeout -s 9 3600 /Users/adam/bin/nightly
0 0 * * * /usr/local/bin/timeout -s 9 3600 /Users/adam/bin/nightly >> /Users/adam/log/nightly.log 2>&1
@AdamGagorik
AdamGagorik / rfv
Last active October 18, 2023 15:03
#!/usr/bin/env bash
# 1. Search for text in files using Ripgrep
# 2. Interactively narrow down the list using fzf
# 3. Open the file in Vim
IFS=: read -ra selected < <(
rg --color=always --line-number --no-heading --smart-case "${*:-}" |
fzf --ansi \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
#!/usr/bin/env bash
pandoc -N \
--variable "geometry=margin=0.75cm" \
--variable mainfont="Palatino" \
--variable sansfont="Helvetica" \
--variable monofont="Menlo" \
--variable fontsize=10pt \
--variable version=2.0 \
--from=gfm "$1.md" \
--pdf-engine=xelatex \
#!/bin/bash
function usage() {
echo "usage: $0 start|stop"
}
if [[ $# -ne 1 ]] || [[ -z $1 ]]; then
usage
exit -1
fi
echo "# ping"
ping -q -w1 -c1 google.com &>/dev/null && echo online || echo offline
echo ""
echo "# scutil"
scutil -r google.com