Skip to content

Instantly share code, notes, and snippets.

@mrkgnao
mrkgnao / futures.rs
Created March 1, 2020 15:06
oh so this is how futures work, huh
View futures.rs
use futures::prelude::*;
use futures::task::{Context, Poll};
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use tokio::time;
enum Noise {
PollMe,
WakeMe,
}
@mrkgnao
mrkgnao / ClientMain.hs
Created November 12, 2019 17:23
modified isomorphic miso example for dmjio
View ClientMain.hs
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import qualified Common
import Data.Proxy ( Proxy(..) )
import Control.Lens ( (^.), (+=), (-=), (.=), makeLenses )
import qualified Servant.API as S
import Servant.API ( (:<|>)(..) )
@mrkgnao
mrkgnao / ghostscript-pdf-crop.sh
Created October 8, 2018 16:32
Crop pdfs with GhostScript
View ghostscript-pdf-crop.sh
#!/usr/bin/env bash
set -euo pipefail
origdir=$(pwd)
tmpdir=$(mktemp -d)
echo "tmpdir: $tmpdir"
read -r width height < <(pdfinfo $1 | grep "Page size:" | sed 's/[a-zA-Z: ]*\([0-9]\+\)[x ]*\([0-9]\+\).*/\1 \2/')
npages=$(pdfinfo $1 | grep "Pages:" | sed 's/Pages: \+\([0-9]\+\).*/\1/')
echo "page count: $npages"
echo "(width, height) = ($width, $height)"
@mrkgnao
mrkgnao / spacemacs-tikz-preview.el
Last active January 30, 2021 08:44
TikZ preview in Emacs
View spacemacs-tikz-preview.el
;; In Spacemacs, this sets up:
;; - LaTeX previews (in \(...\) or \[...\]) with `, T x`
;; - TikZ preview (inside #+BEGIN_LaTeX ... #+END_LaTeX blocks) with C-c C-c
;;
;; All previews and exports use AMS Euler, which I like, and a suitable text
;; font to go with it.
;;
;; Other libraries (xy and so on) should also work if you add them to the
;; org-latex-packages-alist lines below.
;;
@mrkgnao
mrkgnao / Fmap.hs
Created March 13, 2018 08:36
@ekmett's iterated fmap
View Fmap.hs
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Fmap where
import Control.Category ((<<<), (>>>))
import Prelude hiding (map)
type Reader = (->)
@mrkgnao
mrkgnao / TopSites.hs
Created February 19, 2018 16:19
What hosts do you visit most often in Firefox?
View TopSites.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Protolude hiding ((:*:), optional)
import Database.Selda
@mrkgnao
mrkgnao / EvalStrategy.md
Last active January 2, 2018 15:25
What evaluation strategy to use for a Haskell-like language? (and other questions)
View EvalStrategy.md

I've been building an implementation of the "Sound and Complete" type system, as those of you who follow me on Twitter might know (hi!), and I'm fairly close to finishing the system of the paper.

I intend to extend it with support for the two things mentioned in the ending "Extensions" section:

  • constructors that take arguments

  • recursive types (like [ ])

and use it as a Core language for a new Haskell-like language. But I'm implementing an evaluator at present, as being able to "run" small programs is pretty motivating.

@mrkgnao
mrkgnao / MiniTodo.md
Last active October 19, 2018 21:38
A stripped-down Todo app in Reflex with lots of comments from Learn Reflex
View MiniTodo.md

MiniTodo

A heavily-commented, partly modified version of the stripped-down Reflex todo list from reflex-examples.

{-# LANGUAGE RecursiveDo, OverloadedLists, ScopedTypeVariables, OverloadedStrings  #-}

{-
 - A heavily-commented, partly modified version of the stripped-down Reflex todo list from reflex-examples
 -}
View config.nix
{
allowBroken = true;
allowUnfree = true;
permittedInsecurePackages = [
"webkitgtk-2.4.11"
];
}
@mrkgnao
mrkgnao / keymap.xkb
Created August 17, 2017 03:04
Under-construction XKB keymap: shift-reversed number row, modifiers galore, etc
View keymap.xkb
xkb_keymap {
xkb_keycodes "evdev+aliases(qwerty)" {
minimum = 8;
maximum = 255;
<ESC> = 9;
<AE01> = 10;
<AE02> = 11;
<AE03> = 12;
<AE04> = 13;
<AE05> = 14;