Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Wildrick Thomas mwt

View GitHub Profile
@mwt
mwt / README.md
Last active Mar 11, 2021
Jekyll include for utterances
View README.md

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 Jan 25, 2021 — forked from davidejones/handler_fieldstorage.py
aws lambda parsing multipart form with python3
View handler_fieldstorage.py
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 Mar 22, 2020
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.
View speedgrader.ahk
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 Mar 6, 2021
GPU Accelerated Theil-Sen Estimator for Censored Data
View main.py
## 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))
@mwt
mwt / README.md
Created Jan 16, 2020
Quick guide to GNU screen
View README.md

Basic usage

Single terminal

To launch screen, just run

screen

Then run all of your commands like stata -b do filename. When you want to "minimize" the terminal, just press Ctrl+A followed by the D key.

You can then safely log out of ssh without killing the precess that you ran.