Skip to content

Instantly share code, notes, and snippets.

donpark / FramePort.js
Last active Jun 29, 2020
Frame postMessage helper with request/response support
View FramePort.js
* Create port to an iframe element:
* const iframePort = new FramePort(iframeEl);
* Create port to parent window:
* const parentPort = new FramePort(window.parent);
* Post a message:
View scriptBaseUrl.js
// This needs to run when script loads.
const scriptUrl = new URL(document.currentScript.src, document.baseURI).toString();
const scriptBaseUrl = scriptUrl.substr(0, scriptUrl.lastIndexOf('/'));
// To build URL relative to script file.
const wasm = `${scriptBaseUrl}/wasm/my.wasm`
donpark / merge-example.ts
Last active Mar 3, 2020
Neat deep merge using TypeScript generics
View merge-example.ts
import { mergeObjects } from "./merge";
const defaultOptions = {
userMedia: {
audio: true,
video: false,
channelCount: 1,
autoGainControl: true,
echoCancellation: true,
noiseSuppression: true
donpark / VIA Porting
Created May 23, 2019 — forked from nooges/VIA Porting
Info on adding VIA Configurator support to a board using QMK
View VIA Porting

Making a board compatible with VIA Configurator

💥NOTE💥: Don't do this yet, all of this stuff is still 🚑💣BLEEDING EDGE💣🚑, and you will 🔪cut yourself🔪 badly if you choose to do it. Please wait for 🗿Wilba's QMK code to be refactored prior to pushing anything to QMK, as we don't want to end up with a bunch of different forks of the code.

So you've seen VIA Configurator in action, and you want to get this magic supported for your board?

There's two main steps:

  1. Add dynamic keymap support to keyboard in QMK
  2. Add layout to VIA
View ztype.js
// Built with IMPACT -
(function (window) {
"use strict"; = function (istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((this - istart) / (istop - istart));
Number.prototype.limit = function (min, max) {
return Math.min(max, Math.max(min, this));
Number.prototype.round = function (precision) {
donpark / hdlines.js
Created Aug 11, 2017 — forked from srt19170/hdlines.js
Hand-Drawn Lines Code (Javascript)
View hdlines.js
// Draw a line with the given curve, and then resample it
// to a new set of points. <step> is the distance to step
// along the line when taking a new point.
function drawInterpolate(svg, points, step, curve) {
curve = curve || d3.curveCatmullRom.alpha(1.0);
step = step || 1;
var lineFunc = d3.line()
donpark / JSONFeed.ts
Last active Mar 16, 2021
Rough first cut of JSON Feed types and interfaces
View JSONFeed.ts
/** JSON Feed TypeScript Declaration
* Spec Version: 1
declare namespace JSONFeed {
const MIME_TYPE = 'application/json'
type DATEstring = RFC3339string
type IDstring = string
donpark / PaperSetup.tsx
Created May 6, 2017
Setup Paper.js for use in React.js
View PaperSetup.tsx
import * as React from 'react'
import { Component } from 'react'
import { PaperScope } from 'paper'
export class PaperSetup extends Component<any, any> {
constructor(props) {
window['paper'] = new PaperScope()
donpark / NotificationEnum.swift
Created Dec 2, 2016
How to use enum of Notification.Name
View NotificationEnum.swift
import Foundation
// Extension allowing enum of Notification.Names.
#if swift(>=3.0)
extension Notification.Name: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
donpark /
Created Nov 22, 2016
Visible Touch support for demos and ReplayKit uses


Add VisibleTouch.swift to your project then replace window instance variable declaration in AppDelegate.swift file:

var window: UIWindow?


var window: UIWindow? = VisibleTouch.Window(frame: UIScreen.main.bounds)