kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

JS 保持屏幕常亮

https://blog.csdn.net/GeniusCyberpunk/article/details/106082103

1
2
3
4
5
6
7
<script src='/js/NoSleep.js' type='text/javascript'></script>

<script>
var noSleep = new NoSleep();
noSleep.enable();
// alert('eeee');
</script>

https://juejin.cn/post/7229176086147825722

1
2
3
4
5
6
7
8
9
10
11
12
<script>
let wakeLock = null;
async function requestScreenWakeLock() {
	try {
		wakeLock = await navigator.wakeLock.request('screen');
		// console.log('Wake Lock activated, screen will stay awake.');
	} catch (err) {
		alert(err);
	}
}
requestScreenWakeLock();
</script>

JS 获取当前的日期和时间

https://www.jyshare.com/codedemo/7672/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
var today = new Date();

//日期
var DD = String(today.getDate()).padStart(2, '0');    // 获取日
var MM = String(today.getMonth() + 1).padStart(2, '0');   // 获取月份,1 月为 0
var yyyy = today.getFullYear();               // 获取年

// 时间
hh =  String(today.getHours()).padStart(2, '0');  // 获取当前小时数(0-23)
mm = String(today.getMinutes()).padStart(2, '0'); // 获取当前分钟数(0-59)
ss = String(today.getSeconds()).padStart(2, '0'); // 获取当前秒数(0-59)

today = yyyy + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss;
document.write(today);

GPS 两点距离

https://www.cnblogs.com/thinkquan/p/3925199.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function rad($d)
{
	return $d * 3.1415926535898 / 180.0;
}

function GetDistance($lat1, $lng1, $lat2, $lng2)
{
	$EARTH_RADIUS = 6378.137;

	$radLat1 = $this->rad($lat1);
	$radLat2 = $this->rad($lat2);
	$a = $radLat1 - $radLat2;

	$b = $this->rad($lng1) - $this->rad($lng2);

	$s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)));
	$s = $s *$EARTH_RADIUS;
	$s = round($s * 1000);
	return $s;
}

GetDistance(26.000000, 118.000000, 25.000000, 117.000000);