Skip to content

Instantly share code, notes, and snippets.

@lcomplete
lcomplete / hosts.ps1
Created December 23, 2021 03:21 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
@lcomplete
lcomplete / sub-directory-pull-all.sh
Last active December 27, 2021 08:39
更新所有子目录的git仓库
# 更新所有子目录的git仓库
for dir in $(find . -maxdepth 2 -mindepth 2 -type d | xargs); do (echo "$dir" && cd "$dir" && git pull); done
# 按月统计所有仓库的提交次数
for dir in $(find . -maxdepth 2 -mindepth 2 -type d | xargs); do (echo "$dir" && cd "$dir" && git-quick-stats -m | sed '1,3d' | awk '{print $1, $2}' >> /mnt/e/report/commit.txt); done
@lcomplete
lcomplete / rss_link_hunt.py
Created May 9, 2022 12:32
通过 OPML xml 文件解析 RSS feed,从 feed 中获取被推荐最多的链接
@lcomplete
lcomplete / -Spring-JPA-Dynamic-Query-With-Limit
Created September 21, 2022 09:31 — forked from tcollins/-Spring-JPA-Dynamic-Query-With-Limit
Spring Data JPA - Limit results when using Specifications without an unnecessary count query being executed
If you use the findAll(Specification, Pageable) method, a count query is first executed and then the
data query is executed if the count returns a value greater than the offset.
For what I was doing I did not need pageable, but simply wanted to limit my results. This is easy
to do with static named queries and methodNameMagicGoodness queries, but from my research (googling
for a few hours) I couldn't find a way to do it with dynamic criteria queries using Specifications.
During my search I found two things that helped me to figure out how to just do it myself.
1.) A stackoverflow question.