Skip to content

Instantly share code, notes, and snippets.

View kfitfk's full-sized avatar
😇

Hao Ye kfitfk

😇
View GitHub Profile
@kfitfk
kfitfk / open_window.as
Last active August 29, 2015 14:05
Open Browser Window in ActionScript
function openWindow($url:String, $window:String = "_blank"):void {
var req:URLRequest = new URLRequest($url);
if (!ExternalInterface.available) {
navigateToURL(req, $window);
} else {
try {
var strUserAgent:String = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
if (strUserAgent.indexOf("firefox") != -1 || (strUserAgent.indexOf("msie") != -1 && uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) >= 7)) {
ExternalInterface.call("function(url, target){window.open(url, target);return;}", req.url, $window);
@kfitfk
kfitfk / gist:d71409a715b880551470
Created April 16, 2015 09:25
Extract a .tar.gz file
tar -xvzf community_images.tar.gz
To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things.
f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.
z: tells tar to decompress the archive using gzip
x: tar can collect files or extract them. x does the latter.
v: makes tar talk a lot. Verbose output shows you all the files being extracted.
mxmlc ./YOUR_MAIN_CLASS.as -l ./YOUR_MAIN_SWC.swc -static-link-runtime-shared-libraries=true -managers=flash.fonts.AFEFontManager -default-size=550,400 -debug=false -o OUTPUT_FILE_NAME.swf
@kfitfk
kfitfk / flex_embed_unicode_ranges.js
Created May 8, 2015 09:34
Generate the unicodeRanges property for Flex font embed
function flexEmbedCharUnicode(charCode) {
var leadingZeros = '';
for (var i = 0; i < 4 - charCode.length; i++) {
leadingZeros += '0';
}
return 'U+' + leadingZeros + charCode;
}
function flexEmbedUnicodeRanges(string) {
var unicodeRange = []
@kfitfk
kfitfk / most_used_simplified_chinese_unicode_range.txt
Created September 15, 2015 09:27
This unicode range includes most used Chinese characters, including uppercase and lowercase letters, numerals and punctuations, and simplified Chinese Level 1 characters.
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 / unicode_range_to_characters.js
Created September 15, 2015 10:20
Converts a Unicode range to the actual characters.
/**
* 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 / gb2312_characters.txt
Created September 22, 2015 01:49
The GB2312 characters.
 、。・ˉˇ¨〃々―~∥…‘’“”〔〕〈〉《》「」『』〖〗【】±×÷∶∧∨∑∏∪∩∈∷√⊥∥∠⌒⊙∫∮≡≌≈∽∝≠≮≯≤≥∞∵∴♂♀°′″℃$¤¢£‰§№☆★○●◎◇◆□■△▲※→←↑↓〓⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!"#¥%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} ̄ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюяāáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜüêㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩ─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻
@kfitfk
kfitfk / bin_cue_to_iso.md
Created November 9, 2015 05:23
Convert bin+cue to iso on Mac OS X
  1. install bchunk (use homebrew);
  2. bchunk a.bin a.cue output
@kfitfk
kfitfk / rm_keys_redis.sh
Created November 28, 2013 03:13
Remove keys matching a pattern with redis
redis-cli KEYS "prefix:*" | xargs redis-cli DEL
@kfitfk
kfitfk / empty_mysql_table.sql
Created November 28, 2013 03:16
Empty a mysql table
CREATE TABLE cloned LIKE the_table_to_drop;
RENAME TABLE the_table_to_drop TO drop_me, cloned TO the_table_to_drop;
DROP TABLE drop_me;