Skip to content

Instantly share code, notes, and snippets.


Ben Gotow bengotow

View GitHub Profile
bengotow / Examples.tsx
Created June 17, 2021 19:50
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 /
Last active September 2, 2021 16:17
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 five 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, Elementl, and WithTheBand.

We’re seeking a 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. Experience using TypeScript is not a prerequisite (we'll get you up to speed!) but familiarity with React and the JavaScript ecosystem are important

bengotow / test.yaml
Created December 2, 2020 18:03
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 July 10, 2019 17:19
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 January 8, 2018 18:49
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 December 23, 2022 15:33
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 August 30, 2017 21:23
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 March 17, 2016 19:27
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>"