Skip to content

Instantly share code, notes, and snippets.

View tvh's full-sized avatar

Timo von Holtz tvh

View GitHub Profile
@tvh
tvh / bench.hs
Last active August 23, 2018 00:41
module Main where
import Data.Monoid
import Control.Monad
import Criterion.Main
import Data.IORef
import Control.Concurrent.Async
import Control.Concurrent.STM
import Control.Concurrent.MVar
@tvh
tvh / gist:5e24f4818eb519127f0f
Created February 18, 2015 00:31
application/x-www-form-urlencoded for servant
data FormUrlEncoded deriving Typeable
class ToFormUrlEncoded a where
toFormUrlEncoded :: a -> [(ByteString, ByteString)]
class FromFormUrlEncoded a where
fromFormUrlEncoded :: [(ByteString, ByteString)] -> Either String a
instance ToFormUrlEncoded [(ByteString, ByteString)] where
toFormUrlEncoded = id
-- | Request must contain a valid token including at least the specified scope.
data TokenScope (scope :: Symbol)
-- | All we can do for now is say that AUTHORIZATION is looked at.
--
-- TODO: Add Note to API sum type so tha we can add documentation notes for
-- this kind of thing.
instance (KnownSymbol scope, HasDocs sublayout)
=> HasDocs (TokenScope scope :> sublayout) where
docsFor Proxy (endpoint, action) =
docsFor sub (endpoint, action & headers %~ (|> "AUTHORIZATION"))
checkCredentials
:: Text -- ^ UserName
-> Text -- ^ Password
-> m (Either String ())
lookupUser :: Text -> m (Either String [Text])
@tvh
tvh / gist:f888012114dda0be9165
Last active August 29, 2015 14:13
Password OAuth2 Token
-- | Request (via POST method) "Access Token" using Resource Owner Password Credentials Grant.
--
--
fetchAccessTokenPass :: Manager -- ^ HTTP connection manager
-> OAuth2 -- ^ OAuth Data
-> BS.ByteString -- ^ username
-> BS.ByteString -- ^ password
-> IO (OAuth2Result AccessToken) -- ^ Access Token
fetchAccessTokenPass manager oa username password = doJSONPostRequest manager oa uri body
where (uri, body) = accessTokenUrlPass oa username password
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
module Main where
set 10: 4.98707s
delete 10: 4.750214s
delete 10: 5.021166s
set 10: 5.073635s
delete 10: 5.090525s
delete 10: 5.106929s
set 10: 5.145212s
set 10: 5.283383s
set 10: 5.077518s
delete 10: 5.175202s
@tvh
tvh / output (3 nodes)
Last active August 29, 2015 14:09
testzoo
set 100: 0.893666s
children: 14551
set 100: 0.894641s
children: 14451
set 100: 0.897937s
children: 14351
set 100: 0.903344s
children: 14251
delete 100: 0.903555s
delete 100: 0.903288s
@tvh
tvh / dotp.s
Last active July 6, 2016 18:42
; ModuleID = 'dotp.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind readonly uwtable
define float @dotp(float* nocapture %a, float* nocapture %b, i32 %count) #0 {
%1 = icmp sgt i32 %count, 0
br i1 %1, label %.lr.ph, label %._crit_edge
.lr.ph: ; preds = %0, %.lr.ph