模拟器运行instantRunSplitApkResourcesDebug报错

android应用模拟器运行里提示/app/build/intermediates/instant_run_split_apk_resources/debug/instantRunSplitApkResourcesDebug/out/slice_1/resources_ap报错,解决方法:

依次打开
Preferences | Build, Execution, Deployment | Instant Run

不勾选
Enable Instant Run to hot swap code/resource changes on deploy(default enabled)

在shell中执行一个字符串

写shell脚本时经常会拼接一个字串,然后当成命令执行,用到的linux命令是eval ${str}或者echo ${str} | sh,例子如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash

start=1
amount=$1
raceId=$2
api_host=127.0.0.1:8080
str="curl --location --request POST 'http://${api_host}/api/AddBuy'
--header \"'Content-Type':'application/json'\"
--data-raw '{
\"PidStart\":$start,
\"Amount\":${amount},
\"RaceId\":${raceId}
}'"

echo ${str} | sh
# 或者
eval ${str}

github多帐号添加ssh公钥

github有两个账号,但是同一个ssh公钥只能添加给一个账号,需要再生成一个密匙后添加。步骤如下:

再添加一个ssh密匙

1、指定邮箱

1
2
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.

2、提示输入生成位置和文件名,取个不同的名称。如: /Users/you/.ssh/id_rsa1

1
Enter file in swhich to save the key (/Users/you/.ssh/id_rsa):

js防抖和节流

防抖和节流在前端性能优化中很常用,防抖和节流都是对一段时间内事件触发函数执行频率的控制;使用场景就是当频繁事件时怎样去处理函数执行。

防抖

在限定时间内,如果事件再次触发,丢弃当前已响应的函数执行,以当前事件响应函数重新计时

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function debounce(fn, wait) {
wait = wait || 200;
var timer = null;
return function () {
if (timer) {
clearTimeout(timer);
}
var args = arguments;
var that = this;
timer = setTimeout(function () {
timer = null;
fn.apply(that, args);
}, wait)
}
}