Skip to content

Instantly share code, notes, and snippets.

@othercat
othercat / gist:6a3913981a98e09fa3d9846c830a7544
Created March 11, 2026 16:25
清理仙剑1 MAP.mkf 末尾空 chunk 并对齐 GOP.mkf
#!/usr/bin/env python3
"""
fix_mkf_pair.py - 清理 MAP.mkf 末尾空 chunk 并对齐 GOP.mkf
功能:
1. 检测 MAP.mkf 末尾连续的空 chunk(大小为0),将其清除
2. 对齐 GOP.mkf 的 chunk 数量与清理后的 MAP.mkf 一致
- GOP 不足则追加空 chunk
- GOP 末尾多余的空 chunk 则截掉
@othercat
othercat / gist:d3a4e83bc3fe620046d36b0cdd21c2ce
Created March 11, 2026 15:32
修复仙剑1资源 GOP.mkf 使其 chunk 数量与 MAP.mkf 一致
#!/usr/bin/env python3
"""
fix_gop_mkf.py - 修复 GOP.mkf 使其 chunk 数量与 MAP.mkf 一致
背景:
MAP.mkf 和 GOP.mkf 通过相同的 chunk 编号(iMapNum)一一对应。
PAL_LoadMap() 中会校验 iMapNum < chunkCount(MAP) 且 iMapNum < chunkCount(GOP)。
如果 MAP.mkf 已被修复添加了哨兵空 chunk,而 GOP.mkf 没有,
则两者 chunk 数量不一致,会导致最后一个有效地图无法加载。
@othercat
othercat / Clash Yaml samples.yaml
Last active February 21, 2023 10:37
Clash Yaml samples
proxy-groups:
- { name: AppleMusic, type: select, proxies: [DIRECT, 通用代理,香港, 台湾, 日本, 新加坡, 美国, 德国, 其他] }
- { name: AppleNews+, type: select, proxies: [DIRECT, 通用代理,香港, 台湾, 日本, 新加坡, 美国, 德国, 其他] }
- { name: AppleTV+, type: select, proxies: [DIRECT, 通用代理,香港, 台湾, 日本, 新加坡, 美国, 德国, 其他] }
rules:
# Apple Music TV
- 'DOMAIN,tv.applemusic.com,AppleMusic'
- 'DOMAIN,music.apple.com,AppleMusic'
@othercat
othercat / ConvertAC3MKVtoAACMP4.sh
Last active February 15, 2023 01:54
Convert AC3 MKV to AAC MP4
#! /bin/bash
pathname=$1
filename=$(basename $pathname .mkv)
dirname=$(dirname $pathname)
h264videopath="$dirname/../h264video/$filename.h264"
aacaudiopath="$dirname/../aacaudio/$filename.m4a"
aacvideopath="$dirname/../aacvideo/$filename.mp4"
ac3videopath="$dirname/../ac3video/$filename.mp4"
@othercat
othercat / opensafariindifferentspace
Last active August 29, 2015 14:10
Create a new window of Safari when staying in a new Space
set found to 0
set resolution_wide to 1440
tell application "System Events"
repeat with i from 1 to (count of window of process "Safari")
set bnds to bounds of window i of application "Safari"
set wide to item 3 of bnds
if wide < resolution_wide then
set found to 1
end if
end repeat
@othercat
othercat / current_time
Created August 5, 2013 05:41
New method to get work in Nanoseconds.
#ifndef NEW_METHOD
//old method
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
@othercat
othercat / tweet Safari URL using apple script
Created July 25, 2013 14:33
tweet Safari URL using Apple Script for @yamibo
tell application "Safari"
set theURL to URL of front document
set theTitle to name of front document
-- set the clipboard to theTitle & return & theURL as string
end tell
-- change the status message to your liking here:
set tweet to "test Reading: " & theURL & space & theTitle & " cc @yamibo "
@othercat
othercat / regx_segment
Last active December 19, 2015 01:29
匹配"20130620_中文_suc.txt"引号内的内容,月日会变化,但是正则表达式里不能包括中文和星号。 for @kDolphin
^([2-9]\d{3}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|(([2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00))0229)_[\u4e00-\u9fa5]+_[a-zA-Z0-9_]+.txt$
@othercat
othercat / gist:4479978
Created January 8, 2013 00:37
toggle the status item in the menubar on and off
-(void)awakeFromNib{
//statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
//[statusItem setMenu:statusMenu];
//[statusItem setTitle:@"Status"];
//[statusItem setHighlightMode:YES];
//[[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
{
BOOL checked = NO;
@othercat
othercat / private.xml
Created October 31, 2012 03:45
Using KeyRemap4Macbook to remap J,K,G,Shift+G in Preview.app
<?xml version="1.0"?>
<root>
<item>
<name>Enable at only Preview</name>
<item>
<name>Use J and K to Up and Down</name>
<identifier>remap.app_preview_jk2UpDown</identifier>
<only>PREVIEW</only>
<autogen>--KeyToKey-- KeyCode::J, KeyCode::CURSOR_DOWN</autogen>
<autogen>--KeyToKey-- KeyCode::K, KeyCode::CURSOR_UP</autogen>