Skip to content

Instantly share code, notes, and snippets.

View Cyang39's full-sized avatar

Cyang39 Cyang39

View GitHub Profile
@Cyang39
Cyang39 / alist-upload.md
Created September 8, 2024 02:58
curl 上传 alist 的 bash 脚本

参考这个分享的curl上传方法编写的脚本,目的是简化 token 获取到上传文件的流程。

个人用在定时文件备份中。

#!/bin/bash

# 检查参数数量
if [ $# -ne 6 ]; then
    echo "Usage: $0 --username <username> --password <password> <local-file> <alist-url>"
@Cyang39
Cyang39 / readme.md
Last active November 17, 2024 09:20
Termux PalWorld Server (Run PalWorld Server on android and no root required)

Run PalWorld Server on Android

Step.1 Install FEXDroid

gametra4u/FEXDroid

curl -o install https://raw.githubusercontent.com/gamextra4u/FEXDroid/main/install && chmod +x install && ./install

When login into proot, use ./rootfs to download rootfs for FEX.

@Cyang39
Cyang39 / saveinnotion.js
Created October 15, 2023 04:32
Save current page's url in notion
javascript:(async function() {
const token = "<your token>";
const database = "<your database>";
const url = 'https://corsproxy.io/?https://api.notion.com/v1/pages';
const options = {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'content-type': 'application/json',
@Cyang39
Cyang39 / xorcal
Created September 26, 2023 06:57
xorcal
function calculateXOR(str) {
let xorValue = 0;
for (let i = 0; i < str.length; i += 2) {
const hex = str.substr(i, 2);
const decimal = parseInt(hex, 16);
xorValue ^= decimal;
}
const xorHex = xorValue.toString(16).toUpperCase().padStart(2, '0');
return xorHex;
}
@Cyang39
Cyang39 / print_hex.c
Created September 21, 2023 03:42
hex print
void print_hex(const unsigned char *buf, size_t len) {
for (size_t i = 0; i < len; i++) {
printf("%02x ", buf[i]);
}
printf("\n");
}
@Cyang39
Cyang39 / Mount Mtd FS
Created September 13, 2023 02:57 — forked from alangregory/Mount Mtd FS
How to mount ubifs image in Linux.
# $UBIFS is ubifs image file
# make sure $IMAGE is a ubifs image file
blkid $(IMAGE)
$(IMAGE): ... TYPE="ubifs"
# size of created mtd is 256.0 MiB
modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x90 fourth_id_byte=0x95
flash_erase /dev/mtd0 0 0
ubiformat /dev/mtd0
modprobe ubi
@Cyang39
Cyang39 / gist:d83535b4674af732c1b821322836341c
Created September 13, 2023 02:52 — forked from naodesu/gist:10620506
How to mount ubifs image in Linux.
# $UBIFS is ubifs image file
# make sure $IMAGE is a ubifs image file
blkid $(IMAGE)
$(IMAGE): ... TYPE="ubifs"
# size of created mtd is 256.0 MiB
modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x90 fourth_id_byte=0x95
flash_erase /dev/mtd0 0 0
ubiformat /dev/mtd0 -s 2048 -O 2048
modprobe ubi
@Cyang39
Cyang39 / .gitignore
Last active September 13, 2023 01:59
TL-Configs
.a
.cache
.d
.dll
.o
.so
build
@Cyang39
Cyang39 / lodash-ejs.js
Last active April 21, 2020 07:13
Use loadsh _.template() instead of using ejs template engine.
const _ = require("lodash")
const fs = require("fs")
const map = {}
function readTemplate(path) {
if (!map[path]) {
const str = _(fs.readFileSync(path, "utf-8"))
.replace(/<%-/g, "TEMP<%-TEMP")
.replace(/<%=/g, "<%-")
.replace(/TEMP<%-TEMP/g, "<%=")
@Cyang39
Cyang39 / statdata.s
Last active March 2, 2018 21:45
汇编语言里的静态数据
# instruction name's sufiix mans data size
# q = 64-bits
# l = 32-bits
# w = 16-bits
# b = 8-bits
# row started with dot is a directive row
.data
x: .quad 0
y: .word 0
z: .double 123.125