Skip to content

Instantly share code, notes, and snippets.


Ben Gotow bengotow

View GitHub Profile
bengotow / Examples.tsx
Created Jun 17, 2021
useResource with Examples
View Examples.tsx
// Basic usage to fetch data for display
export const NotesTabContent: React.FunctionComponent<{
scope: CoreAPI.TabScope;
boundsForExports: TimeBounds<number>;
}> = ({ scope, boundsForExports }) => {
const [kinds, setKinds] = useQueryPersistedState<string[]>({
encode: kinds => ({ kinds: kinds.join(',') }),
decode: qs => (qs.kinds ? qs.kinds.split(',') : ['New', 'Known']),
bengotow /
Created Jan 12, 2021
Foundry376 is Hiring!

We are hiring!

Foundry 376 is a small engineering group in Nashville, TN building best-in-class software for clients across the US. Our four person team brings decades of startup and product engineering experience to a handful of carefully picked clients each year. We aim to be a “dream team for hire”, collaborating with our clients to build great software in an environment that gives us the freedom to apply our skills and shape the products we build. In 2020, we worked with Sequoia Capital, Nylas, Rebel360, Dagster, and WithTheBand.

We’re seeking a third full-time engineer with 2-4 years of experience who will work with our team to deliver full-stack web applications in NodeJS and React / TypeScript.

About the role


bengotow / test.yaml
Created Dec 2, 2020
Complex Example YAML
View test.yaml
foo1: "{{ variable }}/additional/string/literal"
foo2: "{{ variable }}\\backslashes\\are\\also\\special\\characters"
foo3: "even if it's just a string literal it must all be quoted"
foo4: "a \t TAB and a \n NEWLINE"
foo5: "somebody said I should put a colon here: so I did"
wild: this } is [ all , valid
flow_mapping: { key: "you { should [ use , quotes here" }
inline_array: [123, 5123,1325, "123z", zzz1, 12-.txt, 5.123, -51.23]
inline_complex_1: [{asd: 123}, {b: 2}]
windows_drive: "c:"
View gist:3bd96a7706c49ff7b7fe510a94e85b49
### Keybase proof
I hereby claim:
* I am bengotow on github.
* I am bengotow ( on keybase.
* I have a public key ASDDxSAwBPSVRGc7yvuZ75H82B59i5vUWveNB6SEOhyCuwo
To claim this, I am signing this object:
bengotow / main.js
Created Jul 10, 2019
Mailspring plugin to assign a class to each thread list row
View main.js
// keep in mind this is a plain JavaScript file - the app won't "transpile" it
// in any way (Mailspring used to run Babel when it read plugin source code,
// but it became difficult to package up Babel as part of the application).
// We can still use most ES2016 language features because we use the latest Chrome.
// When you add this file to your theme also be sure to add a `main` entry to the
// package.json file to tell it that it should load this as the entrypoint of your plugin:
// {
// "main": "./main",
bengotow / deserialize.js
Created Jan 8, 2018
Slate HTML deserialize with nested block / inline handling
View deserialize.js
const DefaultParse = HtmlSerializer.parseHtml;
HtmlSerializer.parseHtml = html => {
const tree = DefaultParse.apply(HtmlSerializer, [html]);
const collapse = require('collapse-whitespace');
// ensure that no DIVs contain both element children and text node children. This is
// not allowed by Slate's core schema: blocks must contain inlines and text OR blocks.
const treeWalker = document.createTreeWalker(tree, NodeFilter.SHOW_ELEMENT, {
bengotow / linkify-plugin.js
Last active Feb 14, 2021
A Linkify plugin for DraftJS that creates / syncs entities on the fly
View linkify-plugin.js
import React from 'react';
import { RichUtils, Modifier, EditorState, SelectionState } from 'draft-js';
function isURL(text) {
return text.startsWith('http://'); // insert your favorite library here
Function you can call from your toolbar or "link button" to manually linkify
the selected text with an "explicit" flag that prevents autolinking from
changing the URL if the user changes the link text.
bengotow / spdlog-extensions.cpp
Created Aug 30, 2017
SPDLog Sink for "Flush Within Xmsec"
View spdlog-extensions.cpp
The code below shows a custom SPDLog sink that uses a separate thread and a C++0x condition_variable
to ensure that a spdlog::sinks::rotating_file_sink_mt is flushed to disk within a second of a new
log message being emitted. When no messages are arriving, the helper thread has very low wake overhead
and sleeps for 30s.
std::mutex spdFlushMtx;
std::condition_variable spdFlushCV;
int spdUnflushed = 0;
bengotow / Comparison.txt
Created Mar 17, 2016
Comparison of SQL Approaches for Counting Threads
View Comparison.txt
Option A: Two Subqueries
`Thread-Category`.`value` as category_id,
COALESCE((SELECT unread FROM `Thread-Counts` WHERE category_id = `Thread-Category`.`value`), 0) + SUM(unread) as unread,
COALESCE((SELECT total FROM `Thread-Counts` WHERE category_id = `Thread-Category`.`value`), 0) + COUNT(*) as total
FROM `Thread`
INNER JOIN `Thread-Category` ON `Thread`.`id` = `Thread-Category`.`id`
`Thread`.in_all_mail = 1
View Signature config.cson
"<ACCOUNT ID>": "<br>Test User<br>XXX-XXX-XXXX<br>"