Skip to content

Instantly share code, notes, and snippets.

Tim Mensch TimMensch

Block or report user

Report or block TimMensch

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
View keybase.md

Keybase proof

I hereby claim:

  • I am timmensch on github.
  • I am timmensch (https://keybase.io/timmensch) on keybase.
  • I have a public key ASCBoS_QiHMPU0cE8Mot3Bd-qPHogMfycz9Ujo-tmFLQigo

To claim this, I am signing this object:

@TimMensch
TimMensch / auth-complex.js
Created Nov 8, 2018
A slightly more complex counterexample to the "Functional River" that would be much uglier in promise form.
View auth-complex.js
// Easier to follow. Equally easy to test -- and with one fewer function in need of testing.
import { userInfo } from "os";
const Promise = require("bluebird");
const { hashStringAsync } = Promise.promisifyAll(require("./lib/crypto"));
const { logEventAsync } = Promise.promisifyAll(require("./lib/log"));
const { openAsync } = Promise.promisifyAll(require("./lib/db"));
const { TimeoutError, ValidationError, NotFoundError } = require("./errors");
@TimMensch
TimMensch / auth.js
Last active Nov 8, 2018
An alternative to the "Functional River"
View auth.js
// Easier to follow. Equally easy to test -- and with one fewer function in need of testing.
const Promise = require("bluebird");
const { hashStringAsync } = Promise.promisifyAll(require("./lib/crypto"));
const { logEventAsync } = Promise.promisifyAll(require("./lib/log"));
const { openAsync } = Promise.promisifyAll(require("./lib/db"));
const { TimeoutError, ValidationError, NotFoundError } = require("./errors");
const _openHandle = openAsync(); // FYI: Promises include memoization (caching) built into same API
@TimMensch
TimMensch / example.graphql
Last active Jan 15, 2018
Example GitHub v4 API Query that fails
View example.graphql
{
repository(name: "MidiPlayerJS", owner: "TimMensch") {
ref(qualifiedName:"tim") {
name
target {
... on Commit {
author {
name
}
blame(path:"package.json") {
@TimMensch
TimMensch / validateSchema.js
Created Dec 4, 2017
Validation of JSON based on a TypeScript declaration
View validateSchema.js
/*
Copyright 2017, Tim Mensch.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
View git-fat modified to run (barely) on Python 3.4.1 on Windows
#!/usr/bin/env python
# -*- mode: python -*-
from __future__ import print_function, with_statement
import sys
import hashlib
import tempfile
import os
import subprocess
You can’t perform that action at this time.