Skip to content

Instantly share code, notes, and snippets.

@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>