Skip to content

Instantly share code, notes, and snippets.

@LittleSaya
LittleSaya / backup.cmd
Created February 1, 2024 14:38
Palworld dedicated server save backup and daemon script
@REM PalServer 存档自动备份脚本
@REM Auther: LittleSaya
@echo off
setlocal EnableDelayedExpansion
title Palserver Backup Script
@REM 服务器路径(常量)
set __PALSERVER_DIR__=D:\Program Files (x86)\Steam\steamapps\common\PalServer
@LittleSaya
LittleSaya / waitRef.ts
Created September 14, 2023 10:50
vue 3.0 wait ref
import { Ref, watch } from 'vue';
const waitRefPredicateNonNullable = <T>(r: Ref<T>) => r.value !== null && r.value !== undefined;
/**
* 等待一个 ref 的值变为指定值
* @param r
* @param predicate 判断 ref 值是否符合条件的函数
*/
export function waitRef<T>(r: Ref<T>, predicate: (r: Ref<T>) => boolean): Promise<Ref<T>> {
@LittleSaya
LittleSaya / events.js
Created September 11, 2023 02:14
keep-alive-2
import Vue from 'vue'
const eventBus = new Vue();
export default eventBus;
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONIN
@LittleSaya
LittleSaya / base64ArrayBuffer.js
Created October 19, 2022 03:34 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: