Skip to content

Instantly share code, notes, and snippets.

View jshiell's full-sized avatar

Jamie Shiell jshiell

View GitHub Profile
@jshiell
jshiell / slack-find-users-by-name
Created January 27, 2022 10:20
Script to look up Slack user details by real name
#!/usr/bin/env ruby
# A script to find Slack user details by name
require 'uri'
require 'net/http'
require 'json'
class Auditor
@jshiell
jshiell / Encrypter.java
Created July 16, 2021 07:25
AES Example in Java
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayOutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
@jshiell
jshiell / anyconnect.sh
Last active July 21, 2020 08:05
AnyConnect script for user/pass VPN on headless Linux (i.e. where secret-tool won't work)
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
readonly _CISCO_VPN="/opt/cisco/anyconnect/bin/vpn"
readonly _GREEN='\033[0;32m'
readonly _RED='\033[0;31m'
readonly _NC='\033[0m'
@jshiell
jshiell / bitarray.lua
Created June 12, 2020 07:49
Read/write an array of bits in PICO-8
buffer_base = 0x4300
buffer_width = 127
buffer_height = 127
function init()
memset(buffer_base, 0, (buffer_width * buffer_height) / 8)
end
function set(x, y, value)
local offset = (x + (buffer_width * y))
@jshiell
jshiell / adafruit-circuit-playground-express-cheatsheet.md
Last active February 14, 2022 10:34
Adafruit Circuit Playground Express Cheatsheet

Adafruit Circuit Playground Express Cheatsheet

This is a cheatsheet for getting up and going with the Adafruit Circuit Playground Express using CircuitPython.

Setup

How can I work out what version of Circuit Python I'm using?

When you plug the device into a USB port it should mount a drive called CircuitPy. In the root of this drive should reside a file called boot_out.txt. This will contain version information for the device, e.g.

@jshiell
jshiell / main.py
Last active January 8, 2020 19:10
USB keypress code for AdaFruit Trinket M0 with CircuitPython 4
import digitalio
from board import *
import time
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
import adafruit_dotstar
# The keycode sent for each button, optionally can be paired with a modifier key
# https://circuitpython.readthedocs.io/projects/hid/en/latest/api.html#adafruit-hid-keycode-keycode
@jshiell
jshiell / sleepscreens.sh
Last active July 15, 2019 07:51
Wall monitor power saving script (Wayland/Ubuntu 19.04)
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
turn_off_all_screens() {
busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 3
}
turn_on_all_screens() {
@jshiell
jshiell / sleepscreens.sh
Last active June 12, 2019 08:08
Wall monitor power saving script (XRandR)
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DISPLAY="${DISPLAY:-:0}"
turn_off_all_screens() {
for MONITOR in $(xrandr -d :0 --listmonitors | awk '{print $4}'); do
xrandr -d "$DISPLAY" --output "$MONITOR" --off
@jshiell
jshiell / OkeyDokeExtension.kt
Created November 29, 2018 15:41
JUnit 5 Extension for OkeyDoke support
package com.springer.oscar.test
import com.oneeyedmen.okeydoke.Approver
import com.oneeyedmen.okeydoke.ApproverFactories
import com.oneeyedmen.okeydoke.Name
import org.junit.jupiter.api.extension.*
import java.io.File
import java.lang.reflect.Method
@jshiell
jshiell / retry-extension.kt
Created November 27, 2018 15:54
Retry extension for JUnit 5
package com.springer.oscar.test
import com.springer.oscar.test.RetryExtension.Companion.TEST_PASSED
import org.junit.AssumptionViolatedException
import org.junit.jupiter.api.TestTemplate
import org.junit.jupiter.api.extension.*
import org.junit.platform.commons.util.AnnotationUtils.findAnnotation
import org.junit.platform.commons.util.AnnotationUtils.isAnnotated
import org.opentest4j.TestAbortedException
import org.opentest4j.TestSkippedException