Skip to content

Instantly share code, notes, and snippets.

View craigderington's full-sized avatar
🚀
Automate Everything

Craig Derington craigderington

🚀
Automate Everything
View GitHub Profile
#!/usr/bin/env bash
set -Eeuo pipefail
URL="http://192.168.1.204:8000/api/increment"
ITERATIONS=100
CONCURRENCY=50
LOGFILE="chaos.log"
export URL
#!/bin/bash
# 🌩️ ULTIMATE WEATHER RADAR TERMINAL
# The most powerful terminal-based weather radar viewer
set -euo pipefail
# ============================================================================
# CONFIGURATION
# ============================================================================
#!/bin/bash
# System Benchmark Suite v2
# Optimized for NUC7i5BNH vs Ryzen 7 6800H comparison
set -e
RESULTS_DIR="$(pwd)/benchmark_$(hostname)_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$RESULTS_DIR"
@craigderington
craigderington / sitename.conf
Created September 7, 2022 23:54
Flask App WSGI Apache Configuration
<VirtualHost *:80>
# listen for non-www, redirect to non-www
ServerName domainname.com
Redirect permanent / http://www.domainname.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.domainname.com
ServerAdmin alias@domainame.com
DocumentRoot /var/www/html/sitename
import fastf1 as ff1
from fastf1 import plotting
from fastf1 import utils
from matplotlib import pyplot as plt
from matplotlib.pyplot import figure
import numpy as np
import pandas as pd
# enable the cache
ff1.Cache.enable_cache('cache')
@craigderington
craigderington / recursive_dict_get.py
Created April 27, 2022 02:32
Recursive Dictionary Get
def recursive_dict_get(d, *keys, default_none=False):
"""Recursive dict get. Can take an arbitrary number of keys and returns an empty
dict if any key does not exist. https://stackoverflow.com/a/28225747"""
ret = reduce(lambda c, k: c.get(k, {}), keys, d)
if default_none and ret == {}:
return None
else:
return ret
from signalr_aio import Connection
from base64 import b64decode
from zlib import decompress, MAX_WBITS
import json
# decode the payload
def process_message(message):
deflated_msg = decompress(b64decode(message), -MAX_WBITS)
return json.loads(deflated_msg.decode())
@craigderington
craigderington / hashed_messaging.py
Created June 6, 2021 15:07
Digital Signature Verification with Python and hmac
import os
import hashlib
import uuid
import hmac
from datetime import datetime, timedelta
my_api_key = os.urandom(64)
def verify(api_key, token, timestamp, signature):
import asyncio
class EchoClientProtocol(asyncio.Protocol):
def __init__(self, message, loop):
self.message = message.encode()
def connection_made(self, transport):
self.transport = transport
self.write_data()
// coding: utf-8
// example 1
// string length
// given the following string, 'this example string', write the string length to the console
var string = 'this example string';
console.log(string.length);