#HTTP CODES
##2xx Success
200 OK Standard response for successful HTTP requests.
201 Created
; A modified group-by for jsons. | |
; Eg. [{:id "id1" :title "one"} {:id "id2" :title "two"}] | |
; to, for example, this: {:id1 {:id "id1 :title "one"} :id2 {:id "id2" :title "two"}} | |
(defn group-json | |
[f coll] | |
(persistent! | |
(reduce | |
(fn [ret x] | |
(let [k (keyword (f x))] |
#HTTP CODES
##2xx Success
200 OK Standard response for successful HTTP requests.
201 Created
#!/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." |
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" |
// helpers.js | |
import * as R from 'ramda' | |
export const subObj = R.doSomestuff | |
// reasontest.re | |
type jsmodule; |
/** | |
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 */ |
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" |
exports.addCardListenerImpl = function (card, fn) { | |
card.addEventListener('change', fn); | |
return null; | |
} | |
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) |
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 |