Skip to content

Instantly share code, notes, and snippets.

@ajkerrigan
ajkerrigan / README.md
Last active June 9, 2023 05:18
Passing Data with VisiData Remote Control

Passing Data with VisiData Remote Control

This is a neat discussion thread where a core goal is to send data to an existing VisiData session.

This sample explores one way to do that, combining:

@ajkerrigan
ajkerrigan / README.md
Last active April 19, 2023 14:33
c7n / c7n-left: Owner Tagging Example

Cloud Custodian and c7n-left

Note: This is a lower level, open source / policy-level response to this announcement.

Cloud Custodian allows folks to write policies that help manage cloud resources. c7n-left provides a way to apply Cloud Custodian's policy structure to infrastructure as code (IaC) resource definitions.

Tagging is just one helpful use case here. Consider an organization that expects to use tags to track resource owners. They might use Cloud Custodian to catch and fix

@ajkerrigan
ajkerrigan / README.md
Last active April 11, 2023 12:58
Hacking around on VisiData auto-run commands

VisiData Auto-Run Commands

I've mucked around with the idea of auto-running commands when a sheet opens before. I don't remember which walls I hit, but saulpw/visidata#1681 got me curious to try the idea of a post-load hook in .visidatarc again.

The contents of post_load_hook.py could be dropped directly into a .visidatarc or kept in its own file and imported from .visidatarc.

This is just a sample of course, but seems to work for some common cases at

@ajkerrigan
ajkerrigan / README.md
Last active April 3, 2023 15:57
c7n-left Snippets for VS Code

c7n-left snippets for VS Code

These are user-defined snippets that can remove some manual typing when writing c7n-left policies.

Usage

  • Add a snippet to your VS Code setup.
  • In a code editor, type the trigger prefix (such as pol) and hit Tab to insert the snippet.
@ajkerrigan
ajkerrigan / README.md
Last active March 2, 2023 00:42
Explore Cloud Custodian's Cache with VisiData

Explore Cloud Custodian's Cache with VisiData

By default, Cloud Custodian caches resource data for 15 minutes in ~/.cache/cloud-custodian.cache. This lets you run multiple policies or filters against the same resource data without having to hit cloud provider APIs each time.

Have you ever wanted to look inside that cache? You can!

The cache is a SQLite database, where keys and values are pickle-encoded blobs. We can use VisiData to deserialize those pickled blobs and expand them into a

@ajkerrigan
ajkerrigan / README.md
Last active March 1, 2023 05:32
VisiData Cloud Custodian Sidebar

A Cloud Custodian Output Directory Sidebar Supplement in VisiData

Some experimentation with providing dynamic sidebar help information following discussion in saulpw/visidata#1733

The idea is to conditionally override the help text on a DirSheet only if it looks like we're in a Cloud Custodian output directory.

This is a hack that could be added to ~/.visidatarc... but probably shouldn't yet.

@ajkerrigan
ajkerrigan / README.md
Last active February 15, 2023 19:48
Summarize Lambda TCP Timeouts with Flow Logs

Summarize Lambda TCP Timeouts with Flow Logs

Some sample code to query VPC flow logs via CloudWatch Logs, and show some information about timed out TCP requests by destination.

Some assumptions:

  • We're focused on a specific VPC-attached Lambda function
  • VPC flow logs are enabled and pointing to a /aws/vpc-flow-log/<vpc id> log group
  • Probably other stuff I'm forgetting to call out
@ajkerrigan
ajkerrigan / arn_resource_types.json
Created January 11, 2023 21:27
ARN Resource Types
{
"a2c": [],
"a4b": [
"addressbook",
"conferenceprovider",
"contact",
"device",
"gateway",
"gatewaygroup",
"networkprofile",
@ajkerrigan
ajkerrigan / puzzle1.vdj
Last active December 29, 2022 21:41
Hanukkah of Data 2022 - VisiData Snippets
#!vd -p
{"longname": "open-file", "input": "noahs-customers.csv", "keystrokes": "o"}
{"sheet": "noahs-customers", "col": "name", "row": "", "longname": "phone-keys-for-col", "input": "", "comment": ""}
{"sheet": "noahs-customers", "col": "", "row": "", "longname": "select-expr", "input": "phone.replace('-','') in name_phonekeys", "keystrokes": "z|", "comment": "select rows matching Python expression in any visible column"}
{"sheet": "noahs-customers", "col": "", "row": "", "longname": "dup-selected", "input": "", "keystrokes": "\"", "comment": "open duplicate sheet with only selected rows"}
@ajkerrigan
ajkerrigan / glom_graphql_restructure.py
Last active November 3, 2022 12:02
Restructuring GitHub GraphQL responses with Glom
from glom import glom, Coalesce, Val
from rich.pretty import pprint
nodes = [
{
"owner": {"login": "python"},
"name": "cpython",
"stargazerCount": 48591,
"createdAt": "2017-02-10T19:23:51Z",
"updatedAt": "2022-11-03T04:49:20Z",