Skip to content

Instantly share code, notes, and snippets.

View Sam-Martin's full-sized avatar

Sam Martin Sam-Martin

View GitHub Profile
@Sam-Martin
Sam-Martin / Lambda Delete Test Kitchen Instances after 24hrs.py
Last active November 27, 2017 16:15
Lambda Delete Test Kitchen Instances after 24hrs
import boto3
from datetime import datetime
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
@Sam-Martin
Sam-Martin / update-zabbix-host-proxy.py
Created February 14, 2018 12:48
Update Zabbix hosts to report to proxies based on IPs
from pyzabbix import ZabbixAPI
import os
import json
import logging, sys
from pprint import pprint
#
#
# WARNING
# THIS
@Sam-Martin
Sam-Martin / zabbix-grafana-alerts.json
Last active March 5, 2018 15:09
Zabbix Grafana Alerts
{
"annotations": {
"list": [
{
"$$hashKey": "object:1373",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
@Sam-Martin
Sam-Martin / install-chef.ps1
Created February 22, 2018 15:55
Install Chef Windows
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'
@Sam-Martin
Sam-Martin / Delete-LowQualityPlexDuplicates.ps1
Created April 15, 2018 15:36
Delete Lower Quality Plex Duplicates
$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
}
$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 / convert-powerdns-sql-to-latest-version.py
Last active June 15, 2018 14:01
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)
@Sam-Martin
Sam-Martin / get_spot_instance_prices_globally.py
Created July 16, 2018 15:23
Rough Price of EC2 Spot Instances Globally
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 / rightmove.py
Created February 27, 2019 08:00
Scrape Rightmove
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 / Clone DynamoDB.py
Created May 15, 2019 13:24
Download and Restore DynamoDB
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']: