Skip to content

Instantly share code, notes, and snippets.

View kamikat's full-sized avatar

Kamikat kamikat

View GitHub Profile
@kamikat
kamikat / sshfs-1
Last active March 26, 2018 06:13
Blocking version of sshfs.
#!/bin/bash
DATA_PATH=${DATA_PATH:-$2}
if [ -z "$DATA_PATH" ]; then
sshfs -h
exit 1
fi
LOCK_PATH=$DATA_PATH/.lock-$RANDOM
@kamikat
kamikat / telegram.scpt
Created October 3, 2017 16:56
AppleScript to restart Telegram Desktop.app
if application "Telegram Desktop" is running then
tell application "Telegram Desktop"
quit
end tell
delay 3
tell application "Telegram Desktop"
launch
end tell
end if
@kamikat
kamikat / convert.js
Created September 5, 2017 02:13
Replace immediate number in decompiled APK source file to constant variable reference.
#!/usr/bin/env node
let fs = require('fs')
let { argv } = require('process')
let res_map = fs.readFileSync('R.map').toString().split('\n').slice(0,-1).map(v => v.slice(0,-1).split(' = ')).reduce((dict, v) => {
dict[v[1]] = v[0]
return dict
}, {})
@kamikat
kamikat / homebrew.mxcl.aria2.plist
Created May 22, 2017 15:51
Launchd definition for aria2 (~/Library/LaunchAgents/homebrew.mxcl.aria2.plist)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.aria2</string>
@kamikat
kamikat / aria2.conf
Last active May 23, 2017 13:03
A gentle start to aria2.conf file.
###########
# General #
###########
dir=${HOME}/Downloads
# allow-overwrite=true
# disable-ipv6=true
# quiet=true
@kamikat
kamikat / fid2url.py
Last active April 18, 2017 11:05
从 fid 计算网易云音乐文件的 CDN 地址
#!/usr/bin/env python2
import argparse
import md5
from base64 import urlsafe_b64encode as b64enc
parser = argparse.ArgumentParser(description='convert fid to audio file url')
parser.add_argument('fid', action='store', help='fid')
args = parser.parse_args()
@kamikat
kamikat / get-application-icon.sh
Created February 14, 2017 08:52
Extracting application icon from APK file.
#!/bin/sh
GENERATOR="/^application-icon-(\\d+):(.*)/ && print \"unzip -o $1 \$2 && mv \$2 $(basename $1 .apk)-\$1.png\n\""
aapt d --values badging $1 | perl -n -e"$GENERATOR" | sh
rm -rf res/
package moe.banana.jsonapi2;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.ParameterizedType;
@kamikat
kamikat / esp8266-prelude.py
Created December 22, 2016 06:32
A prelude script to easy access filesystem & network functionalities for MicroPython on ESP8266.
# utility
logfile = None
def debug(*objects):
print(*objects)
if logfile:
print(*objects, file=logfile, flush=True)
def format_hex(bs, delim=''):
@kamikat
kamikat / typography.scss
Created December 1, 2016 07:46
SCSS font configuration using serif CJK fonts
@font-face {
font-family: "Kagami Serif";
src: local("Liberation Serif"),
local("Times New Roman"),
local("Times");
}
@font-face {
font-family: "Kagami Songti SC";
src: local("Songti SC Regular"), local(STSongti-SC-Regular), // OS X 10.8