Skip to content

Instantly share code, notes, and snippets.

Joel McCracken joelmccracken

Block or report user

Report or block joelmccracken

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joelmccracken
joelmccracken / join.hs
Last active Sep 2, 2019
embed applicative forms in monad form s.t. the error msg and labeling functionaliy from applicative fields are maintained but you can customize the overall feel of the larger form
View join.hs
joinForm :: Html -> MForm Handler (FormResult Join, Widget)
joinForm extra = do
let
mustAgreeField :: Text -> Field Handler Bool
mustAgreeField errorMsg = checkBool id errorMsg checkBoxField
accept1Def = areq (mustAgreeField
"You must specify that you accept Section 1")
"Accept Section 1" Nothing
accept2Def = areq (mustAgreeField
View error.txt
Error found:
in module Main
at src/Main.purs:65:29 - 65:37 (line 65, column 29 - line 65, column 37)
Could not match type
( nextId :: Int
, textVal :: Maybe String
, items :: Array
{ key :: String
View foo.js
function assertThrows(triggeringFn, testFn) {
var sawError = false;
try {
triggeringFn();
} catch (Exception e) {
sawError = true;
assert(testFn(e), "Exception did not pass test!");
}
assert(sawError, "Error was not thrown!");
View index.html
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Writing Shell Scripts in Haskell</title>
<style type="text/css">
code{white-space: pre-wrap;}
View index.html
2018-08-04 18:09:14 ☆ glamdring in ~/Projects/moot
± |detached:origin/HEAD {1} S:1 U:1 ✗| → stack build
Cloning 08c9b4cdf977d5bcd1baba046a007940c1940758 from https://github.com/bitemyapp/esqueleto.git
Cloning into '/Users/joel/Projects/moot/.stack-work/downloaded/LFPGB_S1ZA4V'...
remote: Counting objects: 3137, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 3137 (delta 7), reused 24 (delta 5), pack-reused 3105
Receiving objects: 100% (3137/3137), 1.21 MiB | 0 bytes/s, done.
Resolving deltas: 100% (1350/1350), done.
Cloning 6bf765e000c6fd14e09ebdea6c4c5b1510ff5376 from https://github.com/yesodweb/wai.git
View run 1
make migration
STACK_YAML="stack.yaml" stack build moot
Getting project config file from STACK_YAML environment
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. unix requires: >=1.2 && <1.9
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. directory requires: >=1.4 && <1.9
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. Cabal requires: >=1.4 && <1.9
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. http-api-data requires: >=1.4.2 && <1.9
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. aeson-compat requires: >=1.4.0.1 && <1.9
WARNING: Ignoring out of range dependency (allow-newer enabled): time-1.9.1. esqueleto requires: >=1.5.0.1 && <=1.8.0.2
moot-0.0.0: unregistering (components added: exe:fixtures, exe:migration, exe:moot, exe:truncate)
View gist:4786be5d4fe454129900b5d061f9adff
/Users/joel/.stack/programs/x86_64-osx/ghc-7.10.3/lib/ghc-7.10.3/include/rts/storage/ClosureMacros.h:505:5:
warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
^
/Users/joel/.stack/programs/x86_64-osx/ghc-7.10.3/lib/ghc-7.10.3/include/rts/storage/ClosureMacros.h:502:37:
note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF (defined(PROFILING))
^
View foo.hs
it "property for the definition of ($)" $ do
let
test :: Fun Int Int -> Int -> Bool
test fn x =
((apply fn) x) == ((apply fn) $ x)
property test
@joelmccracken
joelmccracken / junk.hs
Created Apr 26, 2017
random haskell snippets, mostly putzing with turtle, gpg, tar, etc
View junk.hs
_tar <- tar
stdout _tar
putStrLn $ (show r)
stdout $ inproc "gpg" ["--passphrase-fd", Data.Text.pack (show r), "--symmetric", "--batch", "--output", "encrypted.gpg"] _tar
proc "gpg" ["--passphrase", "helloworld", "--symmetric", "--batch", "--output", "encrypted.gpg"] _tar
x <- tar
y <- x
case y of
ExitSuccess -> return ()
You can’t perform that action at this time.