Skip to content

Instantly share code, notes, and snippets.

@gwillz
gwillz / moment-tags.js
Last active September 27, 2018 02:06
ES6 tagged template string for inline date fomatting
/**
* This doesn't _need_ to use moment.
* It's just the library that this project is using.
* Luxon or date-fns could also drop in neatly.
*/
const moment = require('moment')
// This a bad name, as is 'format', so idk.
function inline(literals, ...parts) {
let join = '';
/// <reference types="node" />
type Shm<T> = (T & { key: number });
type ShmMap = {
Buffer: Shm<Buffer>;
Int8Array: Shm<Int8Array>;
Uint8Array: Shm<Uint8Array>;
Uint8ClampedArray: Shm<Uint8ClampedArray>;
Int16Array: Shm<Int16Array>;
declare module 'connect-static-file' {
import {Handler} from 'express'
import {SendOptions} from 'send'
interface Options extends SendOptions {
encoded?: string;
headers?: {[key: string]: string};
}
@gwillz
gwillz / react-leaflet.d.ts
Last active August 23, 2018 02:45
React-Leaflet type definitions for v2.0 (extension for existing @types/react-leaflet)
import * as React from 'react'
import * as L from 'leaflet'
import 'react-leaflet'
declare module 'react-leaflet' {
export interface LeafletContext {
map?: L.Map,
pane?: string,
@gwillz
gwillz / draft-js-plugins.d.ts
Created July 5, 2018 08:53
Naive TypeScript support for draft-js-plugins
/// <resources type="react" />
/// <resources type="draft-js" />
declare module "draft-js-plugins-editor" {
export type PluginsEditorProps = Draft.EditorProps | {
plugins: any,
}
export default class PluginsEditor
extends React.Component<PluginsEditorProps, Draft.EditorState> {}