Skip to content

Instantly share code, notes, and snippets.

Avatar

Rex Zeng RexSkz

View GitHub Profile
@RexSkz
RexSkz / stringify.ts
Created Feb 8, 2022
JSON.stringify with depth limit
View stringify.ts
const stringify = (
obj: any,
replacer?: (this: any, key: string, value: any) => any,
space?: string | number,
depth = Infinity,
): string => {
if (!obj || typeof obj !== 'object') {
return JSON.stringify(obj, replacer, space);
}
const t = depth < 1
@RexSkz
RexSkz / roses-are-red.js
Created Aug 16, 2019 — forked from mutoo/roses-are-red.js
Roses are read, violets are blue. Unexpected token { at line 32.
View roses-are-red.js
// inspired by https://twitter.com/nixcraft/status/1162020669242003456
console.log('Roses are red, violets are blue.');
@RexSkz
RexSkz / nfa-match.go
Last active Feb 8, 2022
A simple code to show how NFA RegExp engine works.
View nfa-match.go
package main
import (
"fmt"
)
func match(s string, rules []string, sIndex, ruleIndex int) bool {
if ruleIndex == len(rules) {
fmt.Println("match: success")
return true
View keybase.md

Keybase proof

I hereby claim:

  • I am rexskz on github.
  • I am skywalker_z (https://keybase.io/skywalker_z) on keybase.
  • I have a public key ASA3HzI8Fv8-H0PEIMAp_ecppZTq4VD45vHHrO5aJt_dbgo

To claim this, I am signing this object:

@RexSkz
RexSkz / prism-javascript.js
Last active Feb 8, 2022
JavaScript file highlight for Prism.js (support function arguments)
View prism-javascript.js
// The prism.js library has already supported identifying function arguments according to:
// https://github.com/PrismJS/prism/pull/1446
// https://github.com/PrismJS/prism/pull/1722
// Please use the latest version instead.
@RexSkz
RexSkz / el-option-test.html
Last active Aug 16, 2017
Too many events are emited when `el-select`'s option changed
View el-option-test.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script type="text/javascript" src="https://fiddle.jshell.net/js/babel/babel.js"></script>
<script type="text/javascript" src="https://fiddle.jshell.net/js/lib/dummy.js"></script>
<link rel="stylesheet" type="text/css" href="https://fiddle.jshell.net/css/result-light.css">
<style type="text/css">