Skip to content

Instantly share code, notes, and snippets.

View jlamothe's full-sized avatar

Jonathan Lamothe jlamothe

  • Fingerprint Software
  • Kitchener, ON, Canada
View GitHub Profile
@jlamothe
jlamothe / lockpick.hs
Created April 5, 2020 05:01
lockpick
{-
lockpick.hs
Copyright (C) 2020 Jonathan Lamothe <jonathan@jlamothe.net>
This work is licensed under the Creative Commons CC BY-SA 3.0 License.
To view a copy of the license, visit
<https://creativecommons.org/licenses/by-sa/3.0/>
-}
@jlamothe
jlamothe / Pizza.hs
Created April 12, 2015 21:21
Pizza.hs
module Pizza ( Pizza (..)
, Topping (..)
) where
data Pizza = Pizza [Topping]
deriving (Eq, Show)
data Topping =
Pepperoni |
GreenPepper |
@jlamothe
jlamothe / bug.hs
Created December 13, 2012 01:02
I appear to be running into a bug with the mapRGB function in the SDL library. This code should render a white circle, but it's coming out cyan instead. The following appears to be relevant: http://stackoverflow.com/questions/3286864/why-is-this-haskell-sdl-line-cyan-when-it-should-be-white
import qualified Graphics.UI.SDL as SDL
import qualified Graphics.UI.SDL.Primitives as Draw
main = SDL.withInit [SDL.InitEverything] $ do
SDL.setVideoMode 640 480 32 [SDL.Fullscreen]
>>= drawScreen
eventLoop
drawScreen :: SDL.Surface -> IO ()
drawScreen s = do
@jlamothe
jlamothe / crc16.c
Created May 12, 2012 12:47
CRC16 checksum calculator
#include <stdint.h>
#define CRC16 0x8005
uint16_t gen_crc16(const uint8_t *data, uint16_t size)
{
uint16_t out = 0;
int bits_read = 0, bit_flag;
/* Sanity check: */