Skip to content

Instantly share code, notes, and snippets.

@calebmer
calebmer / future.js
Last active August 29, 2015 14:26
The future of web apps in node
/*
* Next generation of building HTTP apps in NodeJS. Implements the HTML
* streaming API through ES6 generators. ES7 async functions are used to fetch
* data.
*
* Why is this a good idea?
* 1) It is beautiful. You setup a consistent API backend and your frontend
* backend (tongue twister) just looks like this. Layout implementations
* would be a bit odd, but it harkens back to plain old PHP 'require's.
* 2) Most modern, ES6, ES7, streams. All the new pretties.
@calebmer
calebmer / router-benchmark.js
Last active October 19, 2015 00:30
pillarjs/router benchmarks
'use strict'
var http = require('http')
var request = require('supertest')
var Router = require('router')
var finalhandler = require('finalhandler')
var N = parseInt(process.env.N, 10)
var router = Router()
@calebmer
calebmer / schema.sql
Created November 11, 2015 15:23
A subset of a PostgREST schema
CREATE SCHEMA private;
CREATE TABLE private.person (
id serial PRIMARY KEY,
email varchar(128) NOT NULL UNIQUE CHECK ( email ~* '^.+@.+\..+$' ),
given_name varchar(64) NOT NULL CHECK ( LENGTH(given_name) >= 2 ),
family_name varchar(64) CHECK ( LENGTH(family_name) >= 2 ),
image varchar(128),
created_at timestamp NOT NULL DEFAULT NOW(),
password_hash char(60)
@calebmer
calebmer / resources.md
Last active December 3, 2015 22:57
Sample PostgREST JSON Hyperlink Schema
@calebmer
calebmer / react-hot-loader.d.ts
Created May 15, 2016 22:14
React Hot Loader 3 Typings
declare module 'react-hot-loader' {
import React = __React
interface AppContainerProps {
children?: React.ReactElement<any>
}
export class AppContainer extends React.Component<AppContainerProps, {}> {}
}
@calebmer
calebmer / README.md
Created November 7, 2016 16:17
Caleb’s Open Source Software Feature Wishlist

Caleb’s Open Source Software Feature Wishlist

Every once and a while there will be a feature in open source software that I (Caleb) want, but needs a PR to implement. This document is a collection of issues around such features. This list is to track such features and allow me, or others, to find issues to fix whenever the time and interest arises.

Some issues will be easier than others, but hopefully all are more then possible given an afternoon. Ideally the issue has enough context to get rolling.

@calebmer
calebmer / 01-query-1.graphql
Last active March 6, 2017 21:47
GraphQL AST
{
luke: person(id: \"cGVvcGxlOjE=\") {
height
mass
species {
name
classification
}
}
}
@calebmer
calebmer / 00-notes.md
Last active December 8, 2017 14:25
Tiny GraphQL Client Ideas

Notes

Principles

  1. The client must help create applications that are very small. This means not only should the runtime be small, but also the query artifacts that will be included in the bundle. Including the entire query AST could be counter to this goal. Other options are only including the query text, or only including a query identifier (persisted queries) in the bundle.
  2. In order to serve the first principle queries must be statically defined outside of JavaScript. GraphQL AST “selection sets” should be transformed into minimal viable data shape representations to inform the client. These transformed “data shapes” can be imported and used by the client.
  3. Static type checking of query data should be a feature of the client and not an afterthought. GraphQL is statically typed after all. Since we are building query files, and importing the built artifcats adding types should be easy.
  4. Data from newer queries must be merged with data from older queries automatically so the UI stays consistent.

In this case, it looks like TypeScript unifies the function type parameters. Flow does not unify function type parameters. Instead Flow defines “bounds” for function type parameters. Which is the more expressive choice when type-checking JavaScript.

Consider the following function:

function choose<T>(a: T, b: T): T {
  return Math.random() > 0.5 ? a : b;
export PS1="\[\033[0m\]\W \[\033[00;95m\]❯\[\033[0m\] "
# export EDITOR="code -r"
export CLICOLOR=1
export TERM=xterm-color
function nm_notify_done() {
previous=$?
if [ $previous -eq 0 ]; then
osacript -e "display notification \"Done\" with title \"Node Modules Install\"";
else