Skip to content

Instantly share code, notes, and snippets.

View agrafix's full-sized avatar
🛰️
Haskell

Alexander Thiemann agrafix

🛰️
Haskell
View GitHub Profile
@agrafix
agrafix / PCRETest.hs
Last active December 22, 2015 03:58
testRegex fails using GHC 7.6.1 and regex-pcre 0.94.4
View PCRETest.hs
import Text.Regex.PCRE
regex = "dein(en)? ([^\\s]+)"
expected = [ [ "dein F\252ller", "", "F\252ller"]
, [ "deinen F\246hn", "en", "F\246hn"]
]
-- consider this being read from a file
inputStr = "Nimm dein F\252ller und nimm deinen F\246hn mit."
View keybase.md

Keybase proof

I hereby claim:

  • I am agrafix on github.
  • I am ath (https://keybase.io/ath) on keybase.
  • I have a public key whose fingerprint is C8DC 581B 8739 05E7 F877 3A99 CA50 B525 5FA1 6367

To claim this, I am signing this object:

View AtomicState.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes #-}
module AtomicState
( getState, modifyState, forkThread, execAtomicStateT, AtomicStateT
, readState, runReadOnly, AtomicReadT
)
where
import Control.Monad.Reader
import Control.Concurrent
@agrafix
agrafix / UTCTimeArbitrary.hs
Created September 12, 2014 23:30
Haskell UTCTime Arbitrary instance
View UTCTimeArbitrary.hs
import Data.Time
instance Arbitrary UTCTime where
arbitrary =
do randomDay <- choose (1, 29) :: Gen Int
randomMonth <- choose (1, 12) :: Gen Int
randomYear <- choose (2001, 2002) :: Gen Integer
randomTime <- choose (0, 86401) :: Gen Int
return $ UTCTime (fromGregorian randomYear randomMonth randomDay) (fromIntegral randomTime)
View haskell-do-match.js
var samples =
[ ' do var <- readTVar'
, 'do foo'
, 'main = do let x = do { foo }'
, 'main = do let x = do foo'
, 'main = foo $ do '
];
for (var i in samples) {
var line = samples[i];
@agrafix
agrafix / ElmCalc.elm
Created July 26, 2015 11:41
My first Elm app
View ElmCalc.elm
module Main where
import StartApp
import String
import Html
import Html.Events as Html
import Html.Attributes as Html
import Html.Shorthand exposing (..)
import Bootstrap.Html exposing (..)
import Html exposing (blockquote)
@agrafix
agrafix / elm-install.py
Last active August 29, 2015 14:26
elm-package install "alternative" until the bug preventing it to work with vagrant/docker is fixed
View elm-install.py
#!/usr/bin/env python2.7
# This script is a hack until the elm-package install bug is fixed in docker containers
import urllib2
import argparse
import tempfile
import os
import zipfile
import shutil
import json
@agrafix
agrafix / GaussSmoothen.h
Created June 15, 2016 15:50
Gaussian smoothening of 1D signal in C++
View GaussSmoothen.h
#pragma once
#include <cmath>
#include <vector>
#include <assert.h>
inline double gauss(double sigma, double x) {
double expVal = -1 * (pow(x, 2) / pow(2 * sigma, 2));
double divider = sqrt(2 * M_PI * pow(sigma, 2));
return (1 / divider) * exp(expVal);
@agrafix
agrafix / FTT.h
Created June 15, 2016 15:54
C++ implementation of FFT
View FTT.h
/**
* C++ implementation of FFT
*
* Source: http://paulbourke.net/miscellaneous/dft/
*/
#pragma once
/*
This computes an in-place complex-to-complex FFT
@agrafix
agrafix / Api.hs
Created July 24, 2016 10:23
Spock GHC+GHCJS APIs
View Api.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
module Api
( Endpoint(..)
, Proxy(..)
, MaybeToList
, (<//>), var, Path(..), renderRoute
, Generic, ToJSON, FromJSON, NFData, Typeable