Skip to content

Instantly share code, notes, and snippets.

@sfpprxy
sfpprxy / cleanup_swap.md
Created June 12, 2023 05:51 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@sfpprxy
sfpprxy / switch.ahk
Created May 15, 2021 05:36
windwos ahk script switch between windows of same application
; alt+esc -> switch
!Esc:: ; Next window
WinGetClass, ActiveClass, A
WinSet, Bottom,, A
WinActivate, ahk_class %ActiveClass%
return
@sfpprxy
sfpprxy / jb.txt
Created December 18, 2020 01:21
jb
TCN5GLIWHR-eyJsaWNlbnNlSWQiOiJUQ041R0xJV0hSIiwibGljZW5zZWVOYW1lIjoiamV0IGpldCIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiIiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IkRDIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJEQiIsInBhaWRVcFRvIjoiMjAyMS0wMS0wMyJ9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJSU1YiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJSU1UiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAyMS0wMS0wMyJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiUkQiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAyMS0wMS0wMyJ9LHsiY29kZSI6IkNMIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiUlMwIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiUlNDIiwicGFpZFVwVG8iOiIyMDIxLTAxLTAzIn0seyJjb2RlIjoiR08iLCJwYWlkVXBUbyI6IjIwMjEtMDEtMDMifSx7ImNvZGUiOiJSU0YiLCJwYWlkVXBUbyI6IjIwMjEtMDEtM
@sfpprxy
sfpprxy / installjava.sh
Created November 17, 2020 09:49
install j9jvm java via sdkman
#!/usr/local/bin/zsh
apt install curl zip unzip -y
curl -s "https://get.sdkman.io" | bash
source "/root/.sdkman/bin/sdkman-init.sh"
while :
do
echo "try download java..."
@sfpprxy
sfpprxy / shit.md
Last active September 18, 2020 06:46
难以测试或测试无效化的场景

难以测试或测试无效化的场景

#buf

假设

  1. 接口是http://xxx.xxx/update_all_user, 没有其他参数
  2. 业务需求是我有一波users通过http接口取自第三方系统,想存到本项目的数据库里。根据userId这个主键来判断,如果数据库user表里有一致的主键,就把数据表这条记录中其他的字段更新成user对应的属性,否则就把user作为一条新的记录插入数据表
  3. 本项目使用了一个我不熟悉的orm库叫 internal-orm, internal-orm是我们公司自己写的内部使用的库

实操

  1. 现在internal-orm提供了3个api,分别是 writeAll() persistAll() 和 saveAll(),我不清楚这3个api的语义,我填写配置文件连接了数据库,并且尝试性的选择了writeAll来实现业务需求。
@sfpprxy
sfpprxy / checkPPAs.sh
Created September 4, 2020 06:53
auto remove unused PPAs
#!/usr/bin/env bash
for f in /etc/apt/sources.list.d/*.list; do
grep -Po "(?<=^deb\s).*?(?=#|$)" "$f" | while read -r ENTRY ; do
echo "ENTRY: $ENTRY"
# Sanitize entry line by removing stuff between square brackets
ENTRY=$(echo "$ENTRY" | sed 's/\[.*\] //')
HOST=$(cut -d/ -f3 <<< "$ENTRY")
root@shtx ~# su - dodsserver
-su: dircolors: command not found
-su: ls: command not found
dodsserver@shtx:~$ echo
dodsserver@shtx:~$ echo $PATH
{M2_HOME}/bin:{PATH}
dodsserver@shtx:~$ exit
logout
root@shtx ~# sudo su - postgres
@sfpprxy
sfpprxy / install-graalvm.sh
Created August 24, 2020 03:25
install-graalvm
#!/bin/bash
# remove yourself
rm $0
if [ "$1" == "" ]; then
JAVA_VERSION="11"
else
JAVA_VERSION="$1"
fi
@sfpprxy
sfpprxy / cmds
Last active August 20, 2020 18:58
dods_info1
su - dodsserver
./dodsserver restart
./dodsserver debug
root@shtx /home/dodsserver/serverfiles# chown -R dodsserver:dodsserver ./**/**
@sfpprxy
sfpprxy / install.sh
Created August 13, 2019 03:42
fish shell install
sudo apt-add-repository ppa:fish-shell/release-3
sudo apt-get update
sudo apt-get install fish