Skip to content

Instantly share code, notes, and snippets.

View config
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 Sep 9, 2019
Terminal character widths
View Main.hs
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
View 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
Docker build for glirc
View Dockerfile
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 Jan 29, 2019
.config/glirc/config
View 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"
View MegaparseVersion.hs
module Demo where
import Text.Megaparsec
import Text.Megaparsec.Char
type Parser = Parsec (ErrorItem Char) String
demo :: String -> IO ()
demo = parseTest parser
View randoms.hs
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 Jul 31, 2018
variable-length message binary protocol parser combinators
View Parser.hs
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)
View vinyl elfield monoid.hs
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
View blankhart.hs
{-# 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)