Skip to content

Instantly share code, notes, and snippets.

View benjaminapetersen's full-sized avatar
👾

Ben Petersen benjaminapetersen

👾
View GitHub Profile
@benjaminapetersen
benjaminapetersen / .vimrc
Created June 18, 2024 19:36 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@benjaminapetersen
benjaminapetersen / homebrew-gnubin.md
Created June 18, 2024 17:11 — forked from skyzyx/homebrew-gnubin.md
Using GNU command line tools in macOS instead of FreeBSD tools

macOS is a Unix, and not built on Linux.

I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.

Homebrew

Homebrew can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.

authors:
rr: Ryan Richard; richardry
ak: Andrew Keesler; akeesler
mk: Monis Khan; mok
ap: Aram Price; pricear
mm: Matt Moyer; moyerm
mc: Margo Crawford; margaretc
email:
domain: vmware.com
global: true
[core]
# pager = delta
[interactive]
# diffFilter = delta --color-only
[delta]
side-by-side = true
#syntax-theme = Dracula
# Generated by Powerlevel10k configuration wizard on 2020-09-12 at 21:53 PDT.
# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 49789.
# Wizard options: nerdfont-complete + powerline, small icons, classic, unicode, dark,
# 12h time, angled separators, sharp heads, flat tails, 2 lines, disconnected, no frame,
# compact, many icons, concise, transient_prompt, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export PATH=$HOME/go/bin:$PATH
# On linux also add the path to brew and a place to put chromedriver...
if [[ "$OSTYPE" != "darwin"* ]]; then

Laptop Setup Tips

Moving from an older laptop? Bring these files over.

  • In Safari, "File -> Export -> Bookmarks"
  • Make a copy of ~/.zsh_history
  • Make a copy of github public and private keys from ~/.ssh or wherever you kept them
  • Check your Downloads folder for anything worth keeping

Helpful Brew Casks

@benjaminapetersen
benjaminapetersen / jsonpath.md
Created May 27, 2022 20:05 — forked from navicore/jsonpath.md
for getting multiple fields from kubectl via jsonpath

get name and image and startTime

kubectl get pods -ao jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.spec.containers[*].image}{" "}{@.status.phase}{" "}{@.status.startTime}{"\n"}{end}'| grep track
#!/usr/bin/env bash
VERSION="$1"
VERSION="${VERSION#[vV]}"
VERSION_MAJOR="${VERSION%%\.*}"
VERSION_MINOR="${VERSION#*.}"
VERSION_MINOR="${VERSION_MINOR%.*}"
VERSION_PATCH="${VERSION##*.}"
echo "Version: ${VERSION}"
@benjaminapetersen
benjaminapetersen / trap_focus.js
Created December 17, 2020 22:26 — forked from myogeshchavan97/trap_focus.js
Code for trapping focus inside modal
// add all the elements inside modal which you want to make focusable
const focusableElements =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
const modal = document.querySelector('#exampleModal'); // select the modal by it's id
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
const focusableContent = modal.querySelectorAll(focusableElements);
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal