Skip to content

Instantly share code, notes, and snippets.

View caleb15's full-sized avatar
🏠
Working from home

Caleb Collins-Parks caleb15

🏠
Working from home
View GitHub Profile
@caleb15
caleb15 / citibike.json
Created November 4, 2020 02:29
citibike_json_for_telegraf
{"data":{"stations":[{"is_renting":1,"num_bikes_disabled":1,"is_installed":1,"num_bikes_available":10,"legacy_id":"72","is_returning":1,"eightd_has_available_keys":false,"num_ebikes_available":2,"station_id":"72","last_reported":1604455485,"num_docks_disabled":0,"num_docks_available":44,"station_status":"active"},{"is_renting":1,"num_bikes_disabled":2,"is_installed":1,"num_bikes_available":25,"legacy_id":"79","is_returning":1,"eightd_has_available_keys":false,"num_ebikes_available":0,"station_id":"79","last_reported":1604455168,"num_docks_disabled":0,"num_docks_available":6,"station_status":"active"},{"is_renting":1,"num_bikes_disabled":1,"is_installed":1,"num_bikes_available":17,"legacy_id":"82","is_returning":1,"eightd_has_available_keys":false,"num_ebikes_available":0,"station_id":"82","last_reported":1604456065,"num_docks_disabled":0,"num_docks_available":9,"station_status":"active"},{"is_renting":1,"num_bikes_disabled":0,"is_installed":1,"num_bikes_available":43,"legacy_id":"83","is_returning":1,"eightd_
@caleb15
caleb15 / env_warning.py
Last active July 27, 2022 23:59
ansible callback plugin for warning if you are running against wrong environment
import os
from typing import List
import sys
from ansible.plugins.callback import CallbackBase
# this file goes in a "callback_plugins" folder next to your playbook file
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate' # no idea what this var does, can't find documentation :(
#!/bin/sh
GLOBIGNORE="*" # to prevent schedule from becoming wacky
if [ "$1" = "-h" ]; then
echo "Usage: $(basename "$0") check_name \"schedule\" \"command\" alert_channel1,alert_channel2 \"tag1 tag2\" \"description\" grace"
echo "Everything after \"command\" is optional. Grace is a number, if specified"
echo "Example: $(basename "$0") influxdb_is_running \"* * * * *\" \"influx -execute 'SHOW DATABASES'\" VictorOps \"devops\""
echo "Please make sure VPC_NAME and HEALTHCHECKS_API_KEY are set before running the script"
exit 0
fi
@caleb15
caleb15 / ahealthcheck.py
Created March 15, 2020 19:30
automatic healthcheck ping / creation
#$end # for arepl
# Rough Draft
import json
from typing import List
import requests
API_URL_BASE = "https://healthchecks.io/api/v1/"
API_READONLY_key = "stop looking at my naughty bits"
@caleb15
caleb15 / most_changed_roles.py
Created November 22, 2019 19:24
python script for aggregating changes by folder.
import re
# run ./git-most.sh > most.txt before this script
# adjust whitelist var if you only want to see changes to a certain filetype/file/path
most_changed_paths = {}
whitelist = '' # '.yml'
with open('most.txt') as f:
for line in f.readlines():
@caleb15
caleb15 / migrate_mb_h2_to_postgres.sh
Created November 22, 2019 19:04
how to migrate docker metabase h2 to postgres
export MB_DB_TYPE=postgres
export MB_DB_PORT=5432
export MB_DB_USER=postgres
export MB_DB_PASS=
export MB_DB_HOST=db.metabase.staging
sudo docker cp metabase:/app/metabase.jar .
sudo docker stop metabase
java -jar metabase.jar load-from-h2 /home/metabase/metabase-data/metabase.db/metabase.db
@caleb15
caleb15 / typeTest.py
Created August 22, 2019 05:56
file with type problems for testing type checkers
import django
import doesNotExist
import math
import inspect
from typing import List
class foo:
def constructor(self, x):
self.x = x
// simple types: see https://learnxinyminutes.com/docs/typescript/
/////////////////////////////////////////////////////////////////////////////
// generic function
// old:
const foo: a => a;
// new:
const foo: <T extends any>(a: T) => a;
/////////////////////////////////////////////////////////////////////////////