Skip to content

Instantly share code, notes, and snippets.

View wmertens's full-sized avatar

Wout Mertens wmertens

View GitHub Profile

Keybase proof

I hereby claim:

  • I am wmertens on github.
  • I am wmertens (https://keybase.io/wmertens) on keybase.
  • I have a public key ASA6XQ6RqdgBgVFsOKWY0PV55O0x0hHULlbBfmNNhGbUXwo

To claim this, I am signing this object:

@wmertens
wmertens / router.jsx
Last active August 10, 2017 11:14
Wrapper for react-router v4 with an API more to my tastes
import React, {Component, PropTypes} from 'react'
import {Link, Route as OrigRoute, Switch, Redirect, BrowserRouter as Router, withRouter} from 'react-router-dom'
// Subscribes a child to history updates, passing the current location as a prop
// This is needed to work around the React context API not updating all children
// See https://github.com/ReactTraining/react-router/issues/4629#issuecomment-284218493
export class LocationListener extends Component {
static contextTypes = {
history: PropTypes.object,
}
@wmertens
wmertens / New iTerm Window.scpt
Last active February 2, 2017 21:48
Open a new iTerm window (https://iterm2.com) in the current application folder via Applescript
on run
-- Figure out if we want to do the cd (doIt)
-- Figure out what the path is and quote it (myPath)
set doIt to false
try
tell application "Finder" to set doIt to frontmost
set myPath to finder_path()
if myPath is equal to "" then
set doIt to false
else
// Based on https://gist.github.com/langpavel/b30f3d507a47713b0c6e89016e4e9eb7
const serializeDate = value => {
if (value instanceof Date) {
return value.toJSON().slice(0, 10)
} else if (typeof value === 'number') {
return Math.trunc(value)
} else if (typeof value === 'string') {
return (new Date(value)).toJSON().slice(0, 10)
}
return null
@wmertens
wmertens / Post.graphql
Last active June 12, 2017 11:27
Imagining what a graphql schema would look like that allows auto-creating lists and detail view/editor
enum PostStates { DRAFT, PUBLISHED, ARCHIVED }
scalar Date
scalar Html
directive @buildIndex on field
directive @defaultFirst on field
#...etc
type PostContent {
brief: Html @editor(height: 150, wysiwyg: true)
extended: Html @editor(height: 400, wysiwyg: true)
@wmertens
wmertens / server.js
Last active January 5, 2019 15:51
Example Let's Encrypt configuration for KeystoneJS
const keystone = require('keystone')
keystone.init({
name: 'myApp',
brand: 'My App',
port: process.env.PORT,
'ssl port': process.env.SSLPORT,
ssl: 'force',
@wmertens
wmertens / full stack redux.md
Last active February 8, 2022 22:46
making an awesome server with the redux model, Work In Progress

Thought experiment: Redux-like stateless server

Description

We describe a model for client-server processing where the Redux model is used to minimize stateful code. This should allow live-reloading server code, and make it possible to share code (e.g. optimistic updating) between client and server.

Dramatis Personae

  • Assume a server consisting of multiple worker processes that do not share memory and may be running on multiple hosts.
    • Workers have middleware, root reducers and an app state object
  • Workers can be dynamically added and removed
@wmertens
wmertens / auto-vendor-prefixer.coffee
Last active August 29, 2015 14:18
tiny in-browser memoized auto-prefixer for React styles, supports flexbox too.
# Auto-vendor-prefixer
# Finds the vendor prefix to use
# MIT license, Author: Wout Mertens
prefix=null
myStyle=document?.head?.style or {}
foundProps={}
newCssProp = (prop) ->
t = foundProps[prop]
@wmertens
wmertens / private.xml
Last active March 12, 2019 19:57
Use Karabiner (https://pqrs.org/osx/karabiner/) to emulate a http://waytools.com TextBlade as well as add some useful shortcuts for the TextBlade proper.
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>WT</vendorname>
<vendorid>0x000d</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>TB</productname>
<productid>0x0000</productid>
@wmertens
wmertens / script.coffee
Last active August 29, 2015 14:15
PwRggP
# Pure coffeescript React.JS
# Also features "global state manager"
R = React.DOM
N = null
# global state manager
render = null
state = clicks: 0
count = ->