Skip to content

Instantly share code, notes, and snippets.

View ElijahLynn's full-sized avatar
😎
All Your DevOps Belong To Us

Elijah Lynn ElijahLynn

😎
All Your DevOps Belong To Us
View GitHub Profile
@ElijahLynn
ElijahLynn / pipe_to_docker_examples
Last active March 13, 2024 03:29
How to pipe to `docker exec` examples
# These examples assume you have a container currently running.
# 1 Pipe from a file
sudo docker exec --interactive CONTAINER_NAME /bin/bash < the_beginning.sh | tee the_beginning_output.txt`
#2a Pipe by piping
echo "echo This is how we pipe to docker exec" | sudo docker exec --interactive CONTAINER_NAME /bin/bash -
@ElijahLynn
ElijahLynn / monitor-number-tcp-connection-states.sh
Last active January 20, 2024 22:49
Monitor the number of all TCP connection states
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
# Every 1.0s: netstat -an | awk '/^tcp/ { ++S[$NF] } END { for(a in S) print a, S[a] }'
# LISTEN 7
# FIN_WAIT_2 1
# CLOSE_WAIT 1
# CLOSED 33
# TIME_WAIT 1
# ESTABLISHED 63
@ElijahLynn
ElijahLynn / gist:d76d31eca63d984efa424b08dee2905b
Last active December 6, 2023 00:11
Remote tcpdump stream to wireshark

Archived from https://twitter.com/ElijahLynn/status/1144399526452588545

Just had to debug yum returning a 503 on a server deep in a private network, but curl worked fine. Was able to use tshark and pipe it to my local wireshark and re-assemble the HTTP request that finally told me it was blocked by the internet gateway and who to email!

Here is the command that piped in realtime the tshark dump to my local wireshark GUI. Don't worry about the CLI filter because we can just use display filters to get what we want. Then find a GET packet, right click and "Follow" > TCP||HTTP Stream

Amazing!

Would help if I pasted the command!

@ElijahLynn
ElijahLynn / output.txt
Created October 20, 2023 18:34
Show all TCP connections and states (1 liner)
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
@ElijahLynn
ElijahLynn / gist:14a1470d3a344b16489b6b9678e28956
Last active January 20, 2023 22:00
drud/ddev/issue/4570
Running bash [-c /tmp/test_ddev.sh]
======= Existing project config =========
These config files were loaded for project va-gov-cms: [/home/elijah/Projects/va.gov/va.gov-cms/.ddev/config.yaml]
name: va-gov-cms
type: drupal9
docroot: docroot
php_version: 8.1
webserver_type: nginx-fpm
webimage: drud/ddev-webserver:v1.21.4

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

## https://stackoverflow.com/questions/34658836/docker-is-in-volume-in-use-but-there-arent-any-docker-containers?answertab=trending#comment128478332_42116347
function docker-remove-containers --description "Remove all docker containers"
docker stop (docker ps --all --quiet)
docker rm (docker ps --all --quiet)
end
funcsave docker-remove-containers
@ElijahLynn
ElijahLynn / guake_fullscreen_toggle.py
Last active June 7, 2022 23:15
Script to toggle fullscreen for Guake 0.8.x
#!/usr/bin/env python2
# -*- coding: utf-8; -*-
# Depends on https://github.com/Guake/guake/pull/1446
import dbus
try:
bus = dbus.SessionBus()
remote_object = bus.get_object('org.guake.RemoteControl', '/org/guake/RemoteControl')
remote_object.fullscreen_toggle()
@ElijahLynn
ElijahLynn / gist:a848ae3214aba1f22745
Last active February 16, 2021 02:17
Cherry pick range commits from another repo
// Say you have a Repo and you are in a few levels deep. /profiles/publisher/modules/contrib/
// You have a module called ../contrib/embed_external
// You want to pull changes you made to it to upstream
// pwd ../contrib
// git clone embed-external-upstream EE-upstream
// cd EE-upstream
git -C ../embed_external/ diff --relative 76da308..HEAD . | patch -p1
// http://stackoverflow.com/a/9507417/292408
@ElijahLynn
ElijahLynn / droplet_delete_all.fish
Last active September 30, 2020 12:37
Delete all Digital Ocean droplets - good for testing
function droplet_delete_all
echo "Getting list of droplets"
set --local droplets (doctl compute droplet list | tail --lines=+2 | awk '{print $2}')
if test -n "$droplets"
echo "Deleting droplets: $droplets"
for droplet in $droplets
doctl compute droplet delete $droplet
echo "Deleted droplet: $droplet"
end
else