Skip to content

Instantly share code, notes, and snippets.

View hjzheng's full-sized avatar
💭
I may be slow to respond.

HaoJu Zheng hjzheng

💭
I may be slow to respond.
View GitHub Profile
@hjzheng
hjzheng / Readme.md
Created August 17, 2021 08:51 — forked from lesonky/Readme.md
如何使用JavaScript实现纯前端读取和导出excel文件
@hjzheng
hjzheng / PriorityQueue.js
Created September 9, 2020 14:06
优先队列,默认大顶堆
class PriorityQueue {
constructor(data = [], compare = defaultCompare) {
this.data = data
this.length = this.data.length
this.compare = compare
if (this.length > 0) {
for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i)
}
}
@hjzheng
hjzheng / arrayFrom.js
Last active August 17, 2020 06:09
usefull array from
// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
// create 2d array
const create2DArray = (m, n, initVal) => Array.from(new Array(m), () => new Array(n).fill(initVal))
// create 3d array
const create3DArray = (m, n, d, initVal) => Array.from(new Array(m), () => Array.from(new Array(n), () => new Array(d).fill(initVal)))
@hjzheng
hjzheng / xss.md
Last active August 14, 2020 14:47
XSS

目录

  1. 什么是XSS
  2. XSS原理
  3. XSS危害
  4. XSS攻击 (攻击分类与举例)
  5. XSS防御
  6. XSS检测

什么是 XSS

@hjzheng
hjzheng / base58.ts
Created April 20, 2020 06:24
base58
function base58(encodeMap) {
function base58encode(int64: string): string {
let num = BigInt(int64)
const base = 58n
let res = ''
while (num >= base) {
res += encodeMap[num % base]
num = num / base
}
@hjzheng
hjzheng / generatePassword.js
Created January 9, 2020 10:17
生成随机密码(保证一个大写字母,一个小写字母,一个数字,一个特殊字符)
function generatePassword(length) {
let charsets = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '0123456789', '!#$%&*']
let allCharsets = charsets.join('')
let retVal = ''
for (let i = 0, len = charsets.length; i < len; i++) {
let n = charsets[i].length
@hjzheng
hjzheng / template.md
Last active January 2, 2020 02:41
递归+分治+回溯+动态规划

1.递归

function recur(level, params...) {
  // 终止条件
  if (level < maxLevel) {
    process_result
    return
  }
  
 // 处理当前层

HTML和CSS基础

  1. 熟悉 VS Code,注意几个常用插件的配置
  2. 熟悉 html 页面结构 ( 强调 doctype ), 注意 html规范
  3. 使用 Chrome dev tools 调试 CSS, HTML
  4. 使用 jsbin.com 写自己的 demo 页面
  5. reset.css 例如 normalize.css (为什么会有rest.css 和 浏览器的差异性)
  6. 盒模型
  7. CSS Layout 一些知识 传送门
  • block, inline 和 inline-block 元素特点
@hjzheng
hjzheng / genArray.js
Last active November 13, 2019 10:13
生成二维数组
function genArray(rows, cols, something) {
// BAD! Rows are copied by reference
// return new Array(rows).fill(new Array(cols).fill(something))
// good way
Array.from(Array(rows), () => new Array(cols).fill(something))
// more inefficient 12%
// return new Array(rows).fill(null).map(() => Array(cols).fill(something))
}
@hjzheng
hjzheng / range.js
Last active September 17, 2019 04:26
range
function range(start, end, step) {
if (arguments.length === 0) {
throw new Error('range fuction expect at least 1 argument')
}
if (arguments.length === 1) {
end = start
start = 0
step = 1