Skip to content

Instantly share code, notes, and snippets.

@mightybyte
mightybyte / verification.pact
Created April 15, 2019 17:32
Pact formal verification example
;;
;; A little example showing off the merits of formal
;; verification and why it pays off.
;;
;; Keysets cannot be created in code, thus we read them in
;; from the load message data.
(define-keyset 'admin-keyset (read-keyset "admin-keyset"))
;; Define the module.
@mightybyte
mightybyte / pact-web-share.pact
Created March 19, 2019 19:05
Pact shared with pact-web.
;;
;; A little example showing off the merits of formal
;; verification and why it pays off.
;;
;;---------------------------------
;;
;; Create an 'admin-keyset' and add some key, for loading this contract!
;;
;; Make sure the message is signed with this added key as well.
@mightybyte
mightybyte / pact-web-share.pact
Created March 15, 2019 19:20
Pact shared with pact-web.
;; This is a test of the gist saving mechanism
;; accounts module, admin keyset, and table
; (load "examples/verified-accounts/accounts.repl")
(enforce-pact-version "2.4.1")
(define-keyset 'accounts-admin-keyset
(read-keyset "accounts-admin-keyset"))
@mightybyte
mightybyte / pact-web-share.pact
Last active March 15, 2019 19:17
Pact shared with pact-web.
;;---------------------------------
;; Doug demo testZZZ
;; Create a keyset named 'keyset' and add some key,
;; for loading this contract!
;;
;; Make sure the message is signed with this added key as well.
;;---------------------------------
(define-keyset 'module-keyset (read-keyset "keyset"))
@mightybyte
mightybyte / pact-web-share.pact
Created March 15, 2019 19:05
Pact shared with pact-web.
;;
;; Hi Doug, please find your favorite smart contract below.
;;
;; Best,
;; Robert
(define-keyset 'admin-keyset (read-keyset "admin-keyset"))
;; Define the module.
(module verificationDoug 'admin-keyset
@mightybyte
mightybyte / Main.hs
Last active March 20, 2018 05:50
Attaching reflex to a particular node
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------------
import Control.Concurrent
import Control.Monad
import Control.Monad.Trans
@mightybyte
mightybyte / gist:33fed8318386983cd1b6064edba67034
Created December 5, 2017 04:27
zsh completion debug file
+_complete_debug:20> : zsh 5.0.8
+_complete_debug:21> _main_complete
+_main_complete:11> local 'IFS=
'
+_main_complete:25> eval 'local -A _comp_caller_options;
_comp_caller_options=(${(kv)options[@]});
setopt localoptions localtraps localpatterns ${_comp_options[@]};
local IFS=$'\'' \t\r\n\0'\''
enable -p \| \~ \( \? \* \[ \< \^ \#
exec </dev/null;
@mightybyte
mightybyte / WidgetTypes.hs
Last active May 30, 2017 22:09
FRP Widgets
data WidgetConfig t a
= WidgetConfig { _widgetConfig_setValue :: Event t a
, _widgetConfig_initialValue :: a
, _widgetConfig_attributes :: Dynamic t (Map String String)
}
makeLenses ''WidgetConfig
instance (Reflex t, Default a) => Default (WidgetConfig t a) where
def = WidgetConfig { _widgetConfig_setValue = never
{-# LANGUAGE DeriveFunctor #-}
module Form where
import Control.Lens
import Data.Default
import Data.Functor.Compose
import Data.Monoid
import Reflex
@mightybyte
mightybyte / FileLoader.hs
Created January 2, 2017 04:46
Reflex file loader
fileLoader :: MonadWidget t m => FileInputConfig t -> m (Event t Text)
fileLoader cfg = do
fls <- fmapMaybe listToMaybe . updated . value <$> fileInput cfg
reader <- liftIO newFileReader
performEvent_ $ ffor fls $ \f -> liftIO $
readAsDataURL reader (Just f)
wrapDomEvent reader (`on` load) $ do
res <- liftIO $ fromJSValUnchecked =<< getResult reader
let Right contents = decodeUtf8 <$> B64.decode
(encodeUtf8 $ snd $ T.breakOnEnd "base64," res)