Skip to content

Instantly share code, notes, and snippets.

@Munksgaard
Munksgaard / audio.fut
Created December 22, 2022 10:50
A futhark literate script showing how we can create audio
-- # Generating audio with literate Futhark
--
-- Sound is vibrations in the air that are picked up by our ears. Vibrations
-- can be described using sine-curves. Computers are ultimately discrete in
-- nature, so in order to produce sound we have to approximate sine-curves using
-- sampling. Let's see how that works in practice.
-- We start by defining some global variables that we're going to use.
-- First, the volume which we wish to output at.
@Munksgaard
Munksgaard / Makefile
Created December 20, 2022 19:15
Music in Futhark
.PHONY: all
all:
futhark c futmusic.fut
rm -f output.wav
echo "" | ./futmusic -b | tail -c+18 | head -c-1 | ffmpeg -f s8 -i - output.wav
mpv output.wav
@Munksgaard
Munksgaard / gist:f35769477104185bc529c7df43c80d75
Last active December 15, 2022 10:49
Fun types counterexamples
let (y: Int) = 42
let (xss: [y][x]Int) =
kernel x <= y do
let (xs: [x]Int) = iota(x)
in (xs)
let (z: Int) = 42
let (xs: [x]Int) =
if z then
let (x: Int) = 4
maybeHead :: a -> [a] -> a
maybeHead _ (x : _) = x
maybeHead x _ = x
treeFold :: Show a => (a -> a -> a) -> a -> [a] -> a
treeFold f neutral = treeFold' []
where
treeFold' ((i1, x1) : (i2, x2) : rest) xs
| i1 == i2 = treeFold' ((i1 + 1, f x1 x2) : rest) xs
treeFold' acc (x1 : x2 : rest) = treeFold' ((0, f x1 x2) : acc) rest
@Munksgaard
Munksgaard / external-data.txt
Last active April 16, 2022 20:31
A tool to get datta from external sources, e.g. ERDA. An alternative to git-annex or LFS
.external-data/rodinia/hotspot/data/1024.in https://sid.erda.dk/share_redirect/FlhwY8rtfk/rodinia/hotspot/1024.in 3ead297c7a98339297ba0fd351aa3e364b476aac4afe9fb568271e73741adf7b
.external-data/rodinia\ 5/hotspot/data/1024.in https://sid.erda.dk/share_redirect/FlhwY8rtfk/rodinia/hotspot/1024.in 3ead297c7a98339297ba0fd351aa3e364b476aac4afe9fb568271e73741adf7b
@Munksgaard
Munksgaard / Dockerfile
Created April 7, 2022 09:48
docker with futhark
FROM nvidia/cuda@sha256:01d41694d0b0be8b7d1ea8146c7d318474a0f4a90bfea17d3ac1af0328a0830b
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y libz3-4 libz3-dev haskell-stack libtinfo-dev libgmp-dev zlib1g-dev
RUN git clone https://github.com/diku-dk/futhark
WORKDIR "futhark"
RUN stack upgrade
- SimpleDB. A basic rdbms built from scratch: https://www.awelm.com/posts/simple-db/
- Writing a SQL database from scratch in Go: https://notes.eatonphil.com/database-basics.html
- Let's Build a Simple Database: https://cstack.github.io/db_tutorial/
- Foundations of Databases: http://webdam.inria.fr/Alice/
@Munksgaard
Munksgaard / grammar.js
Created February 11, 2022 09:26
futhark tree-sitter grammar
module.exports = grammar({
name: 'futhark',
rules: {
source_file: $ => repeat($.dec),
identifier: $ => /_?[A-Za-z][A-Za-z0-9_\']*/,
_quals: $ => repeat1(
seq($.identifier, '.')
;; Emoji: 😄, 🤦, 🏴󠁧󠁢󠁳󠁣󠁴󠁿
(defun set-fonts ()
(set-fontset-font t 'symbol "Apple Color Emoji")
(set-fontset-font t 'symbol "Noto Color Emoji" nil 'append)
(set-fontset-font t 'symbol "Segoe UI Emoji" nil 'append)
(set-fontset-font t 'symbol "Symbola" nil 'append))
;; run this hook after we have initialized the first time
(add-hook 'after-init-hook 'set-fonts)
;; re-run this hook if we create a new frame from daemonized Emacs
(use-package magit
:ensure t
:bind (("C-c m" . magit-status)
("C-c b" . magit-blame)
("C-x g" . magit-status)
("C-x M-g" . magit-dispatch))
:config
(setq magit-diff-options (quote ("--word-diff")))
(setq magit-diff-refine-hunk 'all)
(add-hook 'magit-mode-hook (lambda () (local-unset-key [C-tab])))