Skip to content

Instantly share code, notes, and snippets.

View zhujinxuan's full-sized avatar
🌂
Please don't fire at head

Jinxuan Zhu zhujinxuan

🌂
Please don't fire at head
  • eGenerationMarketing Inc
  • Boston
View GitHub Profile

Keybase proof

I hereby claim:

  • I am zhujinxuan on github.
  • I am jinxuanzhu (https://keybase.io/jinxuanzhu) on keybase.
  • I have a public key ASBdALdgDc4qwKAdrYnbmhsRsbxCvm0Ek2uw1CpK8nQJyQo

To claim this, I am signing this object:

@zhujinxuan
zhujinxuan / memoize.ts
Created March 14, 2019 16:09
Naive memoize gist
/* tslint:disable:ban-types */
const BOUND = Symbol('BOUND_FUNCTION')
const UNDEFINED = Symbol('UNDEFINED')
const NULL = Symbol('NULL')
const WM_STORE = Symbol('WM_STORE')
const RESULT = Symbol('RESULT')
interface IST {
[WM_STORE]?: WeakMap<any, IST>;
[RESULT]?: any;
@zhujinxuan
zhujinxuan / Sum.ts
Created March 14, 2019 15:57
A Naibe Sum type for typescript
enum LR { isInL, isInR }
class InL<L> {
public readonly cc: LR = LR.isInL
public readonly value : L;
constructor(x : L) {
this.value = x;
}
}
@zhujinxuan
zhujinxuan / gist:d89092daddfc864e3a141a88295d5988
Created October 15, 2018 20:43 — forked from jvenator/gist:9672772a631c117da151
PDFtk Server Install Workaround for Mac OS X

Installing PDFtk Server edittion on your Mac

This workaround install is necessary because PDFtk was pulled from homebrew-cask due to issues with it aggressively overwriting file permissions that could impact other installed libraries. See this homebrew-cask issue.
The following steps worked on Mac OS X 10.10.1 with a standard brew installation for the PDFtk Mac OS X server libary version 2.02.
All Terminal commands separated by a full line space. Some commands wrap into multiple lines.

Download and extract the Mac OS X server install pacakge

@zhujinxuan
zhujinxuan / parseHTML.js
Created December 25, 2017 17:27
A naive solution for paste html to slatejs: convert classNames to inline style and wrap everything inside a div
import mergeStyle from "./mergeStyle/index.js";
/**
* A default parseHTML by Slate
*
* @param {String} html
* @return {Object}
*/
function slateDOMParser(html) {
if (typeof DOMParser === "undefined") {
throw new Error(
@zhujinxuan
zhujinxuan / js
Created October 17, 2017 16:23
validate with some parenthesis
"use strict";
function evaluate(expression) {
let neatExpr = expr2Array(expression);
let rightInd = evaluateNeat(neatExpr, 1);
return rightInd === neatExpr.length - 1;
}
function expr2Array(expression) {
let newExpr = expression.replace(/\(/g, " ( ").replace(/\)/g, " ) ");
let neatExpr = newExpr.split(" ").filter(xstr => xstr !== "");