Skip to content

Instantly share code, notes, and snippets.

View tr00st's full-sized avatar

James Cheese tr00st

View GitHub Profile
@tr00st
tr00st / hack.js
Created April 22, 2021 09:59
Silent sound generator hack for Safari audio permissions
// James Cheese 2021 - based on example at https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode
// Build an audio context of whatever type's available
let SupportedAudioContext = null;
if (window.AudioContext !== undefined) {
SupportedAudioContext = window.AudioContext;
} else if (window.webkitAudioContext !== undefined) {
SupportedAudioContext = window.webkitAudioContext;
}
const silentAudioContext = new SupportedAudioContext();
@tr00st
tr00st / code.py
Last active February 3, 2021 00:20 — forked from sandyjmacdonald/code.py
4 channel control / 8 note MIDI controller example for Pimoroni RGB Keypad for Raspberry Pi Pico
# Based on @sandyjmacdonald's original gist:
# https://gist.github.com/sandyjmacdonald/b465377dc11a8c83a8c40d1c9b990a90
import time
import board
import busio
import usb_hid
from adafruit_bus_device.i2c_device import I2CDevice
import adafruit_dotstar
@tr00st
tr00st / theme.js
Created March 11, 2020 10:18
Horrendous Material-UI theme generator
import { createMuiTheme } from "@material-ui/core";
/*
Generates a random theme for Material-UI. Usually horrible.
*/
const randomColor = () => {
return ["#",Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16)].join("");
}
@tr00st
tr00st / mdstyles.css
Last active May 8, 2021 22:12
Dark colour scheme for MarkdownEditor (https://github.com/madskristensen/MarkdownEditor)
/*
* Dark colour scheme for MarkdownEditor (https://github.com/madskristensen/MarkdownEditor)
*
* Licensed under MIT license.
*
* Copyright (c) 2018 James Cheese
*
* 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
@tr00st
tr00st / settings.py
Created October 13, 2016 09:18
GeoDjango Win64 workarounds
# First install GDAL as a wheel from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
# Then ensure the following are added to your local settings.py (check the dll name, this may change!)
GDAL_LIBRARY_PATH = r"env\Lib\site-packages\osgeo\gdal200.dll"
environ["PATH"] = "{};{}".format(r"env\Lib\site-packages\osgeo", environ["PATH"])
@tr00st
tr00st / rabbitmq-env.bat.diff
Created October 11, 2016 11:17
Patch for rabbitmq env file to pull cookie manually
--- rabbitmq-env-orig.bat Tue Oct 11 12:16:01 2016
+++ rabbitmq-env.bat Tue Oct 11 12:10:18 2016
@@ -1,10 +1,12 @@
@echo off
REM Scopes the variables to the current batch file
REM setlocal
+set /p COOKIE_VALUE=<%HOMEDRIVE%%HOMEPATH%\.erlang.cookie
+
@tr00st
tr00st / migration_postgis.py
Created September 29, 2016 13:17
PostGIS enabler migration
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.RunSQL("CREATE EXTENSION IF NOT EXISTS postgis")
]
### Keybase proof
I hereby claim:
* I am tr00st on github.
* I am jamescheese (https://keybase.io/jamescheese) on keybase.
* I have a public key whose fingerprint is 6F3C F8FD 4114 7718 A16E A759 8D3B AE8A 8E0A A400
To claim this, I am signing this object:
@tr00st
tr00st / .bashrc
Last active October 13, 2015 10:27
Coloured prompt lines for BASH
# Simple colour-coded prompts for BASH usage - red=live, blue=test, green=dev
#live:
export PS1="\[$(tput bold)\]\[\033[38;5;9m\]\u@\h\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]:\w\\$\[$(tput sgr0)\] "
#test:
export PS1="\[$(tput bold)\]\[\033[38;5;39m\]\u@\h\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]:\w\\$\[$(tput sgr0)\] "
#dev:
export PS1="\[$(tput bold)\]\[\033[38;5;119m\]\u@\h\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]:\w\\$\[$(tput sgr0)\] "
@tr00st
tr00st / gist:76f2729e0467e83e117a
Last active August 29, 2015 14:24
SSL config options for nginx
# Remove legacy SSL support. If you really need it, you're supporting IE6 yourself. Sorry.
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Settings for cached SSL sessions.
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 5m;
# Choose some DH params: