Skip to content

Instantly share code, notes, and snippets.

View mwt's full-sized avatar

Matthew W. Thomas mwt

View GitHub Profile
@mwt
mwt / wg-hosts.sh
Last active September 28, 2023 00:42
Update HOSTS file on my wireguard setup
#!/bin/sh
sed -i '/# BEGIN Wireguard vLAN #/,/# END Wireguard vLAN #/d' /etc/hosts
cat << EOF >> /etc/hosts
# BEGIN Wireguard vLAN #
10.7.0.1 letbox.wg
10.7.0.2 bellerophon.wg
10.7.0.3 specialk.wg
10.7.0.4 candy.wg
10.7.0.5 pixel7.wg
10.7.0.6 augustus.wg
@mwt
mwt / README.md
Last active May 3, 2023 00:36 — forked from r0l1/README.md
Running docker-compose as a systemd service

Running snikket as a systemd service

Files

File Purpose
/etc/snikket/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/snikket.service Service unit to start and manage docker compose
/etc/systemd/system/snikket-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/snikket-reload.timer Timer unit to plan the reloads
@mwt
mwt / econ_journals.sorl
Last active October 2, 2023 00:00
Econ Journals Proxy Rule List (for SwitchyOmega): this is a rule list for automatically proxying Econ journal websites through your institution's proxy
[SwitchyOmega Conditions]
; Require: SwitchyOmega >= 2.3.2
; Date: 8/28/2022
; Usage: https://github.com/FelisCatus/SwitchyOmega/wiki/RuleListUsage
*.tandfonline.com
*.aeaweb.org
*.journals.uchicago.edu
*.springer.com
*.jstor.org
@mwt
mwt / gist:2b35ae84f3d4d9a859481b03f2daee9b
Last active July 27, 2022 00:08 — forked from unixabg/gist:4ca86477b6ad0504d8b9486f1a160057
alsa helper script for the glkda7219max
#!/bin/bash
echo Adding microphone to Pulseaudio
grep -qxF 'load-module module-alsa-source device=hw:0,99' /etc/pulse/default.pa || echo 'load-module module-alsa-source device=hw:0,99' >> /etc/pulse/default.pa
echo Adding headphone to Pulseaudio
grep -qxF 'load-module module-alsa-sink device=hw:0,1' /etc/pulse/default.pa || echo 'load-module module-alsa-sink device=hw:0,1' >> /etc/pulse/default.pa
echo Adding headset microphone to Pulseaudio
@mwt
mwt / install.sh
Last active April 17, 2023 01:38
"Universal" Repo Installer for Debian, Ubuntu, Fedora, RHL, OpenSuse, and more.
#!/bin/sh
# This script installs an repository for apt, dnf, yum, or zypper. It expects
# the following eniroment variables.
# GPG_KEY : the url for the asc gpg key
# APP_NAME : the name to use for the repo file and key
# DEB_REPO : (optional) the string to appear in the .list file
# RPM_REPO : (optional) the string to appear in the .repo file
# Override repostiroy based on distribution identity
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
@mwt
mwt / r_fix.ps1
Created September 30, 2021 23:01
Fix OneDrive Issue in R
$R_lib_path = "$env:USERPROFILE\R"
[System.Environment]::SetEnvironmentVariable('R_LIBS_USER', $R_lib_path, [System.EnvironmentVariableTarget]::User)
New-Item -ItemType Directory -Force -Path $R_lib_path
@mwt
mwt / README.md
Last active March 10, 2024 09:40
Jekyll include for utterances

Jekyll include for utterances

This is an include to use utterances comments on any Jekyll static site. It is fully compatible with GitHub Pages.

Basic usage

Add utterances.html to your /_includes folder. Put the following include statement in the part of your layout/page/post/include that you want the comments to be in:

{% include utterances.html %}
@mwt
mwt / handler_fieldstorage.py
Created January 25, 2021 21:01 — forked from davidejones/handler_fieldstorage.py
aws lambda parsing multipart form with python3
from cgi import FieldStorage
from io import BytesIO
def parse_into_field_storage(fp, ctype, clength):
fs = FieldStorage(
fp=fp,
environ={'REQUEST_METHOD': 'POST'},
headers={
'content-type': ctype,
@mwt
mwt / speedgrader.ahk
Last active August 18, 2022 19:14
An AutoHotkey script to grade assignments in Canvas SpeedGrader quickly using Numpad keys to score the question. For example, Numpad0 gives a score of zero. Make sure NumLock is on! This is intended for use in the grade by question mode. You may need to make adjustments based on browser metrics. Made for Firefox.
SetTitleMatchMode, 2
GradeAssignment(s)
{
WinActivate SpeedGrader ; Use window with "SpeedGrader" in name
CoordMode, Click, Window
WinGetPos, winX, winY, winWidth, winHeight, A
Y := winHeight * 0.26 ; Get textbox Y coordinate
tX := winWidth * 0.57 ; Get textbox X coordinate
rX := winWidth * 0.95 ; Arbitrary coordinate on right panel
@mwt
mwt / main.py
Last active April 11, 2023 07:23
GPU Accelerated Theil-Sen Estimator for Censored Data
## Define Akritas et al T-S estimator
def censoredts(data):
"""
This function takes a three-column cupy array where the first column is the
independent variable, the second is the dependent variable, and the third is
an indicator which tells us if the data has been censored.
"""
# Make an index for pairwise treatment of data
from itertools import combinations
indit = zip(*combinations(range(n),2))