This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path_unzip /home/ouuan/scripts/unzip-cp936.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# X.Org 任意窗口划词翻译 | |
# 在 DE/WM 中设置快捷键执行 | |
# 分单词和句子两种模式,notification 中显示的都是 Google 翻译的结果,但单词附带百度翻译的链接,句子附带 Google 翻译的链接 | |
# notification 中附带的链接是否能点开依赖于 notification daemon,dunst 需要在设置中的 `mouse_left_click` 处加上 `open_url` | |
# 翻译的单词连同日期和窗口标题会记录在 ~/.cache/translated-words.txt | |
# 可以使用 http_proxy 环境变量设置代理 | |
# notification 的 appname 是 "xorg-translate",在 dunst 中可以对其进行配置,例如设置图标 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LANG=C pactl subscribe | grep --line-buffered "Event 'remove' on sink" | xargs -L1 playerctl -a pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# In <duration> seconds, if you have been unlocked for more than <permit> seconds, you'll be locked; | |
# if you have been unlocked for more than <warning> seconds, you'll be asked to lock every <dialoginterval> seconds. | |
# The stats are saved at <file>. | |
duration=3600 | |
permit=3200 | |
warning=2800 | |
dialoginterval=180 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
file="$HOME/.track-window-stats" | |
period=1 | |
while true | |
do | |
locked=$(loginctl show-session "$XDG_SESSION_ID" -p LockedHint --value) | |
if [[ "$locked" == 'yes' ]]; then | |
result='<locked>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
origin_reversed() { | |
local tmp_dir=/tmp/concat_original_video_and_reversed_video | |
local base_name=$(basename "$1") | |
local mts_path="$tmp_dir/${base_name}.mts" | |
local reversed_path="$tmp_dir/${base_name}-reversed.mts" | |
local concat_path="$tmp_dir/${base_name}-concat.mts" | |
local list_path="$tmp_dir/${base_name}-list" | |
mkdir -p "$tmp_dir" | |
ffmpeg -i "$1" -q 0 "$mts_path" | |
ffmpeg -i "$mts_path" -vf reverse -af areverse "$reversed_path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this in ~/.zshrc | |
math() { | |
local MATH_RESPONSE | |
case $(($RANDOM % 3)) in | |
0) | |
local MATH_A=$(($RANDOM % 10000)) | |
local MATH_B=$(($RANDOM % 10000)) | |
read "MATH_RESPONSE?$MATH_A + $MATH_B = " | |
local MATH_ANSWER=$(($MATH_A + $MATH_B)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/ouuan/c88295eea5dd89feecd712e8005d9dfa | |
# the package dateutils is required for the datediff command | |
# $1: the command | |
# $2: the short name of the command | |
# $3: the command to eval when it's in cd | |
# $COMMAND_CD_PATH: the path to save the cd time, default is $HOME/.command_cd_<short name or full command> | |
# $COMMAND_CD_LENGTH: cd length in nanoseconds, default is one hour | |
command_cd() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls *.in | sort -V | awk '{ | |
begin = match($0, /-[0-9]*/) + 1; | |
if (substr($0, begin, RLENGTH - 1) == "1") { | |
if (subtask > 0) print "subtask_end_" subtask " " NR - 1 ; | |
++subtask; | |
if (!getline line) print "subtask_end_" subtask " " NR; | |
} | |
}' | |
ls *.in | sort -V | awk '{tmp = $0; gsub(/[0-9]*-[0-9]*/, NR); system("cp " tmp " " $0);}' | |
ls *.out | sort -V | awk '{tmp = $0; gsub(/[0-9]*-[0-9]*/, NR); system("cp " tmp " " $0);}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
var answer = []; | |
var cur = 0; | |
var lastX = -1; | |
var lastY = -1; | |
var answerStr = ''; | |
function drawBlock(x, y) { |