- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function md5_auth() { | |
$current_time = time(); | |
$hash_str = join("", array(MD5_SALT_KEY, $current_time)); | |
return array( | |
'current_time' => $current_time, | |
'token' => base64_encode(md5($hash_str)), | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.opacity (@opacity) { | |
@opacityPercentage: @opacity * 100; | |
opacity: @opacity; | |
-ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=(@{opacityPercentage}))"; | |
filter: ~"alpha(opacity = (@{opacityPercentage}))"; | |
} | |
.border-radius(@radius) { | |
border-radius: @radius; | |
-moz-border-radius: @radius; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"curly": true, | |
"camelcase": true, | |
"undef": true, | |
"unused": true, | |
"eqeqeq": true, | |
"freeze": true, | |
"immed": true, | |
"indent": 4, | |
"latedef": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utils = require('utils'); | |
var casper = require('casper').create({ | |
verbose: true, | |
logLevel: 'error', | |
pageSettings: { | |
loadImages: false, | |
loadPlugins: false, | |
userAgent: 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36' | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Tree Node</title> | |
</head> | |
<body> | |
<script src="javascript/vendor/jquery-1.7.2.min.js"></script> | |
<script src="javascript/vendor/mustache-0.7.2.js"></script> | |
<script src="javascript/vendor/underscore-min.js"></script> | |
<style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values | |
getParameterByName: function(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
results = regex.exec(location.search); | |
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
use node fibonacci num in terminal to get fibonacci list element | |
*/ | |
var fibonacci1 = function(n) { | |
if (n < 1) { | |
return 0; | |
} else if (n === 1 || n ===2) { | |
return 1; | |
} else if (n > 2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import 'https://github.com/necolas/normalize.css/blob/master/normalize.css' | |
/** | |
* For modern browsers | |
* 1. The space content is one way to avoid an Opera bug when the | |
* contenteditable attribute is included anywhere else in the document. | |
* Otherwise it causes space to appear at the top and bottom of elements | |
* that are clearfixed. | |
* 2. The use of `table` rather than `block` is only necessary if using | |
* `:before` to contain the top-margins of child elements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encodeToGb2312(str){ | |
var strOut=""; | |
for(var i = 0; i < str.length; i++){ | |
var c = str.charAt(i); | |
var code = str.charCodeAt(i); | |
if(c==" ") strOut +="+"; | |
else if(code >= 19968 && code <= 40869){ | |
index = code - 19968; | |
strOut += "%" + z.substr(index*4,2) + "%" + z.substr(index*4+2,2); | |
} |
NewerOlder