Skip to content

Instantly share code, notes, and snippets.

@tim-evans
tim-evans / components.duration-field.js
Last active February 18, 2020 15:49
duration-field
import Component from '@ember/component';
import { set } from '@ember/object';
import { tryInvoke, isBlank } from '@ember/utils';
const UP = 38;
const DOWN = 40;
const BACKSPACE = 8;
function lpad(string, count, filler) {
if (string.length < count) {
@tim-evans
tim-evans / fetch-definitions.ts
Last active September 2, 2019 04:58
Apple News .d.ts generator
import { Annotation } from "@atjson/document";
import HTMLSource from "@atjson/source-html";
import { writeFileSync } from "fs";
import * as puppeteer from "puppeteer";
import { Page } from "puppeteer";
interface Definition {
URL: string;
inherits?: string;
example?: string;
@tim-evans
tim-evans / apple-news.d.ts
Last active September 2, 2019 04:57
Apple News Format
declare module AppleNews {
/**
* Augmented reality (AR) creates user experiences that add 2D or 3D elements to the live view from a device’s camera in a way that makes those elements appear to inhabit the real world. ARKit combines device motion tracking, camera scene capture, advanced scene processing, and display conveniences to simplify the task of building an AR experience. See [ARKit](https://developer.apple.com/documentation/arkit).
*
* Displaying ARKit content in Apple News requires an iOS device with an A9 or later processor.
*
* Important
*
* The ARKit feature can't be previewed on iOS versions earlier than iOS 12. If you are using News Preview, ensure you have Xcode 9 or later installed.
* @example
const https = require('https');
const { URL } = require('url');
const AWS = require('aws-sdk');
function fetch(location) {
let url = new URL(location);
return new Promise(resolve => {
return https.get({
host: url.host,
path: url.pathname
import * as React from 'react';
import { FC, useEffect, useRef, useState } from 'react';
import styled from 'styled-components';
import { Rectangle } from '../../src';
/*const blink = keyframes`
0% { opacity: 1; }
50% { opacity: 1; }
55% { opacity: 0; }
100% { opacity: 0; }
import { Reducer, useReducer, useDebugValue } from 'react';
export type ParameterType<
T extends (...args: any[]) => any
> = T extends (...args: infer R) => any ? R : undefined;
type TaskRunner = (...args: any[]) => IterableIterator<any>;
const startTask = (task: TaskRunner, ...params: ParameterType<TaskRunner>) => {
return {
/**
* Cross-browser support for caretPositionFromPoint.
* This returns a `CaretPosition` like object instead
* of a CaretPosition, since we can't create it for
* browsers that don't support this API.
*/
function caretPositionFromPoint(x: number, y: number): {
offsetNode: Node;
offset: number;
getClientRect(): ClientRect | DOMRect;
@tim-evans
tim-evans / tree.ts
Created May 11, 2019 03:39
atjson hir rewrite
class Tree {
label: string;
rank: number;
start: number;
end: number;
private children: Tree[];
constructor(params: {
label: string,
start: number,
@tim-evans
tim-evans / component.ts
Created July 24, 2018 03:04
Web Component
export interface EventCallback {
(evt: Event): boolean;
}
export interface EventHandlerDefinitions {
[key: string]: string | EventCallback;
}
export interface EventHandlerReferences {
[key: string]: EventCallback;