Skip to content

Instantly share code, notes, and snippets.

View bkonkle's full-sized avatar

Brandon Konkle bkonkle

View GitHub Profile
@bkonkle
bkonkle / ensureMutationId.ts
Created August 20, 2019 20:41
Ensure an '$id' for every Mutation in PostGraphile
export const ensureMutationId: Plugin = builder => {
builder.hook('GraphQLObjectType:fields:field', (field, build, context) => {
const {pgSql: sql} = build
const {
scope: {
isPgUpdateMutationField,
isPgCreateMutationField,
isPgDeleteMutationField,
},
} = context
@bkonkle
bkonkle / 1 - Store.re
Last active August 26, 2018 23:55
Reasonable Redux
open StateTypes;
let toOption = Js.Nullable.toOption;
let (getWithDefault, getExn) = Js.Option.(getWithDefault, getExn);
[@bs.module "redux"] external createStore : ('a, 'b, 'c) => 'd = "";
[@bs.module "redux"] external applyMiddleware : ('a, 'b) => 'c = "";
let identity = a => a;
let compose = (second, first, errors) => {
let result = first(errors);
Array.length(result) > 0 ? result : second(result);
};
let isString = input => Js.typeof(input) === "string";
let check = (condition, error) =>
Array.append(condition() ? [||] : [|error|]);
type ioRedis;
[@bs.new] [@bs.module] external ioRedis : unit => ioRedis = "ioredis";
[@bs.send] external set : (ioRedis, string, string, string, int) => Js.Promise.t(string) = "";
[@bs.send] external get : (ioRedis, string) => Js.Promise.t(Js.Nullable.t(string)) = "";
[@bs.send] external on : (ioRedis, string, unit => unit) => unit = "";
@bkonkle
bkonkle / Router.re
Created November 10, 2017 15:23
Reason with Koa Router
type koaRouter;
[@bs.module] external koaRouter : koaRouter = "koa-router";
[@bs.new] external newRouter : unit => koaRouter = "KoaRouter";
[@bs.send] external get : (koaRouter, string, 'a => Js.Promise.t(unit)) => unit = "";
[@bs.send] external post : (koaRouter, string, 'a => Js.Promise.t(unit)) => unit = "";
@bkonkle
bkonkle / README.md
Last active August 4, 2019 03:31
PureScript + purs-loader + webpack-blocks + Haul + React Native

PureScript on React Native via Webpack

Use this config with Haul, the Webpack packager for React Native.

@bkonkle
bkonkle / NewTodoView.jsx
Last active January 12, 2017 19:41
JSX Presentational Component
import React, {Component} from 'react'
import {newTodo} from './NewTodo.purs'
class NewTodoView extends Component {
render () {
const {addTodo, nextId} = this.props
return (
<header className="header">
<h1>todos</h1>
<input className="new-todo"
@bkonkle
bkonkle / NewTodo.purs
Created January 12, 2017 15:33
PureScript NewTodo Component
module Todo.Components.NewTodo (newTodo) where
import Prelude
import Control.Monad.Eff (Eff)
import React (ReactClass)
import React.Recompose (withHandlers)
import Todo.State.Todos (add) as Todos
import Redux.Mini (connect)
-- Props
@bkonkle
bkonkle / config.js
Created January 12, 2017 15:15
Webpack PureScript Config
module: {
// PureScript
loaders: [{
test: /\.purs$/,
loader: 'purs',
exclude: /node_modules/,
query: {
psc: 'psa',
src: ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs'],
warnings: false,
@bkonkle
bkonkle / Google Auth (Part 5).js
Created November 27, 2016 23:53
Electron Google Authentication (Part 5)
export async function fetchGoogleProfile (accessToken) {
const response = await axios.get(GOOGLE_PROFILE_URL, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`,
},
})
return response.data
}