Skip to content

Instantly share code, notes, and snippets.

@donpark
donpark / merge-example.ts
Last active March 3, 2020 20:22
Neat deep merge using TypeScript generics
import { mergeObjects } from "./merge";
const defaultOptions = {
userMedia: {
audio: true,
video: false,
channelCount: 1,
autoGainControl: true,
echoCancellation: true,
noiseSuppression: true
@donpark
donpark / VIA Porting Info.md
Created May 23, 2019 09:31 — forked from nooges/VIA Porting Info.md
Info on adding VIA Configurator support to a board using QMK

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
@donpark
donpark / kafka.md
Created February 14, 2012 02:58
Running Kafka 0.7

Running Apache Kafka 0.7

Download Initial Package

wget http://people.apache.org/~nehanarkhede/kafka-0.7.0-incubating/kafka-0.7.0-incubating-src.tar.gz
tar xvzf kafka-0.7.0-incubating-src.tar.gz
cd kafka-0.7.0-incubating-src

Build Kafka

@donpark
donpark / PaperSetup.tsx
Created May 6, 2017 01:15
Setup Paper.js for use in React.js
import * as React from 'react'
import { Component } from 'react'
import { PaperScope } from 'paper'
export class PaperSetup extends Component<any, any> {
constructor(props) {
super(props)
window['paper'] = new PaperScope()
}
@donpark
donpark / gist:7549a1a2a5f7eef7fbea
Created January 11, 2015 06:53
CALayer with resizable image
- (CALayer*)layerFromResiableImage:(UIImage*)image {
CGSize size = [image size];
UIEdgeInsets insets = [image capInsets];
CALayer *layer = [CALayer layer];
[layer setContents:(id)[image CGImage]];
layer.contentsCenter = CGRectMake(insets.left / size.width, insets.top / size.height,
1.0/size.width, 1.0 / size.height);
return layer;
}
// Built with IMPACT - impactjs.org
(function (window) {
"use strict";
Number.prototype.map = 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
donpark / hdlines.js
Created August 11, 2017 20:50 — forked from srt19170/hdlines.js
Hand-Drawn Lines Code (Javascript)
//
// 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()
.curve(curve)
@donpark
donpark / README.md
Created November 22, 2016 04:24
Visible Touch support for demos and ReplayKit uses

Integration

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

var window: UIWindow?

with:

var window: UIWindow? = VisibleTouch.Window(frame: UIScreen.main.bounds)
@donpark
donpark / aws-sdk-s3.ts
Created September 26, 2016 02:33
augment aws-sdk S3 with missing methods
import * as AWS from 'aws-sdk'
// extend S3 class via interface.
// could not get class augmenting to work in time. maybe not be possible even.
declare interface S3Extended extends AWS.S3 {
// missing methods
headBucket(params: any, callback?: (err: Error, data: any) => void): any;
createBucket(params: any, callback?: (err: Error, data: any) => void): any;
getBucketPolicy(params: any, callback?: (err: Error, data: any) => void): any;
putBucketPolicy(params: any, callback?: (err: Error, data: any) => void): any;
getBucketCors(params: any, callback?: (err: Error, data: any) => void): any;
@donpark
donpark / upload-a-s3-stream.js
Created September 23, 2016 08:43
node-slack-sdk example showing how to upload a S3 stream
var path = require('path');
var url = require('url');
var request = require('request');
var WebClient = require('@slack/client').WebClient;
var token = process.env.SLACK_API_TOKEN || '';
var web = new WebClient(token);
var s3Url = 'https://testbucket.s3-us-west-2.amazonaws.com/some/file/in/S3.mp4';
var s3Stream = // from s3.GetObject call