Skip to content

Instantly share code, notes, and snippets.

View mda590's full-sized avatar
☁️
Feeling cloudy

Matt Adorjan mda590

☁️
Feeling cloudy
View GitHub Profile
@mda590
mda590 / ubuntu-update.sh
Created February 4, 2020 21:46
Simple script to upgrade an Ubuntu distribution and all of its packages
#!/bin/bash
# Fetches the list of available updates
sudo apt-get update -y
# Strictly upgrades the current packages
sudo apt-get upgrade -y
# Installs updates (new ones)
sudo apt-get dist-upgrade -y
@mda590
mda590 / dynamic-prom-rules-file-list.sh
Created April 21, 2019 16:05
Looks in a directory and echos out a YAML formatted string containing a list of rules files which can be put into a Prometheus configuration file
#!/bin/bash
FILES=$(ls -1)
BASE_RULES_PATH="/etc/rules"
FILE_LIST=""
for file in $FILES; do
if [[ $file =~ .*.yaml|.*.yml ]]; then
FILE_LIST+=" - $BASE_RULES_PATH/$file\n"
fi

This shows a config file which can be parsed with Python's configparser. Rules.py will read this config file and construct a JSON object with IP addresses dynamically.

rules.conf

[domain1-rule]
Name = domain1-rule
RuleType = Forward
DomainName = domain1
Ips = 10.10.10.10, 10.10.10.11, 10.10.10.12
Port = 53
@mda590
mda590 / stress_test.py
Created June 8, 2018 14:07
Python script useful for stress testing systems
"""
Produces load on all available CPU cores.
Requires system environment var STRESS_MINS to be set.
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
import time
import os
@mda590
mda590 / wallcat_gradient_windows.ps1
Last active April 1, 2019 10:06
Gets the latest Gradient Wallpaper from Wallcat and sets it as active - run as a scheduled task
$curr_chan = "ygmTdEW7aF"
$curr_date = Get-Date -format "yyyy-MM-dd"
$wallpaper_json = (wget "https://beta.wall.cat/api/v1/channels/${curr_chan}/image/${curr_date}T00:00:00.000Z").Content | ConvertFrom-Json
$wallpaper_url = $wallpaper_json.payload.image.url.o
$wallpaper_local_path = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WallPaper
Invoke-WebRequest $wallpaper_url -OutFile $wallpaper_local_path

Keybase proof

I hereby claim:

  • I am mda590 on github.
  • I am mado (https://keybase.io/mado) on keybase.
  • I have a public key whose fingerprint is FD6D 3178 4BD4 FFDF 5B70 54B0 54E7 E6AE 2894 4A7F

To claim this, I am signing this object:

@mda590
mda590 / get_ec2_regions_string.sh
Created December 27, 2017 18:34
Get all EC2 regions in a comma separated string
aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | @csv'
@mda590
mda590 / listAllS3BucketsObjects.py
Created April 27, 2017 17:23
List all S3 Buckets and Objects
#
# Print all S3 buckets and objects
# Warning: If you have a lot of S3 objects, this could potentially incur a large cost.
#
import boto3
client = boto3.client('s3')
buckets = client.list_buckets()
@mda590
mda590 / ssm-secrets-05.sh
Created March 22, 2017 12:42
Get Secure String from EC2 Parameter Store - Example
aws --region=us-east-2 ssm get-parameters --names "secret-password" --with-decryption
@mda590
mda590 / ssm-secrets-04.sh
Created March 22, 2017 12:41
Get Secure String from EC2 Parameter Store
aws --region=us-east-2 ssm get-parameters --names "<string-name>" --with-decryption