Skip to content

Instantly share code, notes, and snippets.

View zfkun's full-sized avatar
🎯
Focusing

zfkun zfkun

🎯
Focusing
View GitHub Profile
@zfkun
zfkun / native2ascii.js
Last active December 25, 2015 03:59
JavaScript implements for `native2ascii`
/**
* javascript implements for `native2ascii`
*
* @file native2ascii
* @author zfkun(zfkun@msn.com)
*/
/**
* pattern 1
*
@zfkun
zfkun / ascii2native.js
Last active December 25, 2015 03:59
JavaScript implements for `ascii2native`
/**
* javascript implements for `ascii2native`
*
* @file ascii2native
* @author zfkun(zfkun@msn.com)
*/
/**
* pattern 1
*
@zfkun
zfkun / audio_android.html
Last active December 25, 2015 16:08
HTML5 Audio API test for Android & IOS
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>audio test</title>
<style>
p { font-weight: bold; }
span { color: red; }
button { width: 100px; height: 30px; }
audio { display: block; margin: 5px 0; }
@zfkun
zfkun / repeat.js
Last active December 27, 2015 17:59
create a repeat string by a string.
define(function() {
/**
* create a repeat string by a string
*
* @param {string} str target string
* @param {number} count repeat count
* @return {string}
*/
function repeat( str, count ) {
#!/bin/sh
#
# path: .git/hooks/pre-commit
echo "\n\x1B[33mCommit checking ...\x1B[0m\n"
npm test
exitCode=$?
if [ $exitCode -ne 0 ]
@zfkun
zfkun / ansi_escape_code.md
Last active May 5, 2019 10:10
ANSI Escape Code

ANSI Escape Code

给终端文字加点颜色和特效 (来自 http://mozillazg.com/)

文字特效相关的字符格式是:ESC[#;#;....;#m ,其中 # 的取值见下表:

# 的值 功能 python 代码 截图
00 或 0 正常显示 '\033[00m' + 'hello' + '\033[0;39m'
@zfkun
zfkun / setCursorTo.js
Last active August 29, 2015 13:59
cursor position setting
/**
* @file 简易光标定位
* @author zfkun(zfkun@msn.com)
*/
/**
* 简易光标定位
*
* @param node {(HTMLTextAreaElement | HTMLInputElement)} `TextArea`或`Input`元素
* @param index {number=} 定位位置,不传则定位到末尾
@zfkun
zfkun / uninstall_nodejs
Created May 28, 2014 13:16
uninstall nodejs installed from pkg (Mac OSX)
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
sudo rm /usr/local/${i}
done
sudo rm -rf /usr/local/bin/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
@zfkun
zfkun / moneyFormat.js
Created May 30, 2014 05:55
number to money style
define( function ( require, exports, module ) {
/**
* 货币数字格式化
* 将数字整数部分按3位分组加逗号格式化
*
* @example
* ```javascript
* var money = 123456789.1234567;
* var moneyFormated = toMoney( money );
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≤ 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="apple-touch-icon-76x76-precomposed.png">
<!-- For iPhone with high-resolution Retina display running iOS ≤ 6: -->