10 09/2014

奇技淫巧小结

最后更新: Wed Sep 10 2014 12:35:31 GMT+0800

stringify 带格式输出

JSON.stringify(jsObj, null, "\t"); // stringify with tabs inserted at each level
JSON.stringify(jsObj, null, 4);    // stringify with 4 spaces at each level

中间的 nul 是 replacer 对数据进行处理的自定义函数

JSON.parse

JSON.parse(abc) abc 必须是严格的 json,即 属性和数值 都必须 双引号 包裹

webkit(chrome) textrea resize

可用值:none both horizontal vertical initial inherit





css validate

:required {border-color:#333;}
:invalid  {border-color:#c00;} /*required 为空也被视为 invalid*/

用变量构造 正则匹配

function escapeRegExp(string){
    return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
var regex = new RegExp('[' + escapeRegExp(separator) + '\\s]', 'g');

html5 datetime-local vs. datetime

chrome 不认识 datetime 二者区别在于: datetime-local 没有时区

new Date().toISOString() 返回

2014-03-10T04:33:42.465Z

var_dump 和 print_r 区别

The var_dump function displays structured information about variables/expressions including its type and value. Arrays are explored recursively with values indented to show structure. It also shows which array values and object properties are references.

The print_r() displays information about a variable in a way that’s readable by humans. array values will be presented in a format that shows keys and elements. Similar notation is used for objects.

Example:

$obj = (object) array(‘qualitypoint’, ‘technologies’, ‘India’);
var_dump($obj) will display below output in the screen.

object(stdClass)#1 (3) {
[0]=> string(12) “qualitypoint”
[1]=> string(12) “technologies”
[2]=> string(5) “India”
}
And, print_r($obj) will display below output in the screen.

stdClass Object (
[0] => qualitypoint
[1] => technologies
[2] => India
)

web app icon for iphone

ios icon ios7 标准:

60x60 iphone/ipad
76x76 iPod
120x120 iPhone / iPod Retina
152x152 iPad Retina

https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

http://goodui.org/

good ui