Generate random characters Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 5); Math.random(),生成随机数,例如:0.09751664076957856 .toString(36),转换成36进制后
引用自stackoverflow: from tkinter import Tk r = Tk() r.withdraw() r.clipboard_clear() r.clipboard_append('i can has clipboardz?') r.update() # now it stays on the clipboard after the window is closed r.destroy() 注意:需要启用 tkinter
列出指定目录下的全部文件,或可以通过扩展名指定文件类型,也可以通过指定排除规则,忽略部分文件。 def list_files( dir: str, ext: list = None, recursive: bool = True, excludes: list = None ): """ Args: - dir, directory path.
目前(Python 3.8)为止,Python 并没有原生支持访问系统剪贴板。 搜寻出有几种方法,梳理如下: 使用系统 shell 命令简单有效。但是并不适合复
Qt/Pyside2 读取系统剪贴板内容 import sys from PySide2.QtWidgets import QApplication app = QApplication(sys.argv) clipboard = app.clipboard() print(clipboard.mimeData().formats()) print(clipboard.mimeData().data(clipboard.mimeData().formats()[0])) app.closeAllWindows() app=None mimeData() 就和 drag 时对 mimeData() 的操作一样了。 引用自 doc.qt.io: QClipboard supports the same data types that QDrag does, and uses similar mechanisms. For advanced clipboard usage read Drag and Drop .
copy copy text file content to clipboard
pbcopy < file.txt
copy command stdout to clipboard
ps aux | pbcopy
copy text
echo text | pbcopy
paste paste from clipboard to file
pbpaste > file.txt filter string
pbpaste | grep "hello" > file2.txt
echo text from clipboard
echo | pbpaste Reference
https://www.macobserver.com/tips/quick-tip/use-clipboard-in-terminal-without-mouse/
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 =
列出每个文件行数,以及总行数 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 以上示
交集:对于给定的两个集合,返回一个包含两个集合中共有元素的新集合。 使用 Python 元组数据类型 set 来实现交集操作。 a = [1, 2, 3] b = [3, 4, 5] c = set(a).intersection(set(b)) print(list(c)) # [3]