Skip to content

Instantly share code, notes, and snippets.

View KirinDave's full-sized avatar

Dave Fayram KirinDave

View GitHub Profile
Dec 15, 2013 4:53:27 AM net.minecraft.launchwrapper.LogWrapper log
INFO: Loading tweak class name cpw.mods.fml.common.launcher.FMLServerTweaker
Dec 15, 2013 4:53:27 AM net.minecraft.launchwrapper.LogWrapper log
INFO: Using primary tweak class name cpw.mods.fml.common.launcher.FMLServerTweaker
Dec 15, 2013 4:53:27 AM net.minecraft.launchwrapper.LogWrapper log
INFO: Calling tweak class cpw.mods.fml.common.launcher.FMLServerTweaker
2013-12-15 04:53:27 [INFO] [ForgeModLoader] Forge Mod Loader version 6.4.45.953 for Minecraft 1.6.4 loading
2013-12-15 04:53:27 [INFO] [ForgeModLoader] Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_40, running on Linux:amd64:3.2.0-54-generic, installed at /usr/lib/jvm/java-7-oracle/jre
2013-12-15 04:53:27 [WARNING] [ForgeModLoader] The coremod codechicken.core.launch.DepLoader does not have a MCVersion annotation, it may cause issues with this version of Minecraft
2013-12-15 04:53:27 [WARNING] [ForgeModLoader] The coremod worldcore.asm.WCFMLLoadingPlugin does not have a MCV
@KirinDave
KirinDave / assoc-if.clj
Created February 21, 2014 00:32
I just wrote this today for building json structures out of destructured arguments.
(defn assoc-if
"Can someone explain to me how this is not in the stdlib?"
([h key value xformer]
(if-not (nil? value)
(assoc h key (xformer value))
h))
([h key value] (assoc-if h key value identity)))
### Keybase proof
I hereby claim:
* I am kirindave on github.
* I am kirindave (https://keybase.io/kirindave) on keybase.
* I have a public key whose fingerprint is E31F 2C5C 62E1 CB57 3B5B AF97 73DC C83A E5E6 E137
To claim this, I am signing this object:
-- I am so embararassed I wrote it this way. It literally is more characters.
totalBudgetObligationAt :: SimTick -> Budget -> Centocents
totalBudgetObligationAt now b = sum $ [currentSpendableObligationAt now,
currentExpenseObligationAt now,
currentSavingObligationAt now] <*> [b]
-- This code is the kind of code that makes me grumpy.
-- It exists because Node.URL uses nullable
-- (https://github.com/purescript-node/purescript-node-url/blob/master/src/Node/URL.purs#L17-L29)
-- But Node.HTTP.Client (a natural client of url parsing) uses Data.Options
-- (https://github.com/purescript-node/purescript-node-http/blob/master/src/Node/HTTP/Client.purs#L64-L96)
urlToOpts :: String -> Options RequestOptions
urlToOpts urlString = fold $
(assoc <$> pure protocol <*> toMaybe purl.protocol)
<> (assoc <$> pure path <*> toMaybe purl.path)
-- Normal data strcutures
data RecursiveList a = RNil
| RCons a (RecursiveList a)
exampleRlist :: RecursiveList Int
exampleRlist = RCons 1 (RCons 2 RNil)
foldRecList :: (b -> a -> b) -> RecursiveList a -> b -> b
foldRecList f lst basecase = helper basecase lst
-- Simplified Fix
newtype Fix f = Fix (f (Fix f))
-- Helper functions
fix :: f (Fix f) -> Fix f
fix = Fix
unfix :: Fix f -> f (Fix f)
unfix (Fix f) = f
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
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
{-# 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)