Skip to content

Instantly share code, notes, and snippets.

names = [
'user a',
'user b',
'user c',
]
for (let i = 0; i < names.length; i++) {
Array.from(document.querySelectorAll('button')).filter(b => b.innerText == 'Add member')[0].click()
}
@judell
judell / internal_and_public_id
Created August 7, 2019 16:39
convert between hypothesis internal and public ids
import base64, uuid, binascii, traceback
ES_FLAKE_MAGIC_BYTE = ['e', '5']
def _must_b64_decode(data, expected_size=None):
result = base64.urlsafe_b64decode(data)
if expected_size is not None and len(result) != expected_size:
raise TypeError('incorrect data size')
return result
@judell
judell / plpython.md
Last active December 19, 2019 21:53

Installed extensions

h_analytics=# select name, default_version, installed_version from pg_available_extensions  where installed_version is not null;
   name    | default_version | installed_version
-----------+-----------------+-------------------
 uuid-ossp | 1.1             | 1.1
 plpgsql   | 1.0             | 1.0
(2 rows)
import aiopg, asyncio, psycopg2, sys, time
dsn = "dbname=db user=postgres"
async def listen(conn):
async with conn.cursor() as cur:
await cur.execute("LISTEN topic")
while True:
sec = time.gmtime().tm_sec
if sec % 5 == 0:
@judell
judell / find-unused-security-groups.sql
Created September 15, 2021 18:45
PATTERN: UNION similar things to combine them
with lambda_sgs as (
select
'Lambda' as service,
f.arn,
sg_id as security_group_id
from
aws_lambda_function as f,
jsonb_array_elements_text(f.vpc_security_group_ids) as sg_id
),
ec2_instance_sgs as (
@judell
judell / untagged-ec2-instances-and-keypairs.sql
Last active September 15, 2021 21:59
PATTERN: UNION similar things to combine them
select title, id, resource from
(
select
title,
key_pair_id as id,
'aws_ec2_key_pair' as resource,
tags
from
aws_ec2_key_pair
union
@judell
judell / find-gist-patterns.sql
Created September 15, 2021 22:01
find gists that illustrate patterns
> with filenames as (
select
id,
jsonb_object_keys(files) as name
from github_my_gist
)
select
f.name,
g.files -> f.name ->> 'language' as language,
g.description as pattern
@judell
judell / find-internal-function.md
Last active September 28, 2021 15:40
Find an internal Postgres function
@judell
judell / file1.md
Created September 26, 2021 17:51
gist-with-two-files

File1

@judell
judell / cloning-steampipe-plugin-hello.md
Last active September 27, 2021 04:20
Clone a new steampipe plugin from steampipe-plugin-hello