Skip to content

Instantly share code, notes, and snippets.

View eightHundreds's full-sized avatar
💤

eightHundreds

💤
  • China
View GitHub Profile
@eightHundreds
eightHundreds / javaEnum2js.js
Last active October 14, 2023 06:36
java 转 js
function javaEnumToTs(code) {
return code.replace(
/(?![\n\r]+)(\w+)\((-?\d+),\s"([^"]+)"[^\n\r]+/g,
(match, g1, g2,g3) => `/**${g3}**/
${g1}:${g2},`
);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>regex基准</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@eightHundreds
eightHundreds / README.md
Created March 1, 2018 11:09 — forked from zenorocha/README.md
Github README示例

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage

@eightHundreds
eightHundreds / api.ts
Created February 26, 2021 09:28
api.ts 接口请求代码
{
"pp-api": {
"prefix": "ppa",
"body": [
"import { message } from 'antd';",
"import { AxiosResponse } from 'axios';",
"import http from 'helper/http';",
"import microservice from 'helper/microservice';",
"import { get as _get } from 'lodash';",
"const { javaAdmin } = microservice;",
@eightHundreds
eightHundreds / node-memory-config.md
Last active January 27, 2021 10:36
修改node内存限制

当不是用node方式启动时

NODE_OPTIONS=--max_old_space_size=4096 webpack xxx
@eightHundreds
eightHundreds / text-width.ts
Created November 27, 2020 01:55
计算文本宽度
/**
* 计算文本长度
* @param text
* @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
*/
function getTextWidth(text: string) {
// @ts-ignore
const canvas: HTMLCanvasElement = getTextWidth.canvas || (getTextWidth.canvas = document.createElement('canvas'));
const context = canvas.getContext('2d');
context!.font = '14px sans-serif'; // 14px是猜测的,不能确定
@eightHundreds
eightHundreds / hide-scrollbar.vue
Last active August 3, 2020 07:04
滚动条隐藏
<template>
</template>
<script lang="ts">
const onSomethingScrollFactory = () => {
const SCROLL_HIDE_TIMEOUT = 150;
const removeScrolling = debounce((el) => {
el.classList.remove('scrolling');
}, SCROLL_HIDE_TIMEOUT);
@eightHundreds
eightHundreds / api.ts
Last active July 17, 2020 03:38
Ts工具类型声明
namespace Api {
type PageParam<T = {}> = T & { pageNum?: number; pageSize?: number };
type ApiResult<T = {}> = {
[key: string]: any; // 其他基本用不到,想知道看文档
/**
* 调用是否成功
*/
success: boolean;
/**
* 业务状态码
@eightHundreds
eightHundreds / scrollbar.css
Last active July 15, 2020 03:19
滚动条
::-webkit-scrollbar {/* 滚动条整体样式 */
width: 4px; /* 高宽分别对应横竖滚动条的尺寸 */
height: 0;
}
::-webkit-scrollbar-thumb {/* 滚动条里面小方块 */
border-radius: 2px;
background: rgba(0, 0, 0, 0.13);
height: 60px;
}
git tag -d $(git tag --points-at HEAD) # 删除当前commit上的tag
git tag -d $(git tag -l) # 删除全部
git push origin --delete $(git tag -l) # 删除远端
# 参考 https://stackoverflow.com/questions/44702757/how-to-remove-all-git-origin-and-local-tags