Skip to content

Instantly share code, notes, and snippets.

View semlinker's full-sized avatar
👊
Fighting

阿宝哥 semlinker

👊
Fighting
View GitHub Profile
@semlinker
semlinker / FinallyTest.java
Last active November 6, 2019 11:01
Java try-catch-finally
public class FinallyTest {
public void foo() {
try {
tryItOut();
} catch (MyException e) {
handleException(e);
} finally {
handleFinally();
}
}
@semlinker
semlinker / plink-plonk.js
Created February 20, 2020 00:14 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@semlinker
semlinker / on-load.js
Created August 18, 2020 01:07
Code Snippet for MutationObserver
const watch = Object.create(null);
const KEY_ID = "onloadid" + Math.random().toString(36).slice(2);
const KEY_ATTR = "data-" + KEY_ID;
let INDEX = 0;
if (window && window.MutationObserver) {
const observer = new MutationObserver(function (mutations) {
if (Object.keys(watch).length < 1) return;
for (let i = 0; i < mutations.length; i++) {
if (mutations[i].attributeName === KEY_ATTR) {
@semlinker
semlinker / index.html
Created December 23, 2020 03:06
Clipboard API Demo for Copy Image and Text
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<title>Copy image and text</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="container">
<img
@semlinker
semlinker / index.html
Last active June 4, 2023 07:10
Axios 取消重复请求
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Axios 取消重复请求示例</title>
<script src="https://cdn.bootcdn.net/ajax/libs/qs/6.9.6/qs.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
@semlinker
semlinker / index.html
Created April 11, 2021 05:49
Axios 缓存请求数据示例
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Axios 缓存请求数据示例</title>
<script src="https://cdn.bootcdn.net/ajax/libs/qs/6.9.6/qs.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
@semlinker
semlinker / axios-retry-adapter.html
Created April 17, 2021 14:49
Axios 请求重试示例
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Axios 请求重试示例(适配器)</title>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body>
@semlinker
semlinker / index.html
Created April 18, 2021 09:22
JavaScript 中实现大文件并行下载
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>多线程下载示例</title>
<script src="multi-thread-download.js"></script>
</head>
<body>
@semlinker
semlinker / app.js
Last active January 29, 2023 18:55
在线解压ZIP文件
const path = require("path");
const Koa = require("koa");
const cors = require("@koa/cors");
const Router = require("@koa/router");
const StreamZip = require("node-stream-zip");
const app = new Koa();
const router = new Router();
const ZIP_HOME = path.join(__dirname, "zip");
const UnzipCaches = new Map();
@semlinker
semlinker / directory-upload.js
Created May 11, 2021 14:10
目录上传和压缩目录上传示例
const path = require("path");
const Koa = require("koa");
const cors = require("@koa/cors");
const multer = require("@koa/multer");
const Router = require("@koa/router");
const fse = require("fs-extra");
const app = new Koa();
const router = new Router();
const paths = path.sep + ["public", "upload"].join(path.sep);