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 / 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 / curl.md
Last active December 25, 2019 10:42
curl 命令

curl 命令

如果你再*nix机器下,运行man curl命令查看具体的使用用法。

curl 简介

curl is a tool to transfer data from or to a server, using one of the supported protocols (http, https, ftp, ftps...). The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, ftp upload, http post, ssl connections, cookies, file transfer resum and more.

@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 / sed.md
Created July 25, 2014 11:29
sed简明教程

sed简明教程

FROM: 酷壳-陈皓

awk于1977年出生,今年36岁本命年,sed比awk大2-3岁,awk就像林妹妹,sed就是宝玉哥哥了。所以林妹妹跳了个Topless,他的哥哥sed坐不住了,也一定要出来抖一抖。

sed全名叫stream editor,流编辑器,用程序的方式来编辑文本,相当的hacker啊。sed基本上就是玩正则模式匹配,所以,玩sed的人,正则表达式一般都比较强。

同样,本篇文章不会说sed的全部东西,你可以参看sed的手册,我这里主要还是想和大家竞争一下那些从手机指缝间或马桶里流走的时间,用这些时间来学习一些东西。当然,接下来的还是要靠大家自己双手。

@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';
@zxhfighter
zxhfighter / vpn.md
Last active July 17, 2019 00:04
关于VPN的点点滴滴

关于VPN的点点滴滴

很多时候,我们需要翻墙做一点事情,你懂的。肉身翻墙有点困难,这时候我们就需要使用VPN进行虚拟翻墙了。

什么是VPN?


VPN是虚拟专用网络(Virtual Private Network)的简称,指的是在公用网络上建立专用网络的技术。之所以称之为虚拟网,是因为整个VPN网络的任意两个节点之间的连接并没有传统专网所需的端到端的物理链路,而是架构在公用网络服务商提供的网络平台,例如ATM、Frame Relay等之上的逻辑网络,用户数据在逻辑链路中传输。