Skip to content

Instantly share code, notes, and snippets.

data ShowProps = ShowProps (forall sym. IsSymbol sym => SProxy sym -> String)
instance showProps ::
(Show a, IsSymbol sym) =>
FoldingWithIndex (ShowProps) (SProxy sym) String a String where
foldingWithIndex (ShowProps fn) prop str a =
pre <> fn prop <> ": " <> show a
where
pre | str == "" = ""
| otherwise = str <> ", "
newtype StringTransform = StringTransform (String -> String)
class EnumReadForeign rep where
enumReadForeignImpl :: StringTransform -> Foreign -> F rep
-- | Reads sums
enumReadForeign :: forall a rep
. Generic a rep
=> EnumReadForeign rep
=> Foreign
data PrefixProps sym = PrefixProps (SProxy sym)
instance prefixProps ::
( IsSymbol newsym
, Append presym sym newsym
, Row.Lacks newsym rb
, Row.Cons newsym a rb rc
) =>
FoldingWithIndex
(PrefixProps presym)
exports.addCardListenerImpl = function (card, fn) {
card.addEventListener('change', fn);
return null;
}
statusOk :: StatusCode -> Boolean
statusOk (StatusCode n) = n >= 200 && n < 300
_parseError = SProxy :: SProxy "parseError"
_badRequest = SProxy :: SProxy "badRequest"
_unAuthorized = SProxy :: SProxy "unAuthorized"
_forbidden = SProxy :: SProxy "forbidden"
_notFound = SProxy :: SProxy "notFound"
_methodNotAllowed = SProxy :: SProxy "methodNotAllowed"
_formatError = SProxy :: SProxy "formatError"
@dariooddenino
dariooddenino / react-wrapper.re
Last active August 10, 2017 09:30
Trying to create a wrapper function in reason-react.
/**
I'm trying to create a wrapper function that takes a react component and injects Apollo queries as props.
I've got to the point where it works, but:
1) I have to pass all the queries in a single js object with no compiler check if there's corrispondence
between the queries used and the ones the wrapped component is expecting.
2) I can't pass additional props without stuffing all of them inside a single object in the wrapper and then
doing some ugly Js.Obj.assign stuff.
*/
/** This two functions injects all the queries as props in the component */
// helpers.js
import * as R from 'ramda'
export const subObj = R.doSomestuff
// reasontest.re
type jsmodule;
@dariooddenino
dariooddenino / post.purs
Created July 29, 2016 16:17
post request
data Post = Post { id :: Maybe Int
, title :: String
, body :: String
, userId :: Int
}
instance decodeJsonPost :: DecodeJson Post where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
@dariooddenino
dariooddenino / toggle_touchpad.sh
Created January 27, 2016 08:56
Dell 9350 Touchpad toggle on Ubuntu
#!/bin/bash
declare -i ID
ID=`xinput list | grep -Eo 'DLL0704:01\s06CB:76AE\sUNKNOWN\s*id\=[0-9]{1,2}' | grep -Eo '\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'`
if [ $STATE -eq 1 ]
then
xinput disable $ID
echo "Touchpad disabled."

#HTTP CODES


##2xx Success

200 OK Standard response for successful HTTP requests.

201 Created