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 / Building.md
Last active December 15, 2018 02:41
Instructions for using the Travis CI/Jitpack build system

Travis CI/Jitpack Build System

Unless otherwise specified, these files all go in the root of your Github repository.

Travis

We use Travis CI to build and test on each commit or pull request to the Github repository. The Travis setup is all the defaults, plus this as .travis.yml:

# Travis build script for mineman