Skip to content

Instantly share code, notes, and snippets.

View djmetzle's full-sized avatar
⚙️
Working

Daryl Metzler djmetzle

⚙️
Working
View GitHub Profile
@djmetzle
djmetzle / steal-eni.sh
Created December 16, 2017 18:17
Steal an ENI for a Fedora/RedHat/CentOS Instance
#!/bin/bash -ex
# Steal an ENI
# (uses "ONLINE_ENI_ID" from the environment)
# Get some instance basics
METADATA_ENDPOINT="http://169.254.169.254/latest/dynamic/instance-identity/document"
AWS_REGION=`curl -s $METADATA_ENDPOINT | jq .region -r`
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
@djmetzle
djmetzle / eni.md
Created December 18, 2017 16:52
Steal ENI Blogpost?

Attach an ENI to a Fedora/Red Hat/CentOS Instance

aws ec2 attach-network-interface \      
   --region $AWS_REGION \               
   --instance-id $INSTANCE_ID \         
   --device-index 1 \                   
   --network-interface-id $ONLINE_ENI_ID
@djmetzle
djmetzle / checks3logging.sh
Created May 1, 2018 22:24
Quick Script to find S3 buckets with logging enabled
#!/bin/bash -e
# Get list of buckets
S3_BUCKETS=( `aws s3api list-buckets --query "Buckets[].Name" --output=text` )
for bucket in "${S3_BUCKETS[@]}"; do
BUCKET_LOGGING=`aws s3api get-bucket-logging --bucket $bucket`
if [ -n "$BUCKET_LOGGING" ]; then
echo "$bucket: $BUCKET_LOGGING"
fi
@djmetzle
djmetzle / yaml-to-json.rb
Created March 14, 2019 20:20
YAML to JSON Converter
require 'yaml'
require 'json'
x = <<-HEREDOC
---
some:
- yaml: foo
here: bar
HEREDOC
@djmetzle
djmetzle / gist:d46f20889e953a095998dc4ec2549033
Created May 30, 2019 23:23
default Fedora FPM settings
[www]
user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
@djmetzle
djmetzle / AbstractController.php
Created June 4, 2019 21:34
a new attempt at a controller interface
<?
declare(strict_types = 1);
namespace iFixit\Framework\Interfaces;
abstract class AbstractController {
abstract public function routes(): RouteList {}
}
@djmetzle
djmetzle / tree.rb
Created June 19, 2019 19:52
Procedurally generated background
require 'victor'
require 'rgb'
WIDTH=3840
HEIGHT=2160
prng = Random.new
RING_RAD = prng.rand(30..80)
ANGLE_SPREAD=Random.new.rand(3..10)
@djmetzle
djmetzle / cycle-test.yml
Created August 21, 2019 23:10
Proof that docker-compose gracefully handles cyclic dependency resolution
---
version: '3'
services:
aaa:
container_name: aaa
image: busybox
command:
- ping
- bbb
restart: on-failure
@djmetzle
djmetzle / dispatch.rb
Created September 18, 2019 16:12
Class dispatch
class Foo
def quack
puts "quack"
end
end
class Bar
def bark
puts "woof"
end
@djmetzle
djmetzle / checkS3Logging.sh
Created October 2, 2019 21:31
List which S3 buckets have logging enabled
#!/bin/bash -e
S3_BUCKETS=( `aws s3api list-buckets --query "Buckets[].Name" --output=text` )
for bucket in "${S3_BUCKETS[@]}"; do
BUCKET_LOGGING=`aws s3api get-bucket-logging --bucket $bucket`
if [ -n "$BUCKET_LOGGING" ]; then
echo "$bucket: $BUCKET_LOGGING"
fi
done