Skip to content

Instantly share code, notes, and snippets.

View stewartadam's full-sized avatar

Stewart Adam stewartadam

View GitHub Profile
@stewartadam
stewartadam / # python@3.10 - 2022-12-10_18-50-44.txt
Created January 7, 2023 23:24
python@3.10 on macOS 13 - Homebrew build logs
Homebrew build logs for python@3.10 on macOS 13
Build date: 2022-12-10 18:50:44
@stewartadam
stewartadam / macos-network-servicelist.sh
Last active November 9, 2022 08:45
Obtain list of active network services on MacOS
# improvement of answer https://apple.stackexchange.com/a/223446/183406
# fixes issue where multiple services may have the same hardware port (e.g. USB Ethernet)
get_interfaces() {
while read -r line; do
sname="$(echo "$line" | sed -E 's|(.*) \(Hardware Port: (.+), Device: (.+)\)|\1|')"
hname="$(echo "$line" | sed -E 's|(.*) \(Hardware Port: (.+), Device: (.+)\)|\2|')"
sdev="$(echo "$line" | sed -E 's|(.*) \(Hardware Port: (.+), Device: (.+)\)|\3|')"
#echo "Current service: $sname, $sdev, $currentservice"
if [ -n "$sdev" ]; then
ifout="$(ifconfig "$sdev" 2>/dev/null)"
@stewartadam
stewartadam / install-google-chrome.ps1
Last active July 22, 2019 18:49
Install Google Chrome from PowerShell (i.e. how to avoid IE on Windows Server)
# Credits to @nicolaigj: https://gist.github.com/kurokikaze/350fe1713591641b3b42#gistcomment-2074156
$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer
@stewartadam
stewartadam / LICENSE
Last active June 29, 2018 03:07
Default license to apply for all of my Gists that (1) are not forked and (2) do not have a file named LICENSE
MIT License
Copyright (c) 2018 Stewart Adam
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@stewartadam
stewartadam / main.py
Last active March 5, 2024 16:02 — forked from gear11/main.py
Simple Python proxy server based on Flask and Requests with support for GET and POST requests.
"""
A simple proxy server, based on original by gear11:
https://gist.github.com/gear11/8006132
Modified from original to support both GET and POST, status code passthrough, header and form data passthrough.
Usage: http://hostname:port/p/(URL to be proxied, minus protocol)
For example: http://localhost:5000/p/www.google.com
"""
import re
@stewartadam
stewartadam / 00-docker-linuxserver-README.md
Last active October 11, 2022 17:13
systemd configuration for containers on boot with docker-compose (via linuxserver.io, among others)

Overview

This sample is intended for modern Linux systems using systemd (Fedora, Ubuntu, Arch, etc).

Installation

Install the files in this gist, replacing dashes for slashes (e.g. etc-systemd-system-dockercompose.service should be installed to /etc/systemd/system/dockercompose.service) and then run systemctl enable --now dockercompose.service to get things started.

Usage

Any manual docker-compose commands should be run from /srv/appdata/linuxserver so that the values from the .env file are applied properly.

Log files can be viewed by running docker-compose -f --tail=50.

@stewartadam
stewartadam / StubController.java
Last active April 4, 2018 17:59
Spring Redirect to Azure AD
@RestController
class StubController {
@RequestMapping("/resource/{id}")
ModelAndView resource(ModelMap model, HttpServletRequest request, @PathVariable String id) {
model.addAttribute("attribute", "forwardWithForwardPrefix");
String client_id = "";
int state = (int )(Math.random() * 1000000 + 1);
String resource = "client_id_guid_of_fhir";
@stewartadam
stewartadam / plex-systemd-nspawn-setup.sh
Last active June 21, 2018 01:47
Installing Plex in a systemd-nspawn container
CONTAINER_NAME="plex"
CONTAINER_ROOT="/var/lib/machines/$CONTAINER_NAME"
BRIDGE_INTERFACE=br0
mkdir "$CONTAINER_ROOT"
sudo dnf --releasever=25 --installroot="$CONTAINER_ROOT" install systemd passwd dnf fedora-release NetworkManager
systemd-nspawn -D "$CONTAINER_ROOT" --network-bridge="$BRIDGE_INTERFACE"
# Install Plex RPM here, then 'exit' or press Ctrl+] 3x to kill container
mkdir -p /etc/systemd/nspawn
@stewartadam
stewartadam / memcached-multi.init
Created April 9, 2017 07:07
memcached-multi, a RHEL6 initscript with support for easily managing multiple memcached services
#! /bin/bash
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
### END INIT INFO
# Based on https://gist.github.com/lboynton/3775818
# Usage:
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached-server1
@stewartadam
stewartadam / calc.py
Created January 16, 2017 08:28
contour-lines-dataviz
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Calculates the x,y co-ordinates of the contour lines given a 2D grid of land
heights, with the origin in the bottom-left corner.
"""
import math
# cheap scope hack
CONTOURS = {}