Skip to content

Instantly share code, notes, and snippets.

View sethryder's full-sized avatar
:shipit:

Seth Ryder sethryder

:shipit:
View GitHub Profile
@sethryder
sethryder / preprocessing.sh
Created October 17, 2023 21:46
dblab engine snapshot preprocessing example
#!/bin/bash
# preprocessing.sh
POSTGRES_VERSION=14
POSTGRES_IMAGE="postgresai/extended-postgres:${POSTGRES_VERSION}"
POOL_NAME=dblab_pool
MOUNT_DIR=/var/lib/dblab/"${POOL_NAME}"
# logical mode (with dataset)
@sethryder
sethryder / snapshot_handler.py
Created May 15, 2019 15:16
ebs snapshot handler lambda
import boto3
import datetime
from dateutil.relativedelta import relativedelta
import logging
import sys
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def get_dates_to_keep(days_to_keep, weeks_to_keep, months_to_keep):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeVolumes",
"ec2:DescribeTags",
"ec2:CreateTags"
A0mQMAAgpYTqkgjRJqUkZgl1iwS7RKhfIoSGSeqYIstU6ZlKTJPgmgLbRNQ3EhoHiXNQaZ1SondKSTqolFoo0UMFNZFEuajQRiF9hIqRkHQSUitFCJpJSjehaieUnxBDFbVUFZ6ipgJXVdJWpYTyVSmpsyKktUoJeUsi3SURe6m/IjJYQQ6DFpP0WJLJKnVZajOpPgsxWqTTolYrJXhNopqt5DYpdgt+Iw1XquMiBJYjnquYTlxXle2q6rtSjJeQ86povQj2S6g9GZhvKFCF5BiYIZGsw0oMzGnnSCrGJpTJYu6ivUnuULWBOe0cScXYhDJZzCkNlBiYO0B1tVVz2jmSirEJZbKYSe+fQMk0GJg7QHW1S3PaOZKKsQllsphhQpMsbWBOO0dSMTahTBaLufoI6SDgE0oyXMamyXxWG5hvKFCF5BiYIZGsw0oMzIuGiHSRuDRXKRQ9L2liYO4A1dUuLRZzF+0G5iqFouclTQzMHaC62qX5yHO1mUGi2vG1WMykdwNzlULR85ImBuYOUF3t0nzkuVpZV2YGiWrH13zkudrMIFHt+Fos5pQGSgzMVQpFz0uaGJjhBpKb5bnazCBR7fiajzxXmxkkqh1RzB2gutqlxWIxE5hvDSTKmxwD89lhlUPEmMJkVj8RGjgntLG3YDFr+s7QwKzTIMfAnEBDG5h1GsT81vVrMZ9PTaChDcw6DWJ+6/q1mPd/NzDrNIj5revXYrGY1ZUTEiC5Dcx/p7lazQ2FK7jaWJ1Y0WLeJhpKngbm4RQSWEkTAzMLlGNgRsJ6ziRrIHlaNaPXv6LfWi7N2nzEwDwjW48Pl2bUcVsLUF1azOj1r2G6KHFpMZewUn4TuhuYuVdX0neJYwZpj5o9k7aYlX0EqnlleRqYozQI54Q2NtUW8xiqFAYxMEdpEM4JbWyaLGZt/70MzFEahHNCG5tei8WMDmfvSgzMOATeUDINBuZhuigxMDY5qliYFJNxL4P6glsXLgVF6wqDgrHXUcXC4FJPA5TBBfd9
@sethryder
sethryder / yoast_redirect_fixer.php
Last active April 29, 2022 18:16
update redirects in yoast when changing from date based permalinks to just post name
<?php
$option_value_export_plain = file_get_contents('export_plain.txt');
$option_value_base = file_get_contents('base.txt');
$export_plain = unserialize($option_value_export_plain);
$base = unserialize($option_value_base);
$new_export_plain = [];
@sethryder
sethryder / cloudfront_ips_lambda.py
Last active July 30, 2018 15:03
simple lambda for storing cloudfront ips in parameter store for use in other places (such as nginx for where to trust X-Forwarded-For headers)
from botocore.vendored import requests
import json
import boto3
def get_cloudfront_ips():
ip_list = ''
d = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json').text
l = json.loads(d)
for ip_range in [x['ip_prefix'] for x in l['prefixes'] if x['service']=='CLOUDFRONT' ]:
ip_list += ip_range + ','
@sethryder
sethryder / blackbox.yml
Last active April 17, 2023 06:49
monitor multiple blackbox modules with a single job
modules:
https_2xx:
prober: http
timeout: 5s
http:
method: GET
no_follow_redirects: false
fail_if_ssl: false
fail_if_not_ssl: true
preferred_ip_protocol: "ipv4"
### Keybase proof
I hereby claim:
* I am sethryder on github.
* I am sethryder (https://keybase.io/sethryder) on keybase.
* I have a public key whose fingerprint is F4E2 F6DC 5EB7 01DF B577 7628 B4F6 78C6 49B5 866D
To claim this, I am signing this object:
import requests
import time
import json
checks = {}
api_key = ''
api_endpoint = ''
checks['google'] = {'metric_id': 1, 'url': 'http://www.google.com'}
@sethryder
sethryder / aws-generate-ssh-config.php
Created April 12, 2016 15:17
a quickly hacked together script to generate a .ssh/config from aws instances
<?php
$ssh_instances = [];
$ssh_user = 'root';
require 'vendor/autoload.php';
$ec2 = new Aws\Ec2\Ec2Client([
'version' => 'latest',
'region' => 'us-east-1'
]);