Skip to content

Instantly share code, notes, and snippets.

View Lazersmoke's full-sized avatar

Sam Quinn Lazersmoke

View GitHub Profile
@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 / 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 / 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
#!/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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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)