Skip to content

Instantly share code, notes, and snippets.

@glguy
glguy / config
Last active September 2, 2020 03:40
macros: @load: "macros.cfg"
palette: @load: "palette.cfg"
$fn-iline: command: ["get-iline-password"]
$fn-auth:
sasl: mechanism: external
tls: starttls
tls-client-cert: "freenode.pem"
tls-client-key-password: command: ["get-private-key-password"]
@glguy
glguy / Main.hs
Created September 9, 2019 20:44
Terminal character widths
module Main where
import System.Console.ANSI
import System.IO
import Data.List
import Data.Traversable
import Graphics.Text.Width (wcwidth)
import Data.Char
import Data.Foldable
import Text.Printf
@glguy
glguy / keybase.md
Created May 19, 2019 06:52
keybase.md

Keybase proof

I hereby claim:

  • I am glguy on github.
  • I am glguy (https://keybase.io/glguy) on keybase.
  • I have a public key ASA1Mm7LFFjnWTaFi8BWxWpscvOYXSVXSq2SC9QZmPJzkwo

To claim this, I am signing this object:

@glguy
glguy / Dockerfile
Created May 15, 2019 03:42
Docker build for glirc
FROM haskell:8.6
RUN apt-get update && apt-get install -y libssl-dev
RUN cabal v2-update
WORKDIR /opt/glirc
ADD dist-newstyle/sdist/glirc-2.31.tar.gz ./
RUN cd glirc-2.31 && cabal v2-build --only-dependencies
RUN cd glirc-2.31 && cabal v2-build
@glguy
glguy / config
Created January 29, 2019 18:47
.config/glirc/config
extensions:
* "glirc-otr.bundle" -- off-the-record support
* path: "~/Source/glirc/lua-extension/builddir/glirc-lua.bundle"
args: [ "spam_bot/extension.lua" ]
macros:
* name : "accounts"
commands: "who $channel %tuhna,616"
* name : "lua"
module Demo where
import Text.Megaparsec
import Text.Megaparsec.Char
type Parser = Parsec (ErrorItem Char) String
demo :: String -> IO ()
demo = parseTest parser
randomCoords :: StdGen -> [(Int,Int)]
randomCoords g = (rnx1, rny1) : randomCoords g2
where
(rnx1, g1) = randomR (1, heightMax) g
(rny1, g2) = randomR (1, widthMax) g1
@glguy
glguy / Parser.hs
Last active July 31, 2018 03:27
variable-length message binary protocol parser combinators
module Parser where
import qualified Data.ByteString as B
import Data.Word
import Control.Monad (replicateM)
import System.IO
data Parser s f a
= Blind !Int (s -> a)
| Decide !Int (s -> Parser s f a)
instance ('(a,b) ~ x, Semigroup b) => Semigroup (ElField x) where
Field x <> Field y = Field (x <> y)
instance ('(a,b) ~ x, KnownSymbol a, Monoid b) => Monoid (ElField x) where
mempty = Field mempty
{-# Language TypeOperators, FlexibleContexts, DeriveGeneric #-}
module Demo where
import Control.Lens
import GHC.Generics ( (:+:)(L1,R1), M1, K1, Generic, Rep)
import GHC.Generics.Lens (_M1, _K1, generic)
data A = A Int deriving (Show, Generic)
data B = B Int deriving (Show, Generic)
data C = CA A | CB B deriving (Show, Generic)