Skip to content

Instantly share code, notes, and snippets.

@maple-leaf
maple-leaf / gist:c5b795db33ca42949947cc423c78d261
Created August 11, 2021 05:44
dynamic callback argument type base on actual type of another argument
enum keys {
a = 'a',
b = 'b',
}
type mapping = {
[keys.a]: boolean;
[keys.b]: number;
};
const values = {
/* Modified base on https://github.com/ncjones/zap-script-proxy-rewrite/blob/master/proxy-rewrite.js
* Rewrite Zaproxy requests.
*
* Modify the "REWRITE_RULES" array below to contain your desired rewrite rules.
* The first matched rule will be applied for any given message.
*
* A rewrite rule is an object with two methods: "matches" and "rewrite", both
* of which require an HttpMessage as the only argument. The "matches" method
* returns a boolean indicating if the rule matches the message. The "rewrite"
* method rewrites the request by mutating the given message. See the Zaproxy
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<!-- 声明文档使用的字符编码 -->
<meta charset='utf-8'>
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 页面描述 -->
<meta name="description" content="不超过150个字符"/>
<!-- 页面关键词 -->
@maple-leaf
maple-leaf / introrx.md
Created June 20, 2019 09:28 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@maple-leaf
maple-leaf / search.sh
Created March 21, 2019 09:05 — forked from miguelmota/search.sh
Homebrew fix "Calling fails_with :gcc_4_0 is disabled! There is no replacement." or similar errors
find /usr/local/Cellar -regex '.*\.rb' -exec grep -r fails_with {} \;
# then comment out lines with fails_with
@maple-leaf
maple-leaf / multipart_upload.go
Created November 15, 2018 02:05 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@maple-leaf
maple-leaf / shence-directives
Last active September 13, 2018 09:23
神策vue directives
import Vue from 'vue';
// 神策点击
Vue.directive('sc-click', {
bind(el, binding) {
el.sensorClickTrack = (evt) => {
if (window.SC && !!binding.value) {
// 如果返回false类类型则不记录
window.SC.track('click', binding.value);
}
function createWorker(scriptString) {
let blob;
try {
blob = new Blob(['onmessage=function(e) {console.log(e)}']);
} catch (e) { // Backwards-compatibility
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new window.BlobBuilder();
blob.append(scriptString);
blob = blob.getBlob();
}
@maple-leaf
maple-leaf / tmux-cheatsheet.markdown
Created May 23, 2018 09:18 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@maple-leaf
maple-leaf / GIF-Screencast-OSX.md
Created May 3, 2017 07:21 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: