Skip to content

Instantly share code, notes, and snippets.

View mcschroeder's full-sized avatar

Michael Schröder mcschroeder

View GitHub Profile
@mcschroeder
mcschroeder / subscript.hs
Last active February 5, 2021 18:04
Convert numeric suffixes to Unicode subscripts
import qualified Data.Text as Text
suffixToSubscript :: Text -> Text
suffixToSubscript t = case spanEnd isDigit t of
("", _) -> t
(_, "") -> t
(t1, s) -> t1 <> Text.map toSubscript s
toSubscript :: Char -> Char
toSubscript c = if isDigit c then chr (ord c + 8272) else c
From cd75ebc1752dd66dcc7fcaa9e1288fa5026873e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Schr=C3=B6der?= <mc.schroeder@gmail.com>
Date: Mon, 14 Mar 2016 13:29:10 +0100
Subject: [PATCH 1/2] Add STM finalizers
This introduces a new function
atomicallyWithIO :: STM a -> (a -> IO b) -> IO b
Like the existing atomically operation, atomicallyWithIO transforms a
@mcschroeder
mcschroeder / Key.hs
Created February 10, 2016 21:07
Getting values out of types at runtime
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Key (Key, makeKey) where
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Proxy
import GHC.TypeLits
@mcschroeder
mcschroeder / serial.sh
Created December 12, 2015 12:46
Create virtual serial ports
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage: $0 name"
exit 1
fi
MASTER=$1
SLAVE=$1_virt
@mcschroeder
mcschroeder / gist:8906117
Created February 9, 2014 21:22
Vigenère cipher cracker
-- DISCLAIMER:
-- I wrote this when I was just beginning to learn Haskell.
-- I recently found it again and wanted to preserve it.
-- It's probably terrible code. I haven't looked it over.
import Data.Char
import Data.List
import Data.Maybe
import Data.Function