Skip to content

Instantly share code, notes, and snippets.

lynn / PrettyParseError.hs
Last active Oct 20, 2020
Pretty ParseErrors for Text.Parsec
View PrettyParseError.hs
module PrettyParseError (
) where
import Data.List (intercalate, nub)
import Text.Parsec
import Text.Parsec.Error
import Text.Parsec.Pos
lynn /
Last active Mar 19, 2020
A bitwise-magic fractional part function
/// A "fractional part" function on f32s that does bitwise magic
/// on the representation of its argument.
pub fn frac(f: f32) -> f32 {
/// A "fractional part" function that operates on a signed integer
/// representation of an IEEE single-precision floating point number.
fn _frac(i: u32) -> u32 {
// A floating point number consists of a sign bit,
View mod1.c
#include <stdint.h>
#include <stdio.h>
typedef float f32;
typedef int32_t i32;
f32 mod1(f32 f) {
i32 i = *(i32*)&f;
i32 e = (i >> 23) & 0xff;
i32 m = i & 0x7fffff;
lynn / now-i-am-an-arsonist
Last active Feb 23, 2020
"Now I Am An Arsonist" by Jonathan Coulton (feat. Suzanne Vega) chords for soprano ukulele
View now-i-am-an-arsonist
"Now I Am An Arsonist"
by Jonathan Coulton (feat. Suzanne Vega)
chords for soprano ukulele
Capo on 1st fret, or tune up a semitone to G# C# E# A#.
Pattern 1 (C lydian)
# To use this, you need Python 3.5+ and pip.
# 1. Make a new Discord app with a bot.
# 2. Set environment variable SIMPLEWORDS_TOKEN on your computer to the bot's Token.
# Unix/Mac: export SIMPLEWORDS_TOKEN=MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N
# PowerShell: $env:SIMPLEWORDS_TOKEN='MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N'
# 3. Invite the bot to your server:
lynn /
Last active Feb 5, 2020
play just-intonation chord progressions in your terminal
#!/usr/bin/env python
# python3.8 --help
# python3.8 CEGBb CE-GBbL | aplay -r44 -f S16_LE
# python3.8 CEGBb CE-GBbL | ffmpeg -f s16le -ar 44.1k -ac 1 -i - ji.mp3
Play chord progressions in just intonation.
Raw PCM audio is written to stdout (signed, 16-bit, LE, mono).
#!/usr/bin/env python
# Listen to justly-tuned progressions.
# python3.8 1+5:4+7:4 1+4:3+5:3 1+5:4+6:4 1+5:4+7:5 3:4+9:8+4:3 1:2+3:4+5:4 | aplay -r44 -f S16_LE
# python3.8 1+5:4+3:2 15:16+9:8+3:2 1+5:4+3:2 | ffmpeg -f s16le -ar 44.1k -ac 1 -i - out.mp3
import struct
import sys
lynn /
Last active Jul 29, 2019
lynn's internet english idiolect

lynn's internet english idiolect

I wanted to write this little document explaining how "the English I use on the Internet" differs from the English you might read in a newspaper.

I should note: these rules apply in a "direct messaging" or "chatroom" kind of scenario, and also on Twitter. Elsewhere, especially in long-form forum-style environments where I have paragraphs and Markdown, I tend to tone it down. I'll still use emoticons and abbreviations, but try to capitalize and punctuate in a standard way. (This seems kind of common when I compare, say, StackExchange posts versus chatrooms: plenty of members capitalize in the former but not the latter.)

capitalization and punctuation

  • Sentences don't start with a capital letter.
  • I almost always capitalize the word I, because I think it looks weird otherwise. I sometimes lowercase it for effect, as sort of a "hushed voice" thing.
View annotate-twitter-usernames.user.js
// ==UserScript==
// @name annotate twitter usernames
// @namespace
// @version 0.1
// @description annotate twitter usernames
// @author lynn
// @match*
// @grant GM_addStyle
// ==/UserScript==
lynn /
Last active May 5, 2019
Inject rules into the rikaichan/rikaikun `deinflect.dat` file
# usage: python
# (reads deinflect.dat in same folder, writes to new-deinflect.dat)
import fileinput
# Bitmask values
CONJ_RU_VERB = 0x0001
CONJ_U_VERB = 0x0002
CONJ_I_ADJ = 0x0004
You can’t perform that action at this time.