Skip to content

Instantly share code, notes, and snippets.

Avatar

Gene Wood gene1wood

View GitHub Profile
@gene1wood
gene1wood / .person_api.sh
Created Jul 20, 2020
Small script to get users from CIS
View .person_api.sh
export person_api_client_id=xxx
export person_api_client_secret=xxx
if [ -z "$person_api_bearer_token" ]; then
echo "Fetching bearer token"
export person_api_bearer_token=$(curl --silent --request POST --url https://auth.mozilla.auth0.com/oauth/token --header "Content-Type: application/json" --data "{\"client_id\":\"${person_api_client_id}\",\"client_secret\":\"${person_api_client_secret}\",\"audience\":\"api.sso.mozilla.com\",\"grant_type\":\"client_credentials\"}" | jq -r '.access_token')
fi
function url_quote {
echo $1 | python3 -c "import urllib.parse; print(urllib.parse.quote(input()))"
}
function get_auth0_user {
@gene1wood
gene1wood / disable-native-login.php
Last active Jul 4, 2020
Disable Wordpress native username password login when using Google Apps Login
View disable-native-login.php
<?php
/**
* Plugin Name: Disable Native Login
* Plugin URI: https://cs.cementhorizon.com/
* Description: Disable the native username password login in wordpress
* Version: 1.0.0
* Author: Gene Wood
* Author URI: https://cs.cementhorizon.com/
* License: GPL2
@gene1wood
gene1wood / syslog.txt
Created Jun 26, 2020
Syslog on Ubuntu 18.04 when activating Soundcore Life P2 headset
View syslog.txt
Jun 26 11:34:54 judy /usr/lib/gdm3/gdm-x-session[32177]: (--) modeset(G0): HDMI max TMDS frequency 300000KHz
Jun 26 11:34:55 judy dbus-daemon[32393]: [session uid=1000 pid=32393] Activating via systemd: service name='org.bluez.obex' unit='dbus-org.bluez.obex.service' requested by ':1.79' (uid=1000 pid=1277 comm="gnome-control-center bluetooth " label="unconfined")
Jun 26 11:34:55 judy systemd[32111]: Starting Bluetooth OBEX service...
Jun 26 11:34:55 judy obexd[1289]: OBEX daemon 5.48
Jun 26 11:34:55 judy dbus-daemon[32393]: [session uid=1000 pid=32393] Successfully activated service 'org.bluez.obex'
Jun 26 11:34:55 judy systemd[32111]: Started Bluetooth OBEX service.
Jun 26 11:35:03 judy bluetoothd[1462]: a2dp-source profile connect failed for E8:07:BF:A6:3D:26: Device or resource busy
Jun 26 11:35:04 judy kernel: [62680.010423] input: E8:07:BF:A6:3D:26 as /devices/virtual/input/input91
Jun 26 11:35:04 judy /usr/lib/gdm3/gdm-x-session[32177]: (II) config/udev: Adding input device E8:07:BF:A6:3D:26 (/dev/inpu
@gene1wood
gene1wood / 0001-6305_Vista_Win7_PG537.zip
Last active Jun 2, 2020
Realteak AC'97 Audio Codecs Software Vista/Win7 (32/64 bits) Driver only (ZIP file)
@gene1wood
gene1wood / watch-for-new-media.bash
Created May 10, 2020
Script to create inotifywait on directories to trigger Subsonic media scanning
View watch-for-new-media.bash
#!/bin/bash
dirs="/path/to/first/dir /path/to/second/dir /path/to/third/dir"
act="/usr/local/bin/act-on-new-media.bash"
# act="cat"
/bin/inotifywait --monitor --recursive --quiet --format '%w' --event create,moved_to $dirs | while read f
do
$act "$f"
done
@gene1wood
gene1wood / rescan_subsonic_media.py
Created May 10, 2020
Script to trigger a Subsonic media rescan with locking
View rescan_subsonic_media.py
#!/bin/env python
import sys
import requests
import os
import os.path
import time
import logging
import subprocess
import json
@gene1wood
gene1wood / who_has_access.py
Last active Jun 9, 2021
Script to check what AWS IAM users and roles have rights to perform an action
View who_has_access.py
#!/usr/bin/env python
import sys
import boto3
def get_paginated_results(product, action, key, credentials=None, args=None):
args = {} if args is None else args
return [y for sublist in [x[key] for x in boto3.client(product, **({} if credentials is None else credentials)).get_paginator(action).paginate(**args)] for y in sublist]
@gene1wood
gene1wood / How-to-deal-with-a-Google-Pixel-with-a-broken-power-button.md
Created Jan 22, 2020
How to deal with a Google Pixel with a broken power button
View How-to-deal-with-a-Google-Pixel-with-a-broken-power-button.md
@gene1wood
gene1wood / cloudformation-custom-resource-event-sequence.md
Created Dec 31, 2019
The sequence of events triggered for a CloudFormation custom resource backed by an AWS Lambda function
View cloudformation-custom-resource-event-sequence.md

Create a stack

{
    "event": {
        "StackId": "arn:aws:cloudformation:us-west-2:656532927350:stack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80",
        "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A656532927350%3Astack/genetest2/c6c0c040-c5ee-11e9-9ec7-0ad236afdc80%7CExample%7Cef8641a2-cac0-4eaf-aed6-df08cd9aae26?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190823T214203Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7199&X-Amz-Credential=AKIA54RCMT6SG7Y5BKPL%2F20190823%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=a5f9d0ac53360f385b20e9f71a36746d691b2d161bf45ab867a76a858de3e1e0",
        "ResourceProperties": {
            "ServiceToken": "arn:aws:lambda:us-west-2:656532927350:function:genetest2-ExampleFunction-NQLOVV15EHNT",
            "Param": "alpha"
@gene1wood
gene1wood / explore-automating-releasing-python-packages.md
Created Dec 20, 2019
Some exploration around what would be needed to simplify (through code) the process of releasing python package versions
View explore-automating-releasing-python-packages.md
  • Make sure CHANGELOG.md has all new functionality you want in the release

    • Summarize changes since last release that are missing from Unreleased
  • Pick new version based on semver rules

  • Run unit tests / tox

  • Run flake8

  • Check CHANGELOG.md to ensure

    • There are contents in unreleased
    • The new version number isn't present
  • Verify version is newer than newest version in pypi.org