Skip to content

Instantly share code, notes, and snippets.

View danstn's full-sized avatar
🚀
Binding. Lifting. Zipping.

Daniel Stankevich danstn

🚀
Binding. Lifting. Zipping.
View GitHub Profile
@danstn
danstn / revproxy.go
Created January 10, 2023 04:59
Simple Go reverse proxy
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"strings"
)
@danstn
danstn / init.vim
Created December 1, 2022 01:23
A millionth version of my vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CORE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent " enable automatic indentation
set expandtab
set hlsearch " highlight search results
set ignorecase " case insensitive search
set incsearch " match the search and return to the initial position
set list " Show `listchars` characters
@danstn
danstn / Demo.elm
Last active July 7, 2022 23:24
Experiment with state machines & elm-ui
module MachineDemo exposing
( Model
, init
, myDiv
, setHeight
, setMinHeight
, setWidth
)
import Element exposing (..)
@danstn
danstn / stack.ts
Created April 27, 2021 05:24
CDK Construct for React FE on S3/CloudFront with Route53 and HTTPS
export class InfrastructureStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Create a new bucket
const bucket = new s3.Bucket(this, BUCKET_ID, {
bucketName: "<your-domain>",
websiteIndexDocument: "index.html",
autoDeleteObjects: true,
enforceSSL: true,
@danstn
danstn / hasql-extra.hs
Last active November 26, 2020 03:42
Hasql abstractions
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
module HasqlExtra where
import Data.UUID (UUID)
import qualified Hasql.Decoders as D
import Hasql.DynamicStatements.Snippet (Snippet, param, sql)
import Hasql.DynamicStatements.Statement (dynamicallyParameterized)
newtype PrivateData = PrivateData { ssshhh :: Text }
deriving (Eq, Show, Generic)
newtype PublicData = PublicData { somedata :: Text }
deriving (Eq, Show, Generic)
instance ToJSON PrivateData
instance ToJSON PublicData
type PublicAPI = Get '[JSON] [PublicData]
@danstn
danstn / home-ca.sh
Created April 25, 2017 13:32
Home Certificate Authority
#!/usr/bin/bash
set -e
echo -n "Enter server name (i.e. nginx-server): "
read server
echo "===> [INFO] Generating certs for: $server"
echo "===> [Step 1] Generating Certificate Request (CSR)..."
@danstn
danstn / free-monad-example.hs
Last active January 4, 2017 01:14
An example of using Free Monads for writing custom AST/DSL and its interpreters.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveFunctor #-}
import Prelude
import Data.String
import Control.Monad.Free
type Program a r = Free (AST a) r
data AST a next =
@danstn
danstn / reasonable.hs
Created March 29, 2016 15:29 — forked from aaronlevin/reasonable.hs
Reasonably Priced Monads in Haskell
-- | simple/basic Scala -> Haskell translation of Runar's presentation
-- | (https://dl.dropboxusercontent.com/u/4588997/ReasonablyPriced.pdf)
-- | trying to use minimal extensions and magic.
-- | (earlier I had a version using MultiParamTypeClasses for Runar's
-- | Inject class, but scraped it opting for simplicity)
-- | my question: what do we lose by moving towards simplicity?
-- | Future work: use DataKinds, TypeOperators, and potentially TypeFamilies
-- | to maintain and automate the folding of types in Coproduct.
{-# LANGUAGE Rank2Types, DeriveFunctor #-}
@danstn
danstn / gist:c9725862f5ec0cb69063
Created March 29, 2016 13:16 — forked from runarorama/gist:a8fab38e473fafa0921d
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]