Skip to content

Instantly share code, notes, and snippets.

View zxhfighter's full-sized avatar
🏠
Working from home

ski zxhfighter

🏠
Working from home
View GitHub Profile
@zxhfighter
zxhfighter / cherry-pick.md
Created March 23, 2020 06:49
cherry pick

cherry-pick

挑选某些提交应用到某个分支上。

例如某个提交(例如 fa2c50ba)本来需要提交到 develop,现在提交到了 master 分支。

那么我们可以去 master 分支,挑选刚才的提交,应用到 develop 分支即可。

git checkout develop

正向代理和反向代理

TLDR; 正向代理隐藏真实客户端,反向代理隐藏真实服务端。

正向代理

正向代理服务器代理的是客户端,为客户端收发请求,使真实客户端对服务器不可见。

客户端必须设置正向代理服务器,当然前提是要知道正向代理服务器的IP地址,还有代理程序的端口。

@zxhfighter
zxhfighter / async.ts
Created March 5, 2020 04:46
async demo
async function sleep(name: string, ms: number) {
await new Promise(resolve => {
console.log(`${name} sleep ${ms} seconds`);
setTimeout(resolve, ms);
});
}
async function forEachLoop() {
const numbers = [1, 2, 3, 4, 5];
const basetime = Date.now();
@zxhfighter
zxhfighter / blob-applications.md
Last active October 29, 2019 07:37
blob 各种应用场景

Blob

应用背景是,不想暴露下载地址(例如一些视频网站防止视频抓取),这时候就在后端根据文件地址直接转成二进制流形式,返回给前端合并,再进行下载。

可以使用 Blob 处理二进制流,进行文件下载。

语法

{
@zxhfighter
zxhfighter / git-format-patch.md
Last active October 24, 2019 03:39
how to user git format-patch and git am

如何生成 patch 和应用 patch

生成 patch

git format-patch

git format-patch HEAD^         # 生成最近的1次commit的patch
git format-patch HEAD^^        # 生成最近的2次commit的patch
git format-patch .. # 生成版本 r1-r2 之间的patch
@zxhfighter
zxhfighter / reset-author.md
Last active October 21, 2019 10:37
git 小提示

配置当前仓库用户名和邮箱。

git config user.name 'XXX'
git config user.email 'XXX'

或者

@zxhfighter
zxhfighter / flask-launch.json
Created July 23, 2019 07:44
调试 python 和 flask 文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
@zxhfighter
zxhfighter / debug-typescript.md
Last active July 23, 2019 07:30
调试 typescript,gulp 脚本等

调试 Typescript

debugger 浏览器调试法

有两种调试方式。

一种在代码中写 debugger 断点。

task('help', cb => {
@zxhfighter
zxhfighter / node-upload.md
Created July 21, 2019 01:39
Node 上传文件
const http = require('http');
const {readFileSync} = require('fs');
const {basename, normalize} = require('path');

const token =
    'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzNjk3NDk0NTZAcXEuY29tIiwiaWF0IjoxNTYzMzcyNDU1LCJleHAiOjE1NjMzNzYwNTV9.3E927Cxom1qWSZ0a8NbVu_4F0NdTL252PCqlv8KiAhA';

function getFileContent(file, boundary) {
    const crlf = '\r\n';