Skip to content

Instantly share code, notes, and snippets.

View dmwit's full-sized avatar

Daniel Wagner dmwit

View GitHub Profile
#include "32x32to64mul.h"
uint64_t mul64(uint32_t, uint32_t);
@dmwit
dmwit / haskell.vim
Created March 9, 2022 15:53
quickly add/remove Debug.Trace to a module
" drop this in your ftplugin directory
nnoremap <silent> <buffer> <leader>db :call AddDebugImport()<cr>
inoremap <silent> <buffer> <leader>db <c-o>:call AddDebugImport()<cr>
nnoremap <silent> <buffer> <leader>de :call DeleteDebugImport()<cr>
inoremap <silent> <buffer> <leader>de <c-o>:call DeleteDebugImport()<cr>
" TODO: does not work well with literate Haskell or funky module indentations
function! AddDebugImport()
let s:orig_pos = winsaveview()
@dmwit
dmwit / EF.hs
Created June 12, 2021 06:35
MonadLogic, but both associations of >>- are productive
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
import Control.Applicative
import Control.Monad
import Data.Maybe
-- explicit failure
newtype EF a = EF { unEF :: [Maybe a] }
deriving (Eq, Ord, Read, Show, Functor, Foldable, Traversable)
@dmwit
dmwit / dr-mario-droughts.txt
Last active November 25, 2020 02:06
how long do you have to wait for a specific kind of pill?
Drought lengths when you need any pill with the color Red
fromOccurList [(0,2271060),(1,1025779),(2,426448),(3,212578),(4,119886),(5,64270),(6,32290),(7,17444),(8,10093),(9,5837),(10,3349),(11,2017),(12,1196),(13,711),(14,435),(15,246),(16,126),(17,71),(18,60),(19,51),(20,30),(21,24),(22,18),(23,16),(24,13),(25,13),(26,13),(27,8),(28,8),(29,8),(30,8),(31,8),(32,8),(33,8),(34,8),(35,8),(36,8),(37,8),(38,7),(39,7)]
Drought lengths when you need any pill with the color Yellow
fromOccurList [(0,2451242),(1,984260),(2,371277),(3,200237),(4,102153),(5,41453),(6,20140),(7,10668),(8,6059),(9,3258),(10,1688),(11,878),(12,464),(13,215),(14,93),(15,28),(16,12),(17,12),(18,12),(19,12),(20,12),(21,3)]
Drought lengths when you need any pill with the color Blue
fromOccurList [(0,2267753),(1,1004235),(2,373081),(3,256850),(4,142434),(5,67329),(6,36127),(7,20286),(8,11516),(9,6509),(10,3711),(11,2036),(12,1093),(13,572),(14,271),(15,120),(16,52),(17,45),(18,44),(19,43),(20,43),(21,20),(22,2),(23,1),(24,1),(25,1),(26,1)]
Dr
@dmwit
dmwit / xmonad.hs
Created September 6, 2020 15:01
the barest UpdatePointer config
import XMonad
import XMonad.Actions.UpdatePointer
main = xmonad def
{ logHook = updatePointer (0.5, 0.5) (1, 1)
}
data Nat = Zero | Succ Nat | Twice Nat Nat deriving (Eq, Ord, Read, Show)
half :: Nat -> Nat
half Zero = Zero
half (Succ n) = half n
half (Twice _ n) = n
-- pred
p :: Nat -> Nat
p Zero = Zero
screen1LogHook :: D.Client -> PP
screen1LogHook dbus = def
{ ppOutput = dbusOutput dbus
, ppCurrent = wrap ("%{B#2f2f4a80}%{F" ++ cPink ++ "}%{o"++ cPurpBlue ++"}%{A4:xdotool key alt+shift+Right:}%{A5:xdotool key alt+shift+Left:} ") " %{A}%{A}%{-o}%{B- F-}" -- Focused wkspc
, ppVisible = wrap ("%{F" ++ cBlue ++ "} ") " %{F-}" -- not working
, ppVisibleNoWindows = Just (wrap ("%{F" ++ cMagenta ++ "} ") " %{F-}") -- not working
, ppUrgent = wrap ("%{F" ++ cRed ++ "}%{A4:xdotool key alt+shift+Right:}%{A5:xdotool key alt+shift+Left:} ") " %{A}%{A}%{F-}" -- Urgent wkspc
, ppHidden = wrap ("%{F" ++ cPurpBlue ++ "}%{A4:xdotool key alt+shift+Right:}%{A5:xdotool key alt+shift+Left:} ") " %{A}%{A}%{F-}" -- Hidden with windows
, ppHiddenNoWindows = wrap ("%{F" ++ cEmpty ++ "}%{A4:xdotool key alt+shift+Right:}%{A5:xdotool key alt+shift+Left:} ") " %{A}%{A}%{F-}" -- Hidden and empty
, ppWsSep = ""
--- test.hs.old 2020-04-16 20:27:41.179931585 -0400
+++ test.hs.new 2020-04-16 20:29:04.908156993 -0400
@@ -88,17 +88,17 @@
play (play_movement board Player (read col::Int)) Machine strat
--WIP
-machine_turn :: Board -> Strategy -> Board
+machine_turn :: Board -> Strategy -> IO Board
machine_turn board Random = machine_random_ia board
@dmwit
dmwit / gist:cb7e2a9e70acb004ba5ddd07aea1ec7c
Created April 16, 2020 08:27
can somebody explain this to me please?
% cat /proc/24430/cmdline | cut -b1-30
nurse-sveta-multi-play-t0.75
% pgrep sveta-mul
24430
% pgrep sveta-mult
zsh: exit 1 pgrep sveta-mult
% cat /proc/24430/cmdline | cut -b1-30
nurse-sveta-multi-play-t0.75
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
data Nat = O | S Nat