Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Martin Sam-Martin

View GitHub Profile
@Sam-Martin
Sam-Martin / Cmdline example
Created Jan 26, 2020
Get Media Language Recursively
View Cmdline example
find . -iregex ".*.\(mp4\|mkv\)" -exec ~/medialanguage.sh "{}" \; | jq '. | select(.Languages | index("English") | not)'
@Sam-Martin
Sam-Martin / userdata.sh
Created Nov 14, 2019
EC2 Userdata for proxy setup of SSM Agent on Amazon Linux 2
View userdata.sh
#!/usr/bin/env bash
mkdir -p /etc/systemd/system/amazon-ssm-agent.service.d
echo "[Service]" > /etc/systemd/system/amazon-ssm-agent.service.d/override.conf
echo 'Environment="https_proxy=http://proxy:3128"' >> /etc/systemd/system/amazon-ssm-agent.service.d/override.conf
echo 'Environment="http_proxy=http://proxy:3128"' >> /etc/systemd/system/amazon-ssm-agent.service.d/override.conf
echo 'Environment="no_proxy=169.254.169.254"' >> /etc/systemd/system/amazon-ssm-agent.service.d/override.conf
chmod 777 /etc/systemd/system/amazon-ssm-agent.service.d/override.conf
systemctl stop amazon-ssm-agent
systemctl daemon-reload
systemctl restart amazon-ssm-agent
@Sam-Martin
Sam-Martin / get_all_lambda_invocation_stats.py
Created Oct 3, 2019
Sort lambda functions by invocations
View get_all_lambda_invocation_stats.py
import sys
import boto3
import datetime
cw = boto3.client('cloudwatch')
list_metrics_paginator = cw.get_paginator('list_metrics')
function_stats = []
@Sam-Martin
Sam-Martin / Clone DynamoDB.py
Created May 15, 2019
Download and Restore DynamoDB
View Clone DynamoDB.py
aws dynamodb scan --table-name TABLE > export.json
import json
import boto3
dynamo = boto3.client('dynamodb')
TABLE_NAME = 'TABLE_NAME'
JSON_PATH = '/Users/USERNAME/git/GitHub/dynamodump/export.json'
with open(JSON_PATH, 'r') as file:
data = file.read()
parsed_file = json.loads(data)
for item_to_import in parsed_file['Items']:
View rightmove.py
import json
from bson import json_util # pip install pymongo
from datetime import datetime
from rightmove_webscraper import rightmove_data
class rightmove_list(list):
def __init__(self, rightmove_object_results):
new_list = []
for key in rightmove_object_results.keys():
@Sam-Martin
Sam-Martin / get_spot_instance_prices_globally.py
Created Jul 16, 2018
Rough Price of EC2 Spot Instances Globally
View get_spot_instance_prices_globally.py
from __future__ import division
import sys
import collections
import boto3
import pprint
import re
from datetime import datetime, timedelta
ec2 = boto3.client('ec2', region_name='eu-west-1')
@Sam-Martin
Sam-Martin / convert-powerdns-sql-to-latest-version.py
Last active Jun 15, 2018
convert-powerdns-sql-to-latest-version.py
View convert-powerdns-sql-to-latest-version.py
#!/usr/bin/env python2
from __future__ import print_function
import sys, re
from pprint import pprint
from collections import OrderedDict
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
View Scrape From RT and add to Radarr.ps1
$RadarrURL = 'http://127.0.0.1:7878'
$RadarrAPIKey = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa'
#$MovieName = "I Called Him Morgan"
$qualityProfileId = 1
$rootFolderPath = '/data/Movies/'
$rottenTomatoesLink = 'https://www.rottentomatoes.com/top/bestofrt/?year=2017'
function Search-RadarrForFilm{
@Sam-Martin
Sam-Martin / Delete-LowQualityPlexDuplicates.ps1
Created Apr 15, 2018
Delete Lower Quality Plex Duplicates
View Delete-LowQualityPlexDuplicates.ps1
$Server='192.168.1.9:32400'
$PlexToken = 'FGir5aQ5yfpRZZ4ZqxAg'
$libraries = Invoke-RestMethod -Uri "http://$server/library/sections/all?X-Plex-Token=$PlexToken"
$VideoLibraries = $libraries.MediaContainer.Directory | ?{$_.type -eq 'show'}
$Resolutions = @{
"sd" = 1
"420" = 10
"720" = 20
"1080" = 30
}
@Sam-Martin
Sam-Martin / install-chef.ps1
Created Feb 22, 2018
Install Chef Windows
View install-chef.ps1
if(test-path C:\chef\){
Write-Host "C:\chef exists!"
Start-Sleep -Seconds 3600
}
Set-ExecutionPolicy unrestricted -force
$VerbosePreference = 'continue'
$InstallPS1 = "https://omnitruck.chef.io/install.ps1"
$InstallPS1LocalPath = "$env:temp\install-chef.ps1"
$orgName = 'CHEF ORG NAME'
$ChefPackageUri = 'https://packages.chef.io/files/stable/chef/12.21.31/windows/2012r2/chef-client-12.21.31-1-x64.msi'
You can’t perform that action at this time.