Skip to content

Instantly share code, notes, and snippets.

View ziyoung's full-sized avatar
🤒
I may be slow to respond.

hetech ziyoung

🤒
I may be slow to respond.
  • 上海浦东
View GitHub Profile
@ziyoung
ziyoung / pagespy.md
Created December 26, 2023 02:02
如何设计一个前端远程调试工具 --- 以 PageSpy 为例.md

PageSpy 是一个适用于远程 Web 项目调试的工具。在最近的更新中,还添加了对微信小程序的支持。

它通过对浏览器/微信小程序 API 的封装,将调用原生方法时的参数进行过滤、转化,整理成指定格式的消息供调试端消费;调试端收到消息后,在类似 Chrome devtools 的面板中将数据呈现出来。对于前端开发者来说,上手零成本。

PageSpy 调试面板

如果你现在还为调试远端的网页而苦恼,不妨先把 PageSpy 部署起来。如果你已经是 PageSpy 用户或者对这类调试工具的实现感兴趣,不妨跟着本文的讲解一探究竟。

主仓库地址:https://github.com/HuolalaTech/page-spy-web ,觉得好用的小伙伴可以点个 ⭐️。

@ziyoung
ziyoung / async.js
Last active May 12, 2023 10:02
泛泛而谈
const { EventEmitter } = require('event-emitter');
function mapAsync(iterable, mapper, option) {
// consumer 控制 concurrency
}
function filterAsync(iterable, filterer) {
// promise 控制
}
@ziyoung
ziyoung / cli.js
Last active March 30, 2021 03:40
Shebang and common snippet
#!/usr/bin/env node
console.log('cli application');
process.on('rejectionHandled', error => {
throw error;
});
@ziyoung
ziyoung / Makefile
Created June 26, 2020 13:53
go build flag
# go build link
PKG_NAME = github.com/ziyoung/repo
GO_LDFLAGS = -X ${PKG_NAME}/pkg.Var=123
build:
go build -ldflags "${GO_LDFLAGS}" -o file ./some-file.go
@ziyoung
ziyoung / Run.java
Created August 7, 2019 03:39
Java 中注解可以添加在方法的参数上
public class Run {
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
static @interface QueryParam {
String value();
}
public void testAnnotation(@QueryParam("action") String action) {
System.out.printf("action is %s\n", action);
}
@ziyoung
ziyoung / docker-compose.yml
Created August 1, 2019 12:11
MySQL container
version: "3"
services:
my-db:
image: "mysql:5.7"
container_name: "my-db"
restart: always
environment:
MYSQL_ROOT_PASSWORD: 12345
volumes:
@ziyoung
ziyoung / docker-compose.yml
Last active August 22, 2019 02:31
快速搭建 elk
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
version: '3'
services:
es01:
image: elasticsearch:7.2.0
container_name: es01
environment:
- node.name=es01
- discovery.seed_hosts=es02
- cluster.initial_master_nodes=es01,es02
@ziyoung
ziyoung / send-mail.js
Created June 6, 2019 07:41
批量发送邮件
const nodemailer = require('nodemailer');
const config = require('./config.json');
const wait = () => new Promise(resolve => setTimeout(resolve, 800));
async function main() {
let transporter = nodemailer.createTransport({
host: "email.example.com",
port: 587,
secure: false, // true for 465, false for other ports
@ziyoung
ziyoung / note.md
Last active April 29, 2019 10:09
数组与指针的关系

指针的介绍

  • 指针仅仅是指向计算机中的某个地址,并带有类型限定符。
  • 你可以对一个指针使用数组的语法来访问指向的东西,也可以对数组的名字做指针的算数运算。
  • 你应该每次尽可能使用数组,并且按需将指针用作提升性能的手段。

指针并不是数组

无论怎么样,你都不应该把指针和数组混为一谈。它们并不是相同的东西,即使C让你以一些相同的方法来使用它们

@ziyoung
ziyoung / test-load.js
Created April 28, 2019 09:30
测试 element 中的 Markdown loader
const genInlineComponentText = require('./build/md-loader/util').genInlineComponentText;
const template = '<el-input v-model="input" placeholder="请输入内容"></el-input>';
const script = `
export default {
data() {
return {
input: ''
}