Skip to content

Instantly share code, notes, and snippets.

View tomsmeding's full-sized avatar
🦆

Tom Smeding tomsmeding

🦆
View GitHub Profile
@tomsmeding
tomsmeding / manual.hs
Last active January 22, 2024 20:58
Manually simulate prop_partition
-- Fill in the a, b, ps values from the quickhull-test failure message for the
-- 'partition' test below. Then start `cabal repl` and copy-paste this whole
-- thing in there. The output of the last command is what your 'partition' does
-- on this input.
import Data.Array.Accelerate.Interpreter
-- paste the printed values of a, b and ps here
a = (-454, -137)
b = (-286, -641)
@tomsmeding
tomsmeding / reformat_bridgebot.py
Created October 8, 2023 19:28
Weechat plugin for reformatting messages from bridged users
# -*- coding:utf-8 -*-
################################################################################
# Copyright (C) 2023 Tom Smeding
# https://tomsmeding.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@tomsmeding
tomsmeding / Main.hs
Created July 6, 2021 11:43
Automatically testing laws for Tree and RoseTree from assignment 1 of UU AFP '21
{-# LANGUAGE TypeApplications #-}
module Main where
import Data.Proxy
import Test.QuickCheck
import Test.QuickCheck.Classes
-- Definition of the types in assignment 1
data Tree a = Leaf a | Node (Tree a) (Tree a)
#!/usr/bin/env python3
import sys, time
use_fast = len(sys.argv) >= 2 and sys.argv[1] == "fast"
def print_lsp(msg):
print("Content-Length: {}\r\n\r\n{}".format(len(msg), msg), end="")
sys.stdout.flush()
print_lsp('{"method": "initialize", "jsonrpc": "2.0", "id": 1, "params": {"initializationOptions": {}, "rootUri": "file:///home/tom", "capabilities": {"workspace": {"workspaceFolders": false, "configuration": false, "symbol": {"dynamicRegistration": false}, "applyEdit": false, "didChangeConfiguration": {"dynamicRegistration": false}}, "textDocument": {"documentSymbol": {"dynamicRegistration": false, "hierarchicalDocumentSymbolSupport": false}, "references": {"dynamicRegistration": false}, "publishDiagnostics": {"relatedInformation": true}, "rename": {"dynamicRegistration": false}, "completion": {"completionItem": {"snippetSupport": false, "commitCharactersSupport": false, "preselectSupport": false, "deprecatedSupport": false, "documentationFormat": ["plaintext"]}, "contextSupport": false, "dynamicRe
@tomsmeding
tomsmeding / README.txt
Last active November 30, 2020 20:34
Crappy, but reasonably fast, scatter plots
To build everything, use 'make'. To build only datagen or only cpu, use 'make
datagen' or 'make cpu'.
For the GPU code, you might need to change the sm_61 in 'Makefile' to match
your NVIDIA GPU version.
To generate data, use './datagen 2000000 >data.txt' or similar. Format: one
line the number N, then a line with N random [0, 1] values, then another line
with N random [0, 1] values. First line is intended to be the x coordinates,
second line is the y coordinates.
@tomsmeding
tomsmeding / A1.hs
Last active August 31, 2020 11:53
Unused import warning is order-dependent?
module A1 (astuff) where
import C -- no warning!
import B
astuff :: Int
astuff = 10 + bstuff + cstuff
#!/usr/bin/env bash
# Written by Tom Smeding, released into the public domain.
# This produces the following directory structure:
# - $EXT/
# - stack/
# - stack # haskell stack executable
# - IHaskell/ # the IHaskell github repository clone
# - ihaskell # the ihaskell executable
EXT=/ih
#!/usr/bin/env python
import weechat
import re
weechat.register(
"matrix-reply",
"Tom Smeding",
"0.1",
"MIT",
"Reply helper for weechat-matrix buffers",
@tomsmeding
tomsmeding / Error.hs
Last active June 18, 2020 15:57
ghcide fails on this repository, because of the non-exported variable reference in a TH splice
{-# LANGUAGE TemplateHaskell #-}
module Error ( somethfunc ) where
import Language.Haskell.TH hiding ( Unsafe )
somethfunc :: Q Exp
somethfunc = [| glorifiedID |]
glorifiedID :: a -> a
glorifiedID = id
module Main where
import Submod
main :: IO ()
main = return ()