Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • Twitter @shinzui
View GitHub Profile
@shinzui
shinzui / exchange-formats.md
Created Aug 12, 2019 — forked from gelisam/exchange-formats.md
A list of every data exchange formats I could find
View exchange-formats.md

At work, I just spent the last few weeks exploring and evaluating every format I could find, and my number one criteria was whether they supported sum types. I was especially interested in schema languages in which I could describe my types and then some standard specifies how to encode them using an on-the-wire format, usually JSON.

  1. Swagger represents sum types like Scala does, using subtyping. So you have a parent type EitherIntString with two subtypes Left and Right represented as {"discriminator": "Left", value: 42} and {"discriminator": "Right", value": "foo"}. Unfortunately, unlike in Scala in which the parent type is abstract and cannot be instantiated, in Swagger it looks like the parent type is concrete, so when you specify that your input is an EitherIntString, you might receive {"discriminator": "EitherIntString"} instead of one of its two subtypes.
  2. JSON-schema supports unions, which isn't quite the same thing as sum types because
View Glassery.md
title author
Glassery
Oleg Grenrus

After I have improved the raw performance of optika – a JavaScript optics library, it's time to make the library (feature-)complete and sound. Gathering and classifying all possible optic types, gives us a reference point

@shinzui
shinzui / GraphqlHooks.re
Created Mar 31, 2019 — forked from sync/GraphqlHooks.re
Hooks reason graphql
View GraphqlHooks.re
module MemCache = {
type t;
[@bs.deriving abstract]
type config = {initialState: Js.Json.t};
type conf = Js.Json.t;
[@bs.module "graphql-hooks-memcache"]
external _createMemCache: config => t = "default";
View p2.csv
propertyId agentId
132 50000
99 50001
105 50002
120 50002
58 50003
46 50005
65 50006
66 50006
118 50011
View p.csv
buyerNeedId agentId
293 2324
313 1531
View test.csv
propertyId agentId
1 123
2 333
@shinzui
shinzui / RecursiveGQLTypes.re
Created Oct 12, 2018 — forked from kgoggin/RecursiveGQLTypes.re
This gist shows how you could go about defining ReasonML types based on a GraphQL schema that reference each other, as well as a recursive decoder function used to parse a JSON response into the correct type.
View RecursiveGQLTypes.re
/* Use Reason's ability to define recursive types with the `and` keyword */
type movie = {
id: option(string),
name: option(string),
rating: option(Js.null(string)),
runTime: option(Js.null(int)),
actors: option(list(actor)),
}
and actor = {
id: option(string),
@shinzui
shinzui / App.re
Created Sep 8, 2018 — forked from jaredly/App.re
ReasonReact Context API Example
View App.re
module StringContext =
Context.MakePair({
type t = string;
let defaultValue = "Awesome";
});
let component = ReasonReact.statelessComponent("Tree");
let make = _children => {
View Dockerfile
FROM ocaml/opam2:alpine-3.7-ocaml-4.06
RUN sudo apk --no-cache add ca-certificates
RUN sudo apk add --update m4 openssh-client
# Setup SSH.
RUN mkdir -p ~/.ssh
ARG SSH_PRIVATE_KEY
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN printf "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
@shinzui
shinzui / config
Created Aug 23, 2018 — forked from Khady/config
Opam configuration for both sandbox and compilation cache
View config
pre-install-commands:
["opam-bin-cache.sh" "restore" build-id name] {?build-id}
wrap-build-commands: [
["opam-bin-cache.sh" "wrap" build-id] {?build-id}
["%{hooks}%/sandbox.sh" "build"] {os = "linux"}
]
wrap-install-commands: [
["opam-bin-cache.sh" "wrap" build-id] {?build-id}
["%{hooks}%/sandbox.sh" "install"] {os = "linux"}
]