Skip to content

Instantly share code, notes, and snippets.

flex container

  • flex-directionmain-axis (row [horizontal] → or column [vertical] ↓)
  • justify-contentmain-axis-align
  • align-itemscross-axis-align
  • align-contentcross-axis-align-wrapped

flex child

  • align-selfcross-axis-align-override
import { SafeAny } from "@dvtl/types";
/**
* Create a finite-state-machine (FSM) transitioning function by declaring the
* relationships between states.
*
* The FSM is modeled as a set of states and transitions between those states.
*
* The returned `transition` function is statically typed to ensure only valid
* transitions between states can occur.
// tslint:disable:no-invalid-this
import memoizeOne from "memoize-one";
import { EditorState, Plugin, Transaction, PluginSpec } from "prosemirror-state";
import { Schema } from "prosemirror-model";
declare module "prosemirror-state" {
// tslint:disable-next-line:no-any
interface PluginSpec<S extends Schema = any> {
replaceTransaction?:
| ((tr: Transaction, oldState: EditorState, newState: EditorState) => undefined | null | false | Transaction)
export function after(
$pos: ResolvedPos,
predicate: (node: Node, pos: number) => boolean
): { $pos: ResolvedPos; node: Node; parent: Node } | null {
let result: { $pos: ResolvedPos; node: Node; parent: Node } | null = null;
$pos.doc.nodesBetween($pos.pos, $pos.doc.content.size, (node, pos, parent) => {
if (pos < $pos.pos) {
// Don't recurse into nodes that are completely before the position we're
// interested in.
if (pos + node.nodeSize < $pos.pos) {
@bradleyayers
bradleyayers / example.ts
Created May 25, 2018 00:05
Example of a type safe finite-state-machine API in TypeScript.
interface StateOne {
type: "one";
prevName?: string;
}
interface StateTwo {
type: "two";
name?: string;
}
@bradleyayers
bradleyayers / plucking.py
Created November 27, 2012 02:09
Comparison of item removal techniques in python
import numpy
import numpy.ma
import random
import timeit
def using_del(numbers, indices):
numbers = numbers[:]
offset = 0
for i in indices:
@bradleyayers
bradleyayers / load-user-jobs.conf
Created April 26, 2012 21:26
Load user jobs at boot.
author 'Bradley Ayers'
description 'Enables user job "start on" stanzas to be honored at boot'
task
start on starting rc-sysinit
script
cat /etc/passwd | while read line
do
user=`echo $line | cut -d: -f1`
@bradleyayers
bradleyayers / gist:1660182
Created January 23, 2012 02:59
Save to `/etc/dbus-1/system.d/Upstart.conf` to enable Upstart user jobs
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only the root user can own the Upstart name -->
<policy user="root">
<allow own="com.ubuntu.Upstart" />
</policy>
@bradleyayers
bradleyayers / gist:1660177
Created January 23, 2012 02:57
PostgreSQL 9.1 Upstart Job
description "PostgreSQL 9.1 Server"
author "PostgreSQL"
start on runlevel [2345]
stop on runlevel [016]
respawn
pre-start script
if [ -d /var/run/postgresql ]; then
chmod 2775 /var/run/postgresql
else
@bradleyayers
bradleyayers / gist:1660160
Created January 23, 2012 02:52
Install Upstart 1.3 on Ubuntu 10.04
sudo apt-get remove gcc-4.4
sudo dpkg -i initramfs-tools-bin_0.99ubuntu8_amd64.deb
sudo dpkg -i initramfs-tools_0.99ubuntu8_all.deb
sudo dpkg -i --force-breaks friendly-recovery_0.2.18_all.deb
sudo dpkg -i libc-bin_2.13-20ubuntu5_amd64.deb
sudo dpkg -i libc6_2.13-20ubuntu5_amd64.deb
sudo /etc/init.d/apache2 start
sudo dpkg -i gcc-4.6-base_4.6.1-9ubuntu3_amd64.deb
sudo dpkg -i libgmp10_5.0.1+dfsg-7ubuntu2_amd64.deb
sudo dpkg -i libmpfr4_3.0.1-5_amd64.deb