Skip to content

Instantly share code, notes, and snippets.

View KirinDave's full-sized avatar

Dave Fayram KirinDave

View GitHub Profile
-- 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
-- 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
-- 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)
-- 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]
### 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:
@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)))
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 / gist:6117117
Last active December 20, 2015 10:39 — forked from danryan/gist:6116878
HTTP/1.1 200 OK
Server: Turtle
Content-Type: application/turtles; charset=turtles
{
"turtles": {
"turtles": {
"turtles": {
"turtles": {
"turtles": {
"turtles": {
@KirinDave
KirinDave / gist:5749499
Created June 10, 2013 15:08
Looks like an issue in Xeno w/ latest forge.
java.lang.NoSuchMethodError: xreliquary.items.ItemCondensedPotion.func_77636_d(Lnet/minecraft/item/ItemStack;)Z
at xreliquary.items.ItemCondensedPotion.func_77659_a(ItemCondensedPotion.java:635)
at net.minecraft.item.ItemStack.func_77957_a(ItemStack.java:173)
at net.minecraft.item.ItemInWorldManager.func_73085_a(ItemInWorldManager.java:349)
at net.minecraft.network.NetServerHandler.func_72472_a(NetServerHandler.java:539)
at net.minecraft.network.packet.Packet15Place.func_73279_a(SourceFile:58)
at net.minecraft.network.TcpConnection.func_74428_b(TcpConnection.java:461)
at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:134)
at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:53)
at net.minecraft.server.dedicated.DedicatedServerListenThread.func_71747_b(SourceFile:30)
class FizzBuzz
def initialize
@printed = nil
@printers = [ lambda {|x| print (@printed = "Fizz") if x % 3 == 0},
lambda {|x| print (@printed = "Buzz") if x % 5 == 0},
lambda {|x| print (@printed = "Bazz") if x % 7 == 0} ]
end
def for_num(i)