Skip to content

Instantly share code, notes, and snippets.

View unthought's full-sized avatar

Dan Mueller unthought

View GitHub Profile
@jmatsushita
jmatsushita / README
Last active March 26, 2024 10:57
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
@lblackstone
lblackstone / Instructions.md
Last active January 11, 2024 00:06
Debugging provider plugin in a live Pulumi program
  1. Install dlv - https://github.com/go-delve/delve/tree/master/Documentation/installation
  2. Compile and link k8s provider with optimizations off - https://github.com/pulumi/pulumi-kubernetes/commit/3681117730a6440d89e697bc6ae46141fb965d8d (make build && make install && yarn link "@pulumi/kubernetes")
  3. Compile pulumi/pulumi with dlv WIP - https://github.com/pulumi/pulumi/commit/50414ca053981af7560b17df72a0251b9ac2ec03 (make build && make install)
  4. Run the dlv WIP pulumi binary (~/go/bin/pulumi up --logtostderr -v4 --logflow)
  5. Connect GoLand remote debugger to localhost:2345

Current Limitations:

  • Only works for k8s provider
  • Attaches to first launched process of the k8s provider
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active April 23, 2024 13:36 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@briansmith
briansmith / how-to-generate-and-use-private-keys-with-openssl-tool.md
Last active April 11, 2024 17:02
How to generate & use private keys using the OpenSSL command line tool

How to Generate & Use Private Keys using OpenSSL's Command Line Tool

These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.

OpenSSL has a variety of commands that can be used to operate on private key files, some of which are specific to RSA (e.g. openssl rsa and openssl genrsa) or which have other limitations. Here we always use

@aaronjensen
aaronjensen / drain_stop.ex
Last active November 28, 2022 06:59
Phoenix Drain Stop
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0:
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
@pnc
pnc / observer.md
Last active September 9, 2023 23:32
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@rcoh
rcoh / sshupdate.py
Created February 3, 2013 22:57
Automatically update your SSH config to allow ssh-ing into EC2 instances by their name. Works on Linux and Mac OS X.
import os
import subprocess
import boto.ec2
import itertools
AWS_KEY = os.getenv('AWS_ACCESS_KEY')
AWS_SECRET = os.getenv('AWS_SECRET_KEY')
# Tweak as necessary for your infrastructure
regions = ['us-east-1', 'us-west-1', 'eu-west-1']
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 23, 2024 19:14
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@hartym
hartym / git-stash-grep
Created May 3, 2012 09:45 — forked from netshade/gist:1125810
git stash grep (bash)
stashgrep() {
for i in `git stash list | awk -F ':' '{print $1}'`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
}