Skip to content

Instantly share code, notes, and snippets.

View bengotow's full-sized avatar

Ben Gotow bengotow

View GitHub Profile
@bengotow
bengotow / deserialize.js
Created January 8, 2018 18:49
Slate HTML deserialize with nested block / inline handling
const DefaultParse = HtmlSerializer.parseHtml;
HtmlSerializer.parseHtml = html => {
const tree = DefaultParse.apply(HtmlSerializer, [html]);
const collapse = require('collapse-whitespace');
collapse(tree);
// 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.
// https://docs.slatejs.org/guides/data-model#documents-and-nodes
const treeWalker = document.createTreeWalker(tree, NodeFilter.SHOW_ELEMENT, {
@bengotow
bengotow / main.js
Created July 10, 2019 17:19
Mailspring plugin to assign a class to each thread list row
// 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",
### Keybase proof
I hereby claim:
* I am bengotow on github.
* I am bengotow (https://keybase.io/bengotow) on keybase.
* I have a public key ASDDxSAwBPSVRGc7yvuZ75H82B59i5vUWveNB6SEOhyCuwo
To claim this, I am signing this object:
@bengotow
bengotow / test.yaml
Created December 2, 2020 18:03
Complex Example 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:"
@bengotow
bengotow / Examples.tsx
Created June 17, 2021 19:50
useResource with Examples
// 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
bengotow / software-engineer.md
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
bengotow / linkify-plugin.js
Last active December 23, 2022 15:33
A Linkify plugin for DraftJS that creates / syncs entities on the fly
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.