// Round 1
// time: 21:26 - 21:44
// 默认最多尝试 3 次, 每次用时递减
// 缺点: 每次用时多少并不知道
// 失败: setTimeout 那里并没有 resolve, reject
function requestWithRetry(url, attempts = 3) {
const attemptsLeft = attempts - 1;
const maxDelayMS = 30000; // 30 seconds
const minDelayMS = 3000; // 3 seconds
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
# 清华大学: | |
cd "$(brew --repo)" | |
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" | |
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git | |
# 手动修改 bottles 地址: | |
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles | |
# 或: |
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
{ | |
"editor.fontFamily": "'Fira Code', Monaco, Menlo, Consolas, 'PingFang SC', 'Yahei Consolas Hybrid', 'Courier New', monospace", | |
"editor.fontLigatures": true, | |
"editor.scrollBeyondLastLine": false, | |
"terminal.integrated.fontFamily": "'MesloLGS NF', 'Fira Code',Monaco, Menlo, Consolas, 'PingFang SC', 'Yahei Consolas Hybrid', 'Courier New', monospace", | |
"terminal.integrated.fontSize": 15, | |
"emmet.includeLanguages": { | |
"smarty": "html" | |
}, | |
"emmet.triggerExpansionOnTab": true, |
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
import * as Cookies from 'js-cookie' | |
import { fromEvent } from 'rxjs' | |
import { buffer, debounceTime, filter, map } from 'rxjs/operators' | |
// debug 模式配置 | |
// 连续 5 次快速点击, 切换 debug 模式 | |
const FAST_CLICK_COUNT = 5 | |
const DEBUG_COOKIE_KEY = 'debug' | |
const clickStream = fromEvent(document, 'click') |
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
return $.ajax({ | |
url: 'https://another-domain.com/api/user/', | |
type: 'GET', | |
dataType: 'json', | |
xhrFields: { | |
withCredentials: true, // this line is required | |
}, | |
}); |
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
# cut from the beginning of the video to the beginning of the unwanted part | |
ffmpeg.exe -ss 00:00:00.000 -t 00:19:00.000 -i original.mp4 -c:v copy -c:a copy part1.mp4 | |
# cut from the ending of the unwanted part to the end of the video | |
ffmpeg.exe -ss 00:20:28.000 -t 01:26:25.000 -i original.mp4 -c:v copy -c:a copy part2.mp4 | |
# create a list file | |
touch list.txt | |
echo file part1.mp4 > list.txt | |
echo file part2.mp4 >> list.txt |
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
# I know you've got stuck for too long ^_^Y | |
# Locale is not configured correct. I don't know what broke that. Maybe time did. | |
# I fixed it on my ubuntu 14 & 16 servers. | |
# Follow the steps below or run this script on your machine. | |
# step 1 | |
# ensure this line in `/etc/default/locale` file and `/etc/environment` file | |
# LANG="en_US.UTF-8" | |
sudo echo '\nLANG="en_US.UTF-8"' >> /etc/default/locale && /etc/environment |
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 | |
if ethtool wlp2s0 | grep -q "Link detected: no"; then | |
echo connecting | |
echo $(nmcli d connect wlp2s0) | |
else | |
echo connected | |
fi |
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
// ref: https://codepen.io/shrekuu/pen/zYoQoBd?editors=1010 | |
var container; | |
var camera, scene, renderer; | |
// Sphere 1 | |
var sphereGeometry1, sphereMaterial1, sphereMesh1; | |
// Sphere 2 | |
var sphereGeometry2, sphereMaterial2, sphereMesh2; |
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 | |
# ref: https://askubuntu.com/a/421751/596437 | |
wlan=`/sbin/ifconfig wlp2s0 | grep inet\ addr | wc -l` | |
if [ $wlan -eq 0 ]; then | |
/sbin/ifconfig wlp2s0 down && /sbin/ifconfig wlp2s0 up | |
else | |
echo "interface is up" | |
fi |
NewerOlder