Skip to content

Instantly share code, notes, and snippets.

View Lazersmoke's full-sized avatar

Sam Quinn Lazersmoke

View GitHub Profile
@Lazersmoke
Lazersmoke / accessors.hs
Created May 30, 2016 21:05
This is my off-the-top-off-my-head lightweight lens alternative
-- Data decls could be in their own module for qualified import?
-- Alternatively, there might be a solution in GHC 8's duplicate record fields...
-- Only thing to update to add fields is the accessor functions
-- Test with an int and a str
data Test = MkTest Integer String deriving (Eq,Show)
number :: Access Integer Test
number f (MkTest n s) = (f n, MkTest (f n) s)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
for i in `seq 1 50`;
do
wget "https://play.esea.net/index.php?s=stats&last_type_scope=all&game_id=25&sort_by=frags&sort_dir=desc&type_scope=all&d=overall&period[type]=months&period[date_start]=2016-04-01&page=$i" -O "eseadata$i"
done
@Lazersmoke
Lazersmoke / EncodingPublicKey.hs
Created January 16, 2017 17:16
This is how to manually serialize an RSA key for usage in a Minecraft Encryption Request packet for example.
module EncodingPublicKey where
import Data.Maybe
import Data.Semigroup
import Data.Bits
import OpenSSL.RSA
import qualified Data.ByteString as BS
-- Observe the cancer, but don't touch it or you'll contract it.
encodePubKey :: RSAKeyPair -> BS.ByteString
@Lazersmoke
Lazersmoke / ghostbuster.hs
Created March 2, 2017 02:35
A generic way to use existential quantification to generalize data over type variables.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
import GHC.Exts (Constraint)
@Lazersmoke
Lazersmoke / myclass.hs
Created March 16, 2017 02:48
MyClass a => a
class MyClass a where
value :: a
instance MyClass Char where
value = 'a'
instance MyClass Int where
value = 5
something :: MyClass a => a
@Lazersmoke
Lazersmoke / FreerFork.hs
Created April 28, 2017 13:16
Forking Freer Monads
class Fork q where
type RuntimeConstraint q x :: Constraint
fork :: RuntimeConstraint q r => Eff (q ': r) a -> q (Eff r a)
data MyEffect a where
ForkMyEffect :: Member IO r => Eff (MyEffect ': r) a -> MyEffect (Eff r a)
Say :: MyEffect ()
instance Fork MyEffect where
type RuntimeConstraint MyEffect x = Member IO x
@Lazersmoke
Lazersmoke / BooleanEvaluatorCodeReview.md
Created August 22, 2017 02:12
Code review of proofskiddie's boolean evaluator
@Lazersmoke
Lazersmoke / FeedExtract.md
Created August 30, 2017 00:59
Code Review of tchoutri's feed-extract

Code Review of tchoutri's feed-extract

Original Code

Error Log

IO String vs IO ()

The vast majority of the errors are because your functions (particularly help and version) are IO String when they should really be IO (). All of the alternatives in a case must have the same type, all the expressions in a do block must have the same base monad, and the last expression in a do block must have the same type as the do block overall. Let's look at your main function:

@Lazersmoke
Lazersmoke / MemeMana.md
Last active February 18, 2018 23:49
How-to guide for using MemeMana

MemeMana

MemeMana is the essence plugin, which is new in the 1.12 update.

What is Mana?

Mana is a virtual resource you get for playing on the server. If you log in multiple days in a row, you get a login streak, meaning you get more Mana each day. If you stop logging in, your streak will go down over time. This means that logging in each day will give you the most Mana, but if you miss a day, it's not that big of a deal.