function clearTimeout() {
var id = window.setTimeout(function() {}, 0);
while (id--) {
window.clearTimeout(id);
}
}
clearTimeout();
通过浏览器标签(Bookmarklet方式)调用:
【ClearTimeout】 <-拖拽链接到浏览器标签栏
function clearTimeout() {
var id = window.setTimeout(function() {}, 0);
while (id--) {
window.clearTimeout(id);
}
}
clearTimeout();
通过浏览器标签(Bookmarklet方式)调用:
【ClearTimeout】 <-拖拽链接到浏览器标签栏
function getScrollTop() {
var scrollTop = 0,
bodyScrollTop = 0,
documentScrollTop = 0;
if (document.body) {
bodyScrollTop = document.body.scrollTop;
}
if (document.documentElement) {
documentScrollTop = document.documentElement.scrollTop;
}
scrollTop =
bodyScrollTop - documentScrollTop > 0
? bodyScrollTop
: documentScrollTop;
return scrollTop;
}
function getScrollHeight() {
var scrollHeight = 0,
bodyScrollHeight = 0,
documentScrollHeight = 0;
if (document.body) {
bodyScrollHeight = document.body.scrollHeight;
}
if (document.documentElement) {
documentScrollHeight = document.documentElement.scrollHeight;
}
scrollHeight =
bodyScrollHeight - documentScrollHeight > 0
? bodyScrollHeight
: documentScrollHeight;
return scrollHeight;
}
function getWindowHeight() {
var windowHeight = 0;
if (document.compatMode == "CSS1Compat") {
windowHeight = document.documentElement.clientHeight;
} else {
windowHeight = document.body.clientHeight;
}
return windowHeight;
}
//
function autoScroll() {
if (getScrollTop() + getWindowHeight() < getScrollHeight()) {
window.scrollTo({
top: window.scrollY + 5,
behavior: "smooth",
});
var timerId = setTimeout(autoScroll, 50);
// stop when click
document.addEventListener("click", (event) => {
window.clearInterval(timerId);
});
}
}
autoScroll();
通过浏览器标签(Bookmarklet方式)调用,拖拽下面的链接到浏览器标签栏:
列出每个文件行数,以及总行数
git ls-files | xargs wc -l
指定文件夹
git ls-files src lib | xargs wc -l
以上示例是指定仓库中 lib 文件夹
过滤文件夹或文件类型
git ls-files | grep -Ev 'examples|.txt' | xargs wc -l
以上示例是过滤 examples 文件夹和所有 .txt 文件
交集:对于给定的两个集合,返回一个包含两个集合中共有元素的新集合。
使用 Python 元组数据类型 set
来实现交集操作。
a = [1, 2, 3]
b = [3, 4, 5]
c = set(a).intersection(set(b))
print(list(c))
# [3]
原因:有 backend environment,需要先删除
一般这时通过 Web Console 删除后端环境也会失败。可以通过 AWS CLI 来删除:
aws amplify delete-backend-environment --app-id YOUR-APP-ID --environment-name ENV-NAME --region YOR-REGION-NAME
APP ID 查寻方式:
App settings -> General, App ARN 的最后部分。例如:
arn:aws:amplify:ap-southeast-1:YOUR-ACCOUNT-ID:apps/APP-ID
当我们需要某些 DOM 元素不响应鼠标事件时,例如点击(click) 悬停(hover)等, 可以使用 CSS 属性直接实现,方便快捷。
CSS 方法:
div {
pointer-events: none;
}
如果项目使用 tailwindcss, 可以使用类名: pointer-events-none
构建、编辑、分析和测试正则表达式的工具。
地址 | 介绍 |
---|---|
https://regex101.com/ | 构建、测试及调试正则表达式。适配多种编程语言规则 |
https://www.debuggex.com/ | 可视化正则表达式分析、测试器 |
https://regexr.com/ | 学习、构建及测试正则表达式 |
获取程序运行的工作目录。
当前工作目录的相对路径
os.curdir
,是个常量,Unix-like 系统下是 .
当前工作目录的绝对路径
os.getcwd()
或 os.path.abspath(os.curdir)
当前工作目录的上级(父)目录的路径
os.path.dirname(os.getcwd())