Skip to content

Instantly share code, notes, and snippets.

View zhuweiyou's full-sized avatar
🥃
喝完这杯,还有三杯

zhuweiyou

🥃
喝完这杯,还有三杯
  • Shanghai, China, Earth, Milky Way.
  • 19:51 (UTC +08:00)
View GitHub Profile
@zhuweiyou
zhuweiyou / idea
Last active September 20, 2023 15:28
idea 命令, 快捷打开文件或者文件夹
#!/bin/bash
# 判断是否传递了参数
if [ $# -eq 0 ]; then
/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea . > /dev/null 2>&1
else
/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea "$@" > /dev/null 2>&1
fi
# 文件保存到 /usr/local/bin/idea 并给执行权限
@zhuweiyou
zhuweiyou / vercel.json
Created September 16, 2023 02:36
利用 vercel 做反代服务
{
"rewrites": [
{
"source": "/:path*",
"destination": "https://domain.com/:path*"
}
]
}
@zhuweiyou
zhuweiyou / svn-checkout-git-sub-directory.md
Last active August 22, 2023 02:22
用 svn 下载 git 仓库子文件夹

把 URL 中的 /tree/main 替换为 /trunk/branches/分支名

下载主分支的子文件夹

svn checkout https://github.com/{user_name}/{repo_name}/trunk/子文件夹路径

下载其它分支的子文件夹

@zhuweiyou
zhuweiyou / on-reach-bottom.js
Created August 18, 2023 09:51
监听滚动到底部
export function onReachBottomContainer(container, callback, offset = 50) {
const element = typeof container === 'string' ? document.querySelector(container) : container
function onScroll() {
const scrollHeight = element.scrollHeight
const scrollTop = element.scrollTop
const clientHeight = element.clientHeight
if (scrollHeight - scrollTop <= clientHeight + offset) {
callback()
}
@zhuweiyou
zhuweiyou / movable.js
Last active August 18, 2023 09:50
让元素可以拖动
export function movable(element) {
if (typeof element === 'string') {
element = document.querySelector(element)
}
let isDragging = false
let currentX
let currentY
let initialX
let initialY
@zhuweiyou
zhuweiyou / get-middle-string.js
Created August 18, 2023 09:47
取中间文本
export function getMiddleString(src = '', left = '', right = '', more = false) {
let leftIndex = src.indexOf(left)
if (leftIndex === -1) {
return ''
}
leftIndex += left.length
let rightIndex
if (more) {
rightIndex = src.lastIndexOf(right, leftIndex)

差异打包

有时候需要给到别人改动的文件, 而不是全量, 此时就可以在 git仓库根目录执行

git archive -o update.zip HEAD $(git diff --name-only 改动的前一个COMMIT_ID HEAD)

#!/bin/sh
hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
wslip=$(hostname -I | awk '{print $1}')
port=7890
PROXY_HTTP=${hostip}:${port}
export https_proxy=http://${PROXY_HTTP} http_proxy=http://${PROXY_HTTP} all_proxy=socks5://${PROXY_HTTP}