Skip to content

Instantly share code, notes, and snippets.

@matthayter
matthayter / capslock.ahk
Last active October 13, 2024 21:33
Autohotkey V2 script for making Caps Lock both Ctrl & Esc
; From @rhh4x0r on https://gist.github.com/volks73/1e889e01ad0a736159a5d56268a300a8
*CapsLock::
{
Send "{LControl down}"
}
*CapsLock up::
{
Send "{LControl Up}"
@matthayter
matthayter / heap.ts
Last active July 24, 2022 11:56
A (mediocre) heap implementation in Typescript
class MinHeap<T> {
// op: return true when a should be above b.
static fromMutableArr<T>(arr: T[], op: (a: T, b: T) => boolean) {
this.heapify(arr, op);
return new MinHeap<T>(arr, op);
}
static heapify<T>(arr: T[], op: (a: T, b: T) => boolean) {
let start = parent(arr.length - 1);
for (let i = start; i >= 0; i--) {
MinHeap.siftDown(arr, i, op);
@matthayter
matthayter / pync.py
Created March 27, 2020 17:54
Eventually planned to be a decent netcat replacement for windows.
import asyncio
import sys
import socket
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
from argparse import ArgumentParser
def parse_cl():
@matthayter
matthayter / capslock.ahk
Last active August 1, 2017 12:40
Autohotkey: Use Caps Lock as both CTRL and Escape: Hold for CTRL; tap for Escape.
SetCapsLockState Off
*CapsLock::
key=
Input, key, B C L1 T1, {Esc}
if (ErrorLevel = "Max")
if key {
Send {Ctrl Down}
Send {Blind}%key%
}
@matthayter
matthayter / monty_hall.js
Created February 17, 2016 19:05
A demonstration of the Monty Hall problem.
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
var monty = function(doSwitch) {
var tryCount = 10000;
var winCount = 0.0;
for (var i = 0; i < tryCount; i++) {
var car = getRandomInt(0, 3);
import Data.Matrix
import Data.Maybe
import Data.List
import Data.Char
import Control.Monad
import qualified Data.Vector
type Puzzle = Matrix (Maybe Int)
puzzle = puzzleFromLines
@matthayter
matthayter / curl-format.txt
Created July 23, 2014 23:35
Curl timing-info config: To be run with curl -w "@curl-format.txt" -o /dev/null -s http://...
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n