Skip to content

Instantly share code, notes, and snippets.

View domdomegg's full-sized avatar

Adam Jones domdomegg

View GitHub Profile
@domdomegg
domdomegg / install.sh
Last active May 2, 2023 17:06
PulseAudio output switcher
#!/bin/bash
# Installs switchaudio.sh in current directory
# Tested on Ubuntu 20.04.1 LTS with GNOME 3.36.3 and X11
# Uninstall is manual: delete the script file and remove the shortcut from the keyboard shortcut preferences
set -e
curl -s https://gist.githubusercontent.com/domdomegg/ebef7b1808e1cca7879517c83a46ea9c/raw/8a408d85d0270841787186bacfa2d72c700aca61/switchaudiooutput.sh --output switchaudio.sh
chmod +x switchaudio.sh

Keybase proof

I hereby claim:

  • I am domdomegg on github.
  • I am domdomegg (https://keybase.io/domdomegg) on keybase.
  • I have a public key ASDW50zFSWLKsWYdrYRvl4WLpXC_Q6wU9mw0hr1q5FxCbAo

To claim this, I am signing this object:

@domdomegg
domdomegg / qlearning.js
Created July 13, 2020 20:47
Quick n' dirty Q learning implementation in JavaScript
const input = {
learningRate: 0.1,
discountFactor: 0.95,
initialQ: {},
moves: [
{ start: 's17', action: 'right', reward: 0, finish: 's18' },
{ start: 's18', action: 'up', reward: 10, finish: 's14' },
{ start: 's14', action: 'right', reward: -4, finish: 's15' },
{ start: 's23', action: 'up', reward: 0, finish: 's18' },
{ start: 's18', action: 'up', reward: 0, finish: 's13' },
@domdomegg
domdomegg / martingale.js
Created July 8, 2020 15:49
Martingale casino wheel betting strategy simulator
// Simple (probably buggy) simualtor for the Martingale betting strategy on a casino wheel
// Slightly dodgy coding, bashed out quickly in 10 mins to prove a flatmate wrong...
const randomWin = () => {
return Math.random() < 0.49;
}
let stats = {
counter: 0,
wins: 0,
@domdomegg
domdomegg / README.md
Last active November 16, 2019 19:41
Starling API examples

These programs use Starling's public API to print out details of and lock all the cards of an account holder

You'll want to run these something like:

ACCESS_TOKEN=youraccesstokenhere python example.py 

If using the sandbox API, like:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
int main(int argc, char* argv[]) {
// Create an internet socket
@domdomegg
domdomegg / request-foreach-element.js
Last active October 27, 2019 16:58
Call an HTTP endpoint for each element on a page
// Pretty abstract - basically this is for when:
// there's a bunch of things you can get with a query selector
// which you can map to and endpoint url
// and then want to call the endpoint for each thing
// this is the code for you... and by you I probably mean future Adam 👋
// Designed to run in the Google Chrome console
// Set these parameters 🔧
// These are example values for deleting all topics on uk pcpartpicker
# You can view me at https://gist.github.com/domdomegg/2783028abcfcf7bed5ef50cb1cea361b
# You can run me at https://repl.it/@domdomegg/cs260-cw1-q2
TEST_RUNS = 5
TEST_N = 1000
TEST_MAX = 5000 # TEST_MIN will be -TEST_MAX
import numpy as np
import time
def efficient_iterative(a):