Skip to content

Instantly share code, notes, and snippets.

View KirinDave's full-sized avatar

Dave Fayram KirinDave

View GitHub Profile
@KirinDave
KirinDave / crash.txt
Created August 15, 2020 20:02
Crash log, ATM5
---- Minecraft Crash Report ----
// Daisy, daisy...
Time: 8/15/20 12:52 PM
Description: Unexpected error
java.lang.NullPointerException: Registry Object not present: mahoutsukai:murky_flow
at java.util.Objects.requireNonNull(Unknown Source) ~[?:1.8.0_171] {}
at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[?:?] {re:classloading}
at stepsword.mahoutsukai.util.Utils.isInMurkyWater(Utils.java:158) ~[?:1.15.2-v1.21.6] {re:classloading}
@KirinDave
KirinDave / copyfile.sh
Created February 21, 2019 02:47
OSC 52 CopyFile Script
#!/bin/bash
# Convenient when you're using lots of in-browser terminals.
set -eu
MAXLEN=74994
TARGET=$1
if [ -f $TARGET ]; then
@KirinDave
KirinDave / stack-shell.bash
Created June 22, 2018 15:16
How to make stack manage ghc for you
stack exec --no-ghc-package-path --resolver ghc-8.4.3 --package cabal-install zsh
{-# Language DeriveFunctor, FlexibleInstances #-}
module Lib where
newtype Mu f = Mu (f (Mu f))
data ArithF f =
ALit Int |
AAdd f f |
ASub f f deriving Functor
@KirinDave
KirinDave / DictTrick.hs
Created May 25, 2018 17:35 — forked from jship/DictTrick.hs
Small example showing the Dict trick to discover available instances from a GADT
#!/usr/bin/env stack
-- stack --resolver lts-10.8 --install-ghc exec ghci
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
-- A key type for pretend use in looking up a doggo in a database.
newtype Key a = Key { unKey :: String }
data SomeThing = SomeThing { name :: Text, age :: Int }
makeSomeThing :: (Monad m) => m Text -> m Int -> m SomeThing
makeSomeThing nameE ageE = do
name <- nameE
age <- ageE
return $ SomeThing name age
package stupid
import (
"fmt"
"reflect"
"unsafe"
)
type iptr struct {
{-# LANGUAGE TypeFamilies, ScopedTypeVariables, OverloadedStrings, TemplateHaskell, RankNTypes #-}
module Main where
import Data.Map (Map(..), empty)
import Control.Lens
import Data.Monoid (mempty)
import Data.Text (Text(..))
import Control.Applicative (pure)
mergeSort :: Ord a => [a] -> [a]
mergeSort = hylo alg coalg where
alg EmptyF = []
alg (LeafF c) = [c]
alg (NodeF l r) = merge l r
coalg [] = EmptyF
coalg [x] = LeafF x
coalg xs = NodeF l r where
(l, r) = splitAt (length xs `div` 2) xs
createAndSumTree :: [Int] -> Int
createAndSumTree lst = hylo sum build lst where
sum (LeafF v) = v
sum (NodeF v0 v1) = v0 + v1
build [val] = LeafF val
build lst = NodeF l r
where (l, r) = splitAt (length lst `div` 2) lst