Skip to content

Instantly share code, notes, and snippets.

@ajkerrigan
ajkerrigan / hide_cols_right.py
Last active July 9, 2020 04:17
VisiData - Hide non-key columns to the right
from visidata import TableSheet
@TableSheet.api
def hide_cols_right(sheet, idx):
for col in (c for c in sheet.visibleCols[idx + 1:] if not c.keycol):
col.hide()
TableSheet.addCommand(
"gz-",
"hide-cols-right",
@ajkerrigan
ajkerrigan / README.md
Created June 4, 2020 05:08
Some VS Code settings for debugging VisiData

VS Code's Python extension does a lovely job of debugging VisiData. I run it one of two ways:

  • When I'm working on a specific task, I add a specific run string to launch.json to start it. I typically run VisiData inside the integrated terminal.
  • For more ad-hoc/exploratory stuff, I'll start VisiData from tmux and use VS Code's process picker to attach it.

Key pieces that need to be in place for this to work:

  • Have VisiData and all dependencies installed into a virtual environment, and activate that virtual environment in VS Code.
  • Make sure VisiData is installed with -e so your breakpoints work.
@ajkerrigan
ajkerrigan / bookmarklet.md
Created May 13, 2020 05:08
Export Jukebox.Today Queue + History

Add a bookmark using this code as the location. Click to pop up an alert box with a crude CSV of the current queue + history.

javascript:(() => { histitems = []; document.querySelectorAll('.jukebox__item').forEach((item) => { histitem = []; item.querySelectorAll('div[class^="item"]').forEach((child) => { histitem.push('"' + child.innerText.replace(/"/g, '""') + '"'); }); histitems.push(histitem.join(',')); }); alert(histitems.join("\n")); })()
@ajkerrigan
ajkerrigan / .visidatarc.py
Last active March 8, 2020 17:56
VisiData - Auto-prompt for zip passwords
import zipfile
from functools import wraps
from visidata import vd
def open_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except RuntimeError as err:
@ajkerrigan
ajkerrigan / vdhash.py
Created January 19, 2020 19:15
vdhash.py
#!/usr/bin/env python3
import hashlib
import sys
from pathlib import Path
if len(sys.argv) != 2:
print(f'Usage: {sys.argv[0]} <file>')
sys.exit(1)
try:
@ajkerrigan
ajkerrigan / tmux.conf
Created October 11, 2019 13:39
My tmux.conf
unbind-key C-b
set-option -g prefix C-a
bind-key a send-prefix
# Pane Controls
#
# Everything revolves around vim directional keys: h/j/k/l
#
# <prefix>-<direction>: Resize pane one row/col at a time
# <prefix>-shift-<direction>: Resize by 5 rows/cols at a time
@ajkerrigan
ajkerrigan / karabiner.json
Created October 11, 2019 04:19
Karabiner Elements Config Sample
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@ajkerrigan
ajkerrigan / keybase.md
Created August 22, 2019 01:13
keybase.md

Keybase proof

I hereby claim:

  • I am ajkerrigan on github.
  • I am ajkerrigan (https://keybase.io/ajkerrigan) on keybase.
  • I have a public key ASCDswQsTprea3Fr88V8su3Yd0MbqLoMrUyJhPEPEEOQXQo

To claim this, I am signing this object:

@ajkerrigan
ajkerrigan / AWS User Info Bookmarklet.md
Created August 6, 2019 16:55
AWS User Info Bookmarklet

Current User Info Bookmarklet for the AWS Console

When logged into the AWS web console it can be helpful to quickly see details of your current identity. This can include:

  • An ARN
  • Your current account alias
  • Issuer info, indicating tools such as aws-vault
  • Your username, which may include a role session name

This bookmarklet is a simple way to parse that information out of the aws-userInfo cookie and return it as pretty printed JSON.

@ajkerrigan
ajkerrigan / s3_search.py
Last active March 19, 2024 03:04
Use S3 Select the ugly way
#!/usr/bin/env python3
"""
Search files in S3 similar to grep.
Use S3 Select with intentionally broad CSV parameters to make
it behave more like naive grep. This enables it to be used more
effectively on data which is malformed or unpredictably structured
without requiring a pre-processing step.
Reference: https://aws.amazon.com/blogs/aws/s3-glacier-select/