Skip to content

Instantly share code, notes, and snippets.

View tcdw's full-sized avatar
😵
啊啊啊啊啊啊啊啊(

tcdw tcdw

😵
啊啊啊啊啊啊啊啊(
View GitHub Profile
@tcdw
tcdw / color.ts
Created February 23, 2023 17:21
依赖浏览器 API 的颜色处理函数……?
export function cssColorToRGB(color: string) {
// 在浏览器创建一个看不见的元素,把随便什么值喂给它(只要是合法的 CSS 颜色表记就行)
const el = document.createElement("div");
el.style.color = color;
// 然后再读取它就变成 rgb 或 rgba 开头的标准值了
const matchRegex = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/;
const matchResult = matchRegex.exec(el.style.color);
if (!matchResult) {
return null;
@tcdw
tcdw / getBEMClassName.ts
Last active February 23, 2023 17:18
为单一元素生成符合 BEM 规则的 CSS Class 名称
/**
* 为单一元素生成符合 BEM 规则的 CSS Class 名称
* @param block
* @param element
* @param modifiers
* @returns classes 返回的 Class 名称数组,可直接供 Vue 使用
*/
export function getBEMClassName(
block: string,
element?: string | null,
@tcdw
tcdw / window-scrollxy-polyfill.js
Created November 24, 2022 09:20
让 IE9+ 兼容 window.scrollX 和 window.scrollY,不需要改写已有代码
if (typeof window.scrollX !== "number" || typeof window.scrollY !== "number") {
Object.defineProperty(window, "scrollX", {
get() {
return window.pageXOffset;
}
});
Object.defineProperty(window, "scrollY", {
get() {
return window.pageYOffset;
}
@tcdw
tcdw / nyaacat.sh
Last active November 25, 2020 13:34
[Bash] 更新喵窝资源包并打开启动器。
#!/usr/bin/env bash
# - 更新喵窝资源包并打开启动器。
# - 需要安装 `jq` 才可以工作。
# - 官网:https://stedolan.github.io/jq/
# - 包管理器有的话就直接从包管理器装好了。如 macOS + Homebrew,即可 `brew install jq`
PACKDIR_PATH=/Applications/MultiMC.app/Contents/MacOS/instances/Fabric\ 1.16.4/.minecraft/resourcepacks
PACK_REPO=NyaaCat/resourcepack
@tcdw
tcdw / maimai_npc.md
Last active August 11, 2020 17:22
[ABANDONED] 买买镇 NPC 速查表

买买镇 NPC 速查表

VoxelMap 坐标点

name:mine,x:-118,z:112,y:82,enabled:true,red:0.7086123,green:0.47486883,blue:0.91565824,suffix:,world:act2,dimensions:overworld#
name:back home,x:-29,z:55,y:83,enabled:true,red:0.536214,green:0.837014,blue:0.052556634,suffix:,world:act2,dimensions:overworld#
name:room 1,x:-44,z:79,y:82,enabled:true,red:0.011502206,green:0.40554154,blue:0.53481793,suffix:,world:act2,dimensions:overworld#
name:room 2,x:-67,z:82,y:83,enabled:true,red:0.9271869,green:0.95799035,blue:0.21456033,suffix:,world:act2,dimensions:overworld#
name:room 3,x:-87,z:70,y:84,enabled:true,red:0.79276526,green:0.8595252,blue:0.8633945,suffix:,world:act2,dimensions:overworld#

目录结构

  • dist 编译好的 CSS 与 JS 存放的位置
  • src 没有编译的源文件存放位置
  • static 一些不需要编译的资源文件
  • include 模板中嵌入的片段,例如 header 与 footer
  • cdn CDN 配置
  • i18n 主题语言文件
  • index.html 首页(列表页)
  • post.html 文章页
@tcdw
tcdw / snow.js
Created June 6, 2020 16:32
Classic Web Snow Rebirth!!!
// This JavaScript code can be freely redistributed
// as long as this copyright notice is keept unchanged.
// This code is used on AS-IS basis and
// you use it on your own risk. Author of this code
// is not responsible for any damage that this
// code may make.
//
// JS Snow v0.3
// finished on 11-10-1999 23:04 in Zagreb, Croatia.
// modified on 06-12-2005 11:20 in Zagreb, Croatia.
@tcdw
tcdw / lingoys_metro.md
Last active February 19, 2020 14:15
霖菓村地铁施工方案

施工进度管理

戳这里。此电子表格包含:

  • 总览:总体施工进度记录。
  • 隧道挖掘承包情况:小伙伴们的帮忙会被记录在此,届时会以此结算节操。

隧道建设方案

首先,按照以下方法挖掘出需要的空间:

@tcdw
tcdw / perc_howto.md
Last active March 6, 2021 12:20
An In-depth Look of Vanilla Percussion (@21 - @29) on Addmusic (WIP!)

SMWC Version

Yes, this tutorial is specified for vanilla percussions in Addmusic, since I see there are lots people don't really understand about how that trappy stuff works.

So, what @21 - @29 does?

When porters talking about percussion notes feature from other sound engine (eg. Square Soft and Hudson Soft's one), N-SPC does have the same feature, including SMW's. It's pretty limited, since a percussion note in N-SPC is only tied with corresponding instrument. And for whatever reasons, the original Java Addmusic's author decided to handle the percussion in a really confusing way. For backward compatibility, all Addmusics have to do that in the same confusing way.

The reason that @2X instruments stand out from other vanilla instruments is because how Addmusic handle it. @10, @12, etc. will not be covered here, since they are just standard instruments technologically.

@tcdw
tcdw / read_song.js
Last active April 2, 2019 18:55
Dump song directly from Classic Road II
#!/usr/bin/env node
/*
Classic Road II music ripper
by tcdw
Usage:
1. Get the Classic Road II ROM
2. Get your template SPC file:
2.1. Dump a SPC via your SNES emulator from the game, and hex edit x1F4 to 0x00