Skip to content

Instantly share code, notes, and snippets.

View Tritlo's full-sized avatar

Matthías Páll Gissurarson Tritlo

View GitHub Profile
@Tritlo
Tritlo / APDoTest.hs
Created November 9, 2017 16:40
An example of how ApplicativeDo can be inefficient with uniform costs.
{-# 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 }
#!/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 February 7, 2017 11:19 — forked from plexsoup/LightCrumb.js
LightCrumb - based on "Mark" by the Aaron. For lighting your trail on maps with dynamic lighting.
// 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 March 26, 2018 18:29
Dependent typing in Haskell (example)
-- 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
@Tritlo
Tritlo / packages.el
Last active June 8, 2016 18:24 — forked from cstrahan/packages.el
Private spacemacs layer to try out Chris Done's Intero mode for haskell
;; 1. place this in ~/.emacs.d/private/intero/packages.el
;; 2. add intero, syntax-checking and auto-completion to your
;; ~/.spacemacs layer configuration & remove the haskell layer
;; if you were using that before
;; 3. make sure you have stack installed http://haskellstack.org
;; 4. fire up emacs & open up a stack project's source files

Keybase proof

I hereby claim:

  • I am tritlo on github.
  • I am tritlo (https://keybase.io/tritlo) on keybase.
  • I have a public key whose fingerprint is 926A AC14 F0AE 758A 063B 3E47 6EB0 F18F FDC7 2B21

To claim this, I am signing this object:

@Tritlo
Tritlo / TailRec.hy
Last active October 4, 2022 13:55
Proper Tail Recursion in Python
(defclass TailCall [Exception]
"An exeception to implement Proper Tail Recursion"
[[--init--
(fn [self __TCFunc &rest args &kwargs kwargs]
(setv self.func __TCFunc)
(setv self.args args)
(setv self.kwargs kwargs)
nil)]])
(defn TailRec [func]
; Lengd stafrófs = 32 stafir
; lengd stafrófs - 3 = 29 stafir
; Getum raðað JÓL á 3! = 6 vegu
; Getum raðað rest á 29! vegu
; Getum svo sett umröðunina á JÓL á 30 staði.
; fáum því að fjöldi umraðana á stafrófinu með JÓL við hliðná hvoru öðru er
; 29!*3!*30
; En ef JÓL þurfa að vera í réttri röð, þá er þetta bara 30! (getum þá litið á JÓL sem bara einn staf)
(def stafrof "AÁBDÐEÉFGHIÍJKLMNOÓPRSTUÚVXYÝÞÆÖ")
### Keybase proof
I hereby claim:
* I am tritlo on github.
* I am tritlo (https://keybase.io/tritlo) on keybase.
* I have a public key whose fingerprint is C77E 292D BCDB 00FE 822B C363 24D6 5B6A 067D A561
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am tritlo on github.
* I am mpgis (https://keybase.io/mpgis) on keybase.
* I have a public key whose fingerprint is 050D 101B 1677 E442 C1E1 7659 F365 878C C03C DDFD
To claim this, I am signing this object: