Skip to content

Instantly share code, notes, and snippets.

Matthías Páll Gissurarson Tritlo

Block or report user

Report or block Tritlo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Tritlo
Tritlo / favicon.py
Last active Jun 29, 2019
Favicon.png
View favicon.py
import numpy as np
from PIL import Image
w,h = 384, 384
data = np.zeros((w,h,3), dtype=np.uint8)
yellow = [255, 255,0]
black = [0,0,0]
@Tritlo
Tritlo / ONotation.hs
Created Nov 5, 2018
Type-level complexity annotations in Haskell
View ONotation.hs
{-# LANGUAGE TypeInType, TypeOperators, TypeFamilies,
UndecidableInstances, ConstraintKinds #-}
module ONotation where
import GHC.TypeLits as L
import Data.Type.Bool
import Data.Type.Equality
-- Simplistic asymptotic polynomials
data AsymP = NLogN Nat Nat
View PyLibGen.hs
{-# LANGUAGE GADTs #-}
import Data.List
import Data.Monoid
import Data.Typeable
import Data.Dynamic
import GHC.Err
import GHC.Prim
@Tritlo
Tritlo / Dockerfile
Last active Mar 13, 2019
Dockerfile and config for cross compiling Haskell to run on Raspberry Pi
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl xz-utils build-essential unzip
RUN mkdir -p /rpi/ghc/ \
&& curl -sSL http://releases.mobilehaskell.org/x86_64-linux/9824f6e473/ghc-8.4.0.20180109-arm-linux-gnueabihf.tar.xz -o ghc.tar.xz\
&& tar -xvf ghc.tar.xz -C /rpi/ghc/\
&& rm -f ghc.tar.xz
RUN mkdir -p /rpi/prebuilt/ \
@Tritlo
Tritlo / OverloadedDo.hs
Last active Feb 13, 2018
OverloadedDo exploration
View OverloadedDo.hs
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE DeriveDataTypeable #-}
@Tritlo
Tritlo / Main.hs
Last active Jan 23, 2018
Using typed holes to lookup functions with types with non-functional properties.
View Main.hs
{-# LANGUAGE TypeInType, TypeOperators #-}
module Main where
import Sorting
import ONotation
-- Here we say that sorted can use at most complexity N^2 and at most memory N^1
-- and that the sort has to be stable.
mySort :: Sorted (O(N ^. 2)) (O(N)) True Integer
@Tritlo
Tritlo / APDoTest.hs
Created Nov 9, 2017
An example of how ApplicativeDo can be inefficient with uniform costs.
View APDoTest.hs
{-# LANGUAGE ApplicativeDo #-}
module Main where
import Control.Concurrent
import Control.Concurrent.MVar
import Data.Time.Clock
-- We create a wrapper around IO for this example
newtype PIO a = PIO { runPIO :: IO a }
View TACOS.py
#!/usr/bin/env python3
import uuid
import datetime
import time
# Configuration
bucket = 'REDACTED' #Make sure you have permissions to Put, Delete and Get.
path = "nullid/picam-" #The prefix of the pictures.
@Tritlo
Tritlo / LightCrumb.js
Last active Feb 7, 2017 — forked from plexsoup/LightCrumb.js
LightCrumb - based on "Mark" by the Aaron. For lighting your trail on maps with dynamic lighting.
View LightCrumb.js
// Gist: https://gist.github.com/plexsoup/64852540504101b520b25f7c3fa84e5f
// By: Plexsoup - copied from Mark by The Aaron. With help from Scott C, Stephen L and Tritlo
// Thanks: Testers and Feedback: al e., DM Robzer, Vince, Pat S, Gold, Anthony, Kryx, Sudain
// Contact: https://app.roll20.net/users/258125/plexsoup
// Roll20 API Script to leave a breadcrumb trail of torches. Based on "Mark" from The Aaron //
/*
@Tritlo
Tritlo / DependentTypingExample.hs
Last active Mar 26, 2018
Dependent typing in Haskell (example)
View DependentTypingExample.hs
-- This is a simple example showing the use of dependent typing in haskell, in a
-- vein similar to http://www.idris-lang.org/example/
{-# LANGUAGE TypeFamilies, GADTs, TypeOperators, DataKinds, KindSignatures #-}
-- We can also just add TypeInType, and skip DataKinds and KindSignatures,
-- since TypeInType enables both of those, PolyKinds (and more!)
module Main where
import Data.Kind (Type)
-- Define a Type for the natural numbers, Zero and a successor
You can’t perform that action at this time.