Skip to content

Instantly share code, notes, and snippets.

View KirinDave's full-sized avatar

Dave Fayram KirinDave

View GitHub Profile
@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
package com.banksimple.util
private[util] final class Effectful[T](val origin: T) {
/**
* A special case of doto, andAlso is useful for
* quick logging or output tasks. Similar in use
* to doto, but only takes one function.
* */
def andAlso(x: T => Unit): T = { x(origin) ; origin }
task :clean do
important_cleans = `git clean -n -d`.split("\n")
important_cleans.reject! { |file|
file =~ /~$/ or
file =~ /#/ or
file =~ /.beam$/
}
if important_cleans.size > 0
puts "Refusing to clean because:"
puts important_cleans.join("\n")
@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 / 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)