Skip to content

Instantly share code, notes, and snippets.

Brandon Konkle bkonkle

Block or report user

Report or block bkonkle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bkonkle
bkonkle / 1 - Store.re
Last active Aug 26, 2018
Reasonable Redux
View 1 - Store.re
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;
View 1- StateValidation.re
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|]);
View RedisProvider.re
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 Nov 10, 2017
Reason with Koa Router
View Router.re
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 May 10, 2017
PureScript + purs-loader + webpack-blocks + Haul + React Native
View README.md

PureScript on React Native via Webpack

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

@bkonkle
bkonkle / NewTodoView.jsx
Last active Jan 12, 2017
JSX Presentational Component
View NewTodoView.jsx
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 Jan 12, 2017
PureScript NewTodo Component
View NewTodo.purs
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 Jan 12, 2017
Webpack PureScript Config
View config.js
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 Nov 27, 2016
Electron Google Authentication (Part 5)
View Google Auth (Part 5).js
export async function fetchGoogleProfile (accessToken) {
const response = await axios.get(GOOGLE_PROFILE_URL, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`,
},
})
return response.data
}
@bkonkle
bkonkle / Google Auth (Part 4).js
Created Nov 27, 2016
Electron Google Authentication (Part 4)
View Google Auth (Part 4).js
export async function fetchAccessTokens (code) {
const response = await axios.post(GOOGLE_TOKEN_URL, qs.stringify({
code,
client_id: GOOGLE_CLIENT_ID,
redirect_uri: GOOGLE_REDIRECT_URI,
grant_type: 'authorization_code',
}), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
You can’t perform that action at this time.