Skip to content

Instantly share code, notes, and snippets.

/**
* 把数组填充到字符串内
* @param {Array} array
* @param {Function} fn
* @return {String}
*/
function each(array, fn){
var s = '', l = array.length;
for (var i = 0; i < l; i++) {
if (typeof array[i] != 'undefined'){

前端排错表

首先,是否有拼写错误?

JSP 模板

HTML 靠前的位置使用 script 标签初始化 JS 变量,不要使用 <input type="hidden" name="id" id="id" value="${id}" />

@yulanggong
yulanggong / java_lessons.md
Last active August 29, 2015 14:26
JAVA 踩坑记录

IDEA

Make 不编译 java 文件

File -> Project Structure -> Modules -> 选择一个主项目 -> Paths: 这里配置编译输出路径

项目配置读取错误

复制 src 目录下的配置文件到输出路径下,[TODO] 编译的时候为啥没有复制配置文件呢?

@yulanggong
yulanggong / userAgents.md
Last active August 29, 2015 14:26
userAgent 收集

#iOS

QQ

Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12F70 QQ/5.7.0.469 NetType/WIFI Mem/673

WeChat

Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12F70 MicroMessenger/6.2.3 NetType/WIFI Language/zh_CN

@yulanggong
yulanggong / lessc_watch.js
Created March 15, 2012 02:36
Less compiler with --watch and --smartpath support
/*
* Less compiler with --watch and --smartpath support
*
* Based on lessc of less 1.3.0
*
* Added options:
*
* -w, --watch Watch files (include @import files) for changes and re-compile
*
* -m, --smartpath output css file like this:
@yulanggong
yulanggong / less2stylus.coffee
Created March 15, 2012 02:17 — forked from lancejpollard/less2stylus.coffee
Convert LESS to Stylus for Twitter Bootstrap
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ \n]+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
.replace(/\;\ *?$/gm, "") # remove semicolons
.replace(/@(\w+):(\ *)\ /g, (_, $1, $2) -> # replace @variable: with $variable =
"$#{$1}#{$2} = "
@yulanggong
yulanggong / gist:2224161
Created March 28, 2012 06:15 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@yulanggong
yulanggong / critique.md
Created April 5, 2012 03:53 — forked from Raynos/critique.md
jQuery library critique

jQuery

Related: [Why you don't need jQuery as an abstraction][2]

$ itself is a god object. Everything goes on it. The standard plugin / extension architecture that is recommended is to just bolt more methods on $ itself!

Surely this is bad. An example would be how we have both $.load which is overloaded to do completely different things. If they were on two separate sensibly named objects $Container.load and $EventTarget.load. Personally I would deprecate the latter in favour of .on('load'

The animation should be it's own little modular thing, not bolted onto $. Ajax should be it's own little modular thing, not bolted onto $

@yulanggong
yulanggong / deepRecursionCallback.js
Created September 28, 2012 07:23
deepRecursionCallback
var stackSize = 0;
function foo(a, stackSize){
stackSize ++;
bar();
if (!a.length) return;
if (stackSize > 1000) {
@yulanggong
yulanggong / jsStyle.js
Created September 29, 2012 03:28
jsStyle
//缩进两个空格
var a = 1
, b = 2
, c = 3
, d = {
e: 4
, f: 5
, g: 6
}
, h = [