Skip to content

Instantly share code, notes, and snippets.

View Subilan's full-sized avatar
😇
去他妈的

su Subilan

😇
去他妈的
View GitHub Profile
@Subilan
Subilan / flac2alac
Created February 23, 2024 16:42 — forked from mlen/flac2alac
FLAC to ALAC converter. Requires Mac OS X and `flac` binary installed (ie. via Homebrew: `brew install flac`).
#!/usr/bin/env bash
set -e
convert_to_alac() {
flac="$1"
aiff="${flac%.*}.aiff"
alac="${flac%.*}.m4a"
flac -s -d --force-aiff-format -o "$aiff" "$flac"
afconvert -f m4af -d alac "$aiff" "$alac"
@Subilan
Subilan / SrtToJson.js
Created June 20, 2021 16:39
change srt subtitle data to json using javascript
// change minute time with milisecond to seconds
// e.g. 02:04:33,229
function toSeconds(input) {
let a = input.split(',');
let x = a[0].split(':').reverse().reduce((prev, curr, i) => prev + curr*Math.pow(60, i), 0);
let y = a[1] / 1000
return x + y;
}
function SrtToJson(srt) {
############################################################
# +------------------------------------------------------+ #
# | Notes | #
# +------------------------------------------------------+ #
############################################################
# If you want to use special characters in this document, such as accented letters, you MUST save the file as UTF-8, not ANSI.
# If you receive an error when Essentials loads, ensure that:
# - No tabs are present: YAML only allows spaces
# - Indents are correct: YAML hierarchy is based entirely on indentation
[20:02:12] [Server thread/INFO]: Starting minecraft server version 1.15.2
[20:02:12] [Server thread/INFO]: Loading properties
[20:02:13] [Server thread/INFO]: This server is running Tuinity version git-Tuinity-"ab11927" (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
[20:02:14] [Server thread/INFO]: Using 4 threads for Netty based IO
[20:02:14] [Server thread/INFO]: Server Ping Player Sample Count: 12
[20:02:14] [Server thread/INFO]: Debug logging is disabled
[20:02:14] [Server thread/INFO]: Default game type: SURVIVAL
[20:02:14] [Server thread/INFO]: Generating keypair
[20:02:14] [Server thread/INFO]: Starting Minecraft server on *:10122
[20:02:14] [Server thread/INFO]: Using default channel type
@Subilan
Subilan / SortByDate.js
Created November 15, 2019 16:28
依据日期先后顺序排序
let array = [{id: 2, date: "2019/1/28"}, {id: 3, date: "2019/1/1"}, {id: 1, date: "2019/7/19"}];
array.sort(function(a,b){
return new Date(b.date) - new Date(a.date);
});
// Output
// [{id: 1, date: "2019/7/19"}, {id: 2, date: "2019/1/28"}, {id: 3, date: "2019/1/1"}];
@Subilan
Subilan / GetIP.sh
Created August 13, 2019 08:02
迅速获得当前服务器公网 IP
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
@Subilan
Subilan / visible_area_optional.ts
Last active March 31, 2020 13:52
判断一个元素在垂直方向而言,是否在可视范围内(完全在 / 不完全在 可选)
/**
* 原自 https://gist.github.com/simplelife7/5954021 评论区
* 由于使用了 TypeScript 才有的类型注释,这些代码不能直接复制到 JS 中运行。
*/
/**
*
* @param {string} id 元素的 id(不包含 # 号)
* @param {boolean} full 选择是否要求元素全体在可视范围内。
* 当 full 参数为 true 时,只有当该元素所有部分都在可视范围内,才会返回 true。
@Subilan
Subilan / RangeRandomInt.js
Created June 5, 2019 15:06
JavaScript 范围随机数生成
const randomInt = (min, max) => Math.floor(Math.random() * (max - min) + min);