Skip to content

Instantly share code, notes, and snippets.

View dpwiz's full-sized avatar
👁️‍🗨️
🌈

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
{-# LANGUAGE TemplateHaskell #-}
module CNth where
import Language.Haskell.TH
import Data.List
cnth :: Int -> Q Exp
cnth n = dotE qs
where
qs = head . reverse . take n . drop 1 $ ads
@dpwiz
dpwiz / Hedis.hs
Last active August 29, 2015 14:01
Scotty application skeleton
module Hedis
(
-- * Application classes
HasRedis(..)
-- * App-wrapped redis runner
, redis
-- * Re-export other stuff from "Database.Redis"
, module R
) where
@dpwiz
dpwiz / watch.sh
Created June 6, 2014 14:33
cabal build --watch --exec
while true; do
clear && cabal build && $@
inotifywait -qq -e modify -r src/ *.cabal
done
@dpwiz
dpwiz / README
Last active August 29, 2015 14:02
rest-* documentation builder
The script utilizes `cabal sandbox` to keep the guts from spilling into system packages.
The documentation builder is `standalone-haddock`[1] so you have to install it and put on your PATH first. A `hscolour` have to be installed to provide source links.
[1]: https://hackage.haskell.org/package/standalone-haddock
[2]: https://hackage.haskell.org/package/hscolour
@dpwiz
dpwiz / haskell.nanorc
Last active August 29, 2015 14:02
DIY Haskell IDE
## include "/path/to/haskell.nanorc"
syntax "haskell" "\.hs$"
color green "(\||@|!|:|_|~|=|\\|;|\(|\)|,)"
color magenta "(True|False|==|/=|&&|\|\||<|>|<=|>=)"
color green "(->|<-|!)"
color red "[\n\t](as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|mdo|module|newtype|qualified|type|where)[ \n\t]"
color brightblue "'.'"
color brightblue "'\\[ntfr]'"
color brightblue ""[^\"]*""
@dpwiz
dpwiz / PlainOldXML.hs
Created August 19, 2014 08:24
Unviersal wrapper for POX protocols.
module PlainOldXML where
import Network.HTTP.Conduit
import Text.XML
import Text.XML.Cursor
xmlQuery :: Manager -> String -> Document -> IO Cursor
xmlQuery manager url doc = do
putStrLn "Request:" >> BSL.putStrLn (renderLBS (def { rsPretty = True }) doc)
@dpwiz
dpwiz / Client.hs
Created August 25, 2014 10:33
JSON-RPC client
module JSONRPC.Client where
import Control.Applicative ((<|>))
import Data.Aeson (encode, decode)
import Data.Aeson.Types
import Network.HTTP.Conduit
import qualified Data.Text as T
import qualified Data.ByteString.Lazy.Char8 as BSL
data (FromJSON a) => JSONRPCReply a =
@dpwiz
dpwiz / mini.elm
Last active April 27, 2019 01:46
A minimal Elm application with AJAX and Virtual DOM.
import Debug
import Graphics.Input as Input
import Html
import Html (..)
import Html.Attributes (..)
import Html.Events (..)
import Html.Tags (..)
import Http
import Window
@dpwiz
dpwiz / scarf.yaml
Last active August 29, 2015 14:13
demo scarf config
# Usage:
# $ wget http://hipstername.tld/download/linux-x64/scarf && chmod +x scarf
# $ ./scarf gist:wiz/c32460e1ecbf612bb12f
title: Demo template
source: github:login/reponame
params:
- key: spam
title: Spam
@dpwiz
dpwiz / Main.elm
Created March 18, 2015 19:27
Render, minify and compress Elm project.
module Main where
import Html (..)
import Html.Attributes (..)
import Html.Events (..)
import List
import LocalChannel as LC
import Signal
-- Model