Skip to content

Instantly share code, notes, and snippets.

View porglezomp's full-sized avatar
💖
GITHUB DROP ICE

Cassie Jones porglezomp

💖
GITHUB DROP ICE
View GitHub Profile
@porglezomp
porglezomp / sat.py
Created January 14, 2021 08:54
A really basic DPLL SAT solver
import sys
# (a | b) & (~b | c)
# [[a, b], [~b, c]]
# [[1, 2], [-2, 3]]
# (a | b) & (~b | c) & (b)
# b is true
# (a | T) & (F | c) & (T)
# T & (c) & T
@porglezomp
porglezomp / postexec.fish
Last active January 10, 2021 22:19
Send a notification when a long-running command finishes.
# I have this inside my .config/fish/config.fish, but you migh be able to put it in .config/fish/functions ?
function show_notif --on-event fish_postexec
set -l duration $CMD_DURATION
set -l command $argv
if [ $duration -gt 10000 ]
set -l is_front (osascript -e 'tell application "Terminal" to frontmost')
if [ $is_front != "true" ]
osascript -e "display notification \"Command `$command` finished running after "(expr $duration / 1000)"s\" with title \"Command finished\""
end
end
@porglezomp
porglezomp / 00-README.md
Last active January 10, 2021 22:19
Goto scripts

Goto

These scripts goto and label let you handle jumping around to directories that you want to get to frequently, without having to figure out the path relative to where you are currently. To create a location, go to the directory you care about, then type label <name>. After you've done that, you're able to type goto <name> at any time to jump directly to that location.

Installation

To install on fish, copy the fish scripts into the locations listed at the top of them. To install on bash/sh/etc., copy the goto-label.sh into the end of your .profile, .bash_profile, or whatever else you have your config code in.

@porglezomp
porglezomp / codl-pep.rst
Last active January 10, 2021 01:58
codl pep

PEP: 9999 Title: Add Lab to colorsys Author: Cassie Jones <code@witchoflight> codl Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 28-Nov-2017 Python-Version: 3.7 Post-History: 30-Aug-2002

@porglezomp
porglezomp / twitter-alt-to-title.js
Created June 19, 2020 17:41
Twitter Alt-Text to Title-Text
// ==UserScript==
// @name Twitter Alt-Text to Title-Text
// @description Copy the alt attribute of twitter images into the title attribute, so that I can see the alt text on hover.
// @version 1
// @grant none
// @include https://twitter.com/*
// ==/UserScript==
const SELECTORS =
` .tweet .AdaptiveMedia-photoContainer img
@porglezomp
porglezomp / hovalaag.vim
Last active September 28, 2020 19:04
A vim syntax definition for HOVALAAG
" Vim syntax file
" Language: HOVALAAG Assembly
" Maintainer: Cassie Jones
" Latest Revision: 20 September 2020
" See the game at http://silverspaceship.com/hovalaag/
" Get updates at https://gist.github.com/porglezomp/690bb0f75883dc69350174b576ad643f
syntax case ignore
syn match vasmOperator "[+->|&^~]"
@porglezomp
porglezomp / process.py
Last active September 15, 2020 01:44
A script to generate a "Bad Apple" video out of lichess.org chess boards
#!/usr/bin/env python3
# See the finished video at https://youtu.be/HWJhm25RPXA
import functools
import json
import random
import subprocess
import time
from pathlib import Path
from PIL import Image
@porglezomp
porglezomp / example.c
Created April 7, 2020 21:26
Load unless there's a segfault
// gcc example.c try_load.c
#include "try_load.h"
#include <stdio.h>
void try_to_load(const uint8_t *address) {
uint8_t value;
if (try_load_u8(address, &value)) {
printf("Successfully load from address %p: %d\n", address, value);
} else {
@porglezomp
porglezomp / makefile
Created January 20, 2020 02:25
Convert the "Item Block Heights" video into a summary image
# Convert the "Item Block Heights" video into a summary image
# Video: https://www.youtube.com/watch?v=JteRFzrF6U4
# Image: https://twitter.com/porglezomp/status/1219082110704791555
all: abcheight.png
input.mp4:
youtube-dl -f mp4 'JteRFzrF6U4' -o input.mp4
frames: input.mp4
-- This is a group with a set g, an operation *, and an identity e
record Group g ((*) : g -> g -> g) (e : g) where
constructor MkGroup
-- each of these fields provides a witness of one of the group laws
assoc : (a, b, c : g) -> (a * b) * c = a * (b * c)
ident : (a : g) -> (a * e = a, e * a = a)
inverse : (a : g) -> (b : g ** (a * b = e, b * a = e))
-- Given two groups g1 and g2, with identities e and e', e must be e'
uniquenessOfId : (g1 : Group g o e) -> (g2 : Group g o e') -> e = e'