Skip to content

Instantly share code, notes, and snippets.

@mrkgnao
mrkgnao / futures.rs
Created Mar 1, 2020
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 Nov 12, 2019
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 Oct 8, 2018
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 Apr 22, 2020
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.
;;
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 Feb 19, 2018
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 Jan 2, 2018
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 Oct 19, 2018
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 Aug 17, 2017
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;
You can’t perform that action at this time.