This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open StoryBook; | |
let _module = [%bs.raw "module"]; | |
storiesOf("ReasonML Example", _module) | |
->addDecorator(storyFn => | |
<div style={ReactDOMRe.Style.make(~textAlign="center", ~marginTop="50px", ())}> | |
{storyFn()} | |
</div> | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as shelljs from 'shelljs' | |
import db from 'path-to-knex-client' | |
import config from 'src/config' | |
/** | |
Mocha hooks | |
*/ | |
before(async () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Schema for translations, with @genType for TS/JS usage */ | |
[@genType] | |
type translations = { | |
helloMessage: string, | |
helloMessageWithVariable: (~name: string) => string, | |
}; | |
/** English translations */ | |
[@genType] | |
let translationsEN = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type MyGraphQLMutation = { | |
module GQL: ReasonApolloTypes.Config; | |
include (module type of ReasonApolloMutation.Make(GQL)); | |
}; | |
module type MyGraphQLQuery = { | |
module GQL: ReasonApolloTypes.Config; | |
include (module type of ReasonApolloQuery.Make(GQL)); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- taken from https://rob.conery.io/2014/05/28/a-better-id-generator-for-postgresql/ | |
create schema idgen; | |
create sequence idgen.global_id_sequence; | |
CREATE OR REPLACE FUNCTION idgen.id_generator( | |
myts timestamp, | |
OUT result bigint) AS $$ | |
DECLARE | |
our_epoch bigint := 1314220021721; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- needed for `gen_random_bytes` | |
CREATE EXTENSION IF NOT EXISTS pgcrypto; | |
/** | |
Generate a unique Order ID based on current_timestamp, base32 and two bits of entropy. | |
If two Orders are created at the exact same millisecond, we rely on the entropy to provide uniqueness. | |
Usage: | |
> select * from generate_order_id(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dataclass saves the trouble of writing __init__ implementations | |
# frozen=True makes the class instances immutable (so no hidden mutable state) | |
@dataclass(frozen=True) | |
class UserConnector: | |
def get_user(id: str) -> User: | |
return User.objects.get(id=id) | |
@dataclass(frozen=True) | |
class OrgConnector: | |
def get_org(id: str) -> Org: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'm using Django models as inspiration in this example | |
from mymodels import User, Org | |
# You could also call these Getters or DAOs etc | |
# The point is that they perform some kind of | |
# side effect like talking to a DB or an API | |
@dataclass(frozen=True) | |
class UserConnector: | |
def get_user(id: str) -> User: |