Skip to content

Instantly share code, notes, and snippets.

View codedmart's full-sized avatar

Brandon Martin codedmart

View GitHub Profile
checking for a BSD-compatible install... /builddir/.xbps-network-manager-applet/wrappers/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes
checking for x86_64-unknown-linux-gnu-gcc... cc
checking whether the C compiler works... yes
@codedmart
codedmart / Coupon.hs
Last active June 9, 2019 23:25
ElasticSearch `[FieldName]` for the models we use them for. We don't technically use them for `Coupon` and `User` since those use a query string search rather then a multi match search.
couponFields :: [FieldName]
couponFields =
[ FieldName "type"
, FieldName "code"
, FieldName "status"
, FieldName "createdBy.fullName"
, FieldName "createdBy.email"
, FieldName "createdBy.username"
]
-- from purescript-argonaut https://github.com/purescript-contrib/purescript-argonaut-codecs/blob/master/src/Data/Argonaut/Combinators.purs#L34-L35
-- obj .? "foo"
(.?) :: forall a. (DecodeJson a) => JObject -> String -> Either String a
(.?) o s = maybe (Left $ "Expected field " ++ show s) decodeJson (M.lookup s o)
-- I would like to do something like
-- obj `at` ["foo", "bar"]
at :: forall a. (DecodeJson a) => JObject -> Array String -> Either String a
at obj fields = fold (.?) obj (reverse fields)
var assert = require('assert')
var inversions = require('Inversions').inversions
var list = require('Data.List')
describe('The inversion counting function', function() {
it('should find an inversion', function () {
assert.equal(inversions(list.Cons.create(1)(list.Cons.create(2)(list.Cons.create(3)(list.Cons.create(4)(list.Nil.value))))), 0)
assert.equal(inversions(list.Cons.create(2)(list.Cons.create(1)(list.Cons.create(3)(list.Cons.create(4)(list.Nil.value))))), 1)
})
})
{
logical_operator:"and",
conditions:[
{
path:"asset",
relation:"is",
values:[
{
type:"value",
id:4325
data ConditionValues a b c = I a | T b | S c
deriving (Eq, Ord, Read, Show)
instance (ToJSON a, ToJSON b, ToJSON c) => ToJSON (ConditionValues a b c) where
toJSON (I a) = toJSON a
toJSON (T b) = toJSON b
toJSON (S b) = toJSON b
instance (FromJSON a, FromJSON b, FromJSON c) => FromJSON (ConditionValues a b c) where
-- parseJSON f = I <$> parseJSON f
data Filters = Filters
{ logicalOperator :: Text
, conditions :: [Condition | Filters]
} deriving (Show, Eq, Generic)
instance ToJSON Filters where
toJSON = genericToJSON $ aesonDrop 0 snakeCase
instance FromJSON Filters where
parseJSON = genericParseJSON $ aesonDrop 0 snakeCase
{
'conditions':[
{
'values':[
'ip'
],
'path':'sg_status_list',
'relation':'is'
},
{
@codedmart
codedmart / Auth.hs
Last active January 19, 2016 17:31
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
- , enter
- , (:~>)(..)
- -- ** `Nat` utilities
- , liftNat
- , runReaderTNat
- , evalStateTLNat
- , evalStateTSNat
- , logWriterTLNat
- , logWriterTSNat
- -- ** Functions based on <https://hackage.haskell.org/package/mmorph mmorph>