Skip to content

Instantly share code, notes, and snippets.

Avatar

Vinh cvle

View GitHub Profile
@cvle
cvle / parseMarkup.ts
Last active Jan 13, 2020
Make Fluent work in IE11
View parseMarkup.ts
// Wait for this to land: https://github.com/zloirock/core-js/pull/732
// Then use this custom markup parser in <LocalizationProvider> as <template> doesn't work in IE11.
const parser = new DOMParser();
function parseMarkup(str: string) {
const doc = parser.parseFromString(`<body>${str}</body>`, "text/html");
return Array.from(doc.body.childNodes);
}
View gist:bd59c0627091f57c7d2185422ffd2b0f
### Keybase proof
I hereby claim:
* I am cvle on github.
* I am cvle (https://keybase.io/cvle) on keybase.
* I have a public key ASCX-4HrgTiKXO9jvtvQvDJMuYrj0YV5KHpuAaotBuoRkgo
To claim this, I am signing this object:
@cvle
cvle / expectAndFail.js
Last active May 31, 2019
Workaround for Jest Assertions not failing tests in a try/catch block
View expectAndFail.js
// Jest assertions will not fail if they live inside a try-catch block due to
// https://github.com/facebook/jest/issues/3917.
// This file returns a version of `expect` that fails
// the test immediately when an exception is thrown.
/**
* isPromise detects whether given object is a promise or not.
*/
const isPromise = obj =>
View typescript-bug-chaining-hocs.ts
import React from "react";
type Omit<T, K extends keyof T> = Pick<T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never, [x: number]: never })[keyof T]>;
type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
<P extends TInjectedProps>(
component: React.ComponentType<P>
) => React.ComponentType<Omit<P, keyof TInjectedProps> & TNeedsProps>;
type DefaultingInferableComponentEnhancer<TInjectedProps> =
@cvle
cvle / http-mitm-proxy-example.js
Last active May 23, 2018
http-mitm-proxy example
View http-mitm-proxy-example.js
const Proxy = require('http-mitm-proxy');
const proxy = Proxy();
const port = 8081;
const host = '0.0.0.0';
function appendToBody(chunk, s) {
return new Buffer(chunk.toString().replace(/<\/body>/g, s + '</body>'));
}
proxy.onError(function(ctx, err) {
View gist:283195454f02da4301d76bf08e8baff8
find folder/ -type f -name '*.js' | xargs sed -i 's/addNotification/notify/g'
View gist:a911bec79eb3ab476403716d44cade55
{
"data": {
"__schema": {
"queryType": {
"name": "RootQuery"
},
"mutationType": {
"name": "RootMutation"
},
"subscriptionType": {
@cvle
cvle / kvf-complex-example.sh
Last active Jul 28, 2016
kube-volume-freezer complex example.
View kvf-complex-example.sh
#!/bin/bash
# This script performs a live snapshotting of 3 Volumes from 3 different deployments simultaneously.
set -Eeuo pipefail
GCLOUD=gcloud
KUBECTL=kubectl
KVFCTL="docker run --net host --rm wikiwi/kube-volume-freezer kvfctl"
NAMESPACE=default
You can’t perform that action at this time.