Skip to content

Instantly share code, notes, and snippets.

Avatar
😵
very busy recently

Lingzheng.yh kfitfk

😵
very busy recently
View GitHub Profile
@kfitfk
kfitfk / subset_font_pyftsubset
Created Mar 1, 2021
Use pyftsubset to subset a font file and convert to web font format
View subset_font_pyftsubset
pyftsubset [input_file.ttf] --output-file="[output_file.woff2]" --flavor=woff2 --layout-features='*' --name-IDs='*' --name-legacy --name-languages='*' --text-file=[subset_chars.txt]
@kfitfk
kfitfk / qmelt.sh
Created Mar 13, 2020
Using MLT/qmelt
View qmelt.sh
# vb, minrate, maxrate are optional
# also there're other options, check the man page
qmelt path_to_mlt.xml -consumer avformat:output.mp4 vb=1200k minrate=500k maxrate=1900k
@kfitfk
kfitfk / canvas_to_img.js
Created Aug 26, 2019
Save canvas drawing to local image
View canvas_to_img.js
function saveCanvas(canvas) {
var image = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream'); // here is the most important part because if you dont replace you will get a DOM 18 exception.
window.location.href = image; // it will save locally
}
@kfitfk
kfitfk / img_to_base64.js
Created May 5, 2016
Convert an image to base64 encoding
View img_to_base64.js
/**
* Convert an image to a base64 encoded value
* @param {string} url - The url of the image which has correct Access-Control-Allow-Origin response header
* @param {function} callback - callback with one parameter containing the base64 encoded value
* @param {string} [outputFormat] - image/png or image/jpeg or image/webp(Chrome)
*/
function convertImgToBase64(url, callback, outputFormat){
var img = new Image()
img.crossOrigin = 'Anonymous'
img.onload = function() {
@kfitfk
kfitfk / rgb_to_lab.js
Created Mar 18, 2016
Convert RGB color to CIE LAB color
View rgb_to_lab.js
function rgbToXyz(r, g, b) {
r /= 255
g /= 255
b /= 255
if (r > 0.04045) r = Math.pow(((r + 0.055) / 1.055), 2.4)
else r = r / 12.92
if (g > 0.04045) g = Math.pow(((g + 0.055) / 1.055), 2.4)
else g = g / 12.92
@kfitfk
kfitfk / bin_cue_to_iso.md
Created Nov 9, 2015
Convert bin+cue to iso on Mac OS X
View bin_cue_to_iso.md
  1. install bchunk (use homebrew);
  2. bchunk a.bin a.cue output
@kfitfk
kfitfk / gb2312_characters.txt
Created Sep 22, 2015
The GB2312 characters.
View gb2312_characters.txt
 、。・ˉˇ¨〃々―~∥…‘’“”〔〕〈〉《》「」『』〖〗【】±×÷∶∧∨∑∏∪∩∈∷√⊥∥∠⌒⊙∫∮≡≌≈∽∝≠≮≯≤≥∞∵∴♂♀°′″℃$¤¢£‰§№☆★○●◎◇◆□■△▲※→←↑↓〓⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!"#¥%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} ̄ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюяāáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜüêㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩ─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻
@kfitfk
kfitfk / unicode_range_to_characters.js
Created Sep 15, 2015
Converts a Unicode range to the actual characters.
View unicode_range_to_characters.js
/**
* Convert a Unicode range to the actual characters.
* The Unicode range is in this form - ['U+0020', 'U+0041-005A']
* @param {array} range - An array containing strings of Unicode range.
* @returns {array} - An array containing the actual characters.
*/
function charactersFromUnicodeRange(ranges) {
var output = [];
ranges.forEach(function(range) {
@kfitfk
kfitfk / most_used_simplified_chinese_unicode_range.txt
Created Sep 15, 2015
This unicode range includes most used Chinese characters, including uppercase and lowercase letters, numerals and punctuations, and simplified Chinese Level 1 characters.
View most_used_simplified_chinese_unicode_range.txt
U+0020,U+0041-005A,U+0061-007A,U+0030-0039,U+002E,U+0020-002F,U+003A-0040,U+005B-0060,U+007B-007E,U+4E00-4E01,U+4E03,U+4E07-4E0E,U+4E10-4E11,U+4E13-4E16,U+4E18-4E1E,U+4E22,U+4E24-4E25,U+4E27-4E28,U+4E2A-4E2D,U+4E30,U+4E32,U+4E34,U+4E36,U+4E38-4E3B,U+4E3D-4E3F,U+4E43,U+4E45,U+4E47-4E49,U+4E4B-4E50,U+4E52-4E54,U+4E56,U+4E58-4E59,U+4E5C-4E61,U+4E66,U+4E69,U+4E70-4E71,U+4E73,U+4E7E,U+4E86,U+4E88-4E89,U+4E8B-4E8F,U+4E91-4E95,U+4E98,U+4E9A-4E9B,U+4E9F-4EA2,U+4EA4-4EA9,U+4EAB-4EAE,U+4EB2-4EB3,U+4EB5,U+4EBA-4EBB,U+4EBF-4EC7,U+4EC9-4ECB,U+4ECD-4ECE,U+4ED1,U+4ED3-4ED9,U+4EDD-4EDF,U+4EE1,U+4EE3-4EE5,U+4EE8,U+4EEA-4EEC,U+4EF0,U+4EF2-4EF3,U+4EF5-4EF7,U+4EFB,U+4EFD,U+4EFF,U+4F01,U+4F09-4F0A,U+4F0D-4F11,U+4F17-4F1B,U+4F1E-4F20,U+4F22,U+4F24-4F27,U+4F2A-4F2B,U+4F2F-4F30,U+4F32,U+4F34,U+4F36,U+4F38,U+4F3A,U+4F3C-4F3D,U+4F43,U+4F46,U+4F4D-4F51,U+4F53,U+4F55,U+4F57-4F60,U+4F63-4F65,U+4F67,U+4F69,U+4F6C,U+4F6F-4F70,U+4F73-4F74,U+4F76,U+4F7B-4F7C,U+4F7E-4F7F,U+4F83-4F84,U+4F88-4F89,U+4F8B,U+4F8D,U+4F8F,U+4F91,U+4F94,U+4F97,U+4F9B
@kfitfk
kfitfk / ps_save_jpeg.jsx
Created Jul 23, 2015
A Photoshop script to automate save for web as JPEG. Save the file as using jsx extenstion. Then in Photoshop go to "File-Scripts-Browse..." to load the file. This script will overwrite the existing output file if it already exists.
View ps_save_jpeg.jsx
// Utils
function trace() {
$.writeln.apply($, arguments);
}
// Construct the dialog layout
var layoutInfo = "dialog{\
text: 'Save for Web in JPEG',\
info: Panel {\
orientation: 'column',\