Skip to content

Instantly share code, notes, and snippets.

@turnage
turnage / connection.rs
Last active March 10, 2020 03:19
Network Interface
/// An identifier for a stream which is unique on a single connection.
///
/// A stream is a logical sequence of datagrams.
///
/// A stream may be strictly ordered, gauranteeing that all packets
/// are received at the endpoint in order (e.g. 1, 2, 3, 4, 5, ...).
///
/// Alternatively a stream may be only sequenced, a weaker property
/// that gaurantees all packets received by the endpoint are new,
/// but some may be missed (e.g. 1, 2, 5, ...).
@turnage
turnage / PrimeSieve.hs
Created January 27, 2020 03:23
Simple Prime Sieve
data Sieve = Sieve
{ limit :: Int
, position :: Int
, product :: Int
, sieve :: [Int]
, count :: Int
}
uniquePrimes :: Sieve -> Maybe (Int, Sieve)
uniquePrimes (Sieve limit position product sieve count) = if product * position > limit
@turnage
turnage / Colour.hs
Last active September 18, 2018 18:20
Haskell Art Tutorial
module Colour (setColour) where
import Data.Colour
import Data.Colour.RGBSpace
import Data.Colour.SRGB
import Graphics.Rendering.Cairo
class CairoColour d where
withColour :: d -> (Pattern -> Render ()) -> Render ()
@turnage
turnage / CLA.md
Created February 18, 2017 18:28 — forked from pjcozzi/CLA.md
CLA for MIT license

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the MIT license; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the MIT license; or

@turnage
turnage / announcer.go
Last active August 23, 2016 20:48
Example graw Bot
package main
import (
"fmt"
"github.com/turnage/graw"
"github.com/turnage/redditproto"
)
type announcer struct{}