This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body <- getRequest | |
lift $ runConduitRes $ (consumeBody body) =$ sinkFile directory | |
where | |
consumeBody :: MonadIO m => YesodRequest -> ConduitM i ByteString m () | |
consumeBody body = do | |
chunk <- liftIO $ NW.requestBody $ reqWaiRequest body | |
if (chunk == BS.empty) | |
then return () | |
else do | |
yield chunk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helper.Aws | |
(listAllEmails | |
) where | |
import Control.Lens ((&), (.~)) | |
import Control.Monad.Trans.AWS (Error, runAWST, trying, _Error) | |
import Data.ByteString (ByteString) | |
import Network.AWS (Region (NorthVirginia), newEnv, runResourceT, send, within) | |
import Network.AWS.Auth (AccessKey (..), Credentials (FromKeys), SecretKey (..)) | |
import Network.AWS.SES (IdentityType (..)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic commands | |
:Git [args] # does what you'd expect | |
all of your `~/.gitconfig` aliases are available. | |
:Git! [args] # same as before, dumping output to a tmp file | |
Moving inside a repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpsTail :: [a] -> o -> ([a] -> o) -> o | |
cpsTail [] d = \f -> d | |
cpsTail (a:as) d = \f -> f as | |
cpsLoop :: (forall o. [a] -> o -> ([a] -> o) -> o) -> [a] -> [a] | |
cpsLoop f l = f l l id | |
safeTail :: [a] -> Maybe [a] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Store s a = Store (s -> a) s | |
instance Comonad (Store s) where | |
extract :: Store s a -> a | |
extract (Store f s) = f s | |
-- "replacing all values with containers, and then consuming those containers again" | |
extend :: Store s a -> (Store s a -> b) -> Store s b | |
extend s f = fmap f $ duplicate s | |
-- verbose: Store (\x -> f' $ Store f x) s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Vec3 a = Vec3 a a a deriving (Eq, Show) | |
instance Functor Vec3 where | |
fmap f (Vec3 a b c) = Vec3 (f a) (f b) (f c) | |
instance Applicative Vec3 where | |
pure a = Vec3 a a a | |
(Vec3 f f' f'') <*> (Vec3 a b c) = Vec3 (f a) (f' b) (f'' c) | |
instance Foldable Vec3 where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
traverseX :: forall f. Functor f = (a -> f a) -> Vec3 a -> f (Vec3 a) | |
traverseX f (Vec3 x y z) = (\h -> Vec3 h) <$> f x | |
traverseY :: forall f. Functor f = (a -> f a) -> Vec3 a -> f (Vec3 a) | |
traverseY f (Vec3 x y z) = (\h -> Vec3 h) <$> f x | |
traverseZ :: forall f. Functor f = (a -> f a) -> Vec3 a -> f (Vec3 a) | |
traverseZ f (Vec3 x y z) = (\h -> Vec3 h) <$> f x | |
type Lens s a = forall f. Funtor f => (a -> f a) -> s -> f s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883", withHoogle ? true }: | |
let | |
inherit (nixpkgs) pkgs; | |
pinnedUnstable = | |
pkgs.fetchFromGitHub { | |
owner = "NixOS"; | |
repo = "nixpkgs-channels"; | |
rev = "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38"; | |
sha256 = "1ak7jqx94fjhc68xh1lh35kh3w3ndbadprrb762qgvcfb8351x8v"; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE ScopedTypeVariables #-} |