Skip to content

Instantly share code, notes, and snippets.

Avatar
🇳🇿

Tom Henderson tom-henderson

🇳🇿
View GitHub Profile
View grafana-annotation.py
#!/usr/bin/env python3
# https://grafana.com/docs/http_api/annotations/
import os
import sys
import json
import requests
import argparse
import datetime
View docker-volume-metrics.sh
#!/bin/bash -e
# Write out prometheus metrics for docker volume size.
while read -r container_id; do
container=$(docker inspect "$container_id")
state=$(jq --raw-output .[].State.Status <(echo "$container"))
if [[ $state = 'running' ]]; then
View countries.csv
code latitude longitude name
AD 42.546245 1.601554 Andorra
AE 23.424076 53.847818 United Arab Emirates
AF 33.93911 67.709953 Afghanistan
AG 17.060816 -61.796428 Antigua and Barbuda
AI 18.220554 -63.068615 Anguilla
AL 41.153332 20.168331 Albania
AM 40.069099 45.038189 Armenia
AN 12.226079 -69.060087 Netherlands Antilles
AO -11.202692 17.873887 Angola
View dialing_codes.csv
code country
1 United States
20 Egypt
27 South Africa
30 Greece
31 Netherlands
32 Belgium
33 France
34 Spain
36 Hungary
View slack.py
#!/usr/bin/env python3
import os
import sys
import json
import requests
import argparse
import re
SLACK_WEBHOOK_URL = os.environ.get("SLACK_WEBHOOK_URL")
View Get-GPClientSideExtensions
function Get-GPClientSideExtensions {
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions" | foreach {
$guid = ($_.Name).Split(“\”) | Select -Last 1
$props = Get-ItemProperty $_.PSPath
# Guessing CSE name in order (default), ProcessGroupPolicy, ProcessGroupPolicyEx
if ($props.'(default)') {
$description = $props.'(default)'
} elseif ($props.ProcessGroupPolicy) {
$description = $props.ProcessGroupPolicy
View org.observium.agent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.observium.agent</string>
<key>Program</key>
<string>/usr/local/lib/observium-agent/yoctopuce</string>
<key>Sockets</key>
<dict>
View safeswim.py
import requests
url = "https://api-dot-translate-safeswim.appspot.com/v1/locations/4829360"
data = json.loads(requests.get(url))
days = [
'today',
'tomorrow',
'dayAfter'
]
View vs_code_settings.json
// Place your settings in this file to overwrite the default settings
{
// General Appearance
"window.zoomLevel": 0,
"workbench.colorTheme": "Tomorrow_Night",
"workbench.iconTheme": "vs-seti",
"workbench.startupEditor": "welcomePage",
// Editor
"editor.selectionHighlight": true,
View rent.py
import requests
from bs4 import BeautifulSoup as bs
locations = ['Devonport', 'Takapuna']
data = {}
for location in locations:
url = "https://www.tenancy.govt.nz/rent-bond-and-bills/market-rent/?location={}".format(location)
html = requests.get(url).text
soup = bs(html, "html.parser")