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"
]
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'
},
{
- , enter
- , (:~>)(..)
- -- ** `Nat` utilities
- , liftNat
- , runReaderTNat
- , evalStateTLNat
- , evalStateTSNat
- , logWriterTLNat
- , logWriterTSNat
- -- ** Functions based on <https://hackage.haskell.org/package/mmorph mmorph>
@codedmart
codedmart / Auth.hs
Last active January 19, 2016 01:38
fromMaybeT :: Monad m => m a -> MaybeT m a -> m a
fromMaybeT x y = fmap fromJust . runMaybeT $ y <|> lift x
instance (AllCTUnrender list a, HasServer sublayout)
=> HasServer (Auth list a :> sublayout) where
type ServerT (Auth list a :> sublayout) m =
a -> ServerT sublayout m
case mc of
Nothing -> return $ FailFatal $ serverErr' Forbidden
Just jwt -> do
mcs <- verifyClaims $ decodeUtf8 jwt
case mcs of
Nothing -> return $ FailFatal $ serverErr' Forbidden
Just clms -> do
let user = lookup "user" $ toList $ unregisteredClaims clms :: Maybe Value
case user of
Nothing -> return $ FailFatal $ serverErr' Forbidden