This file contains hidden or 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 debugAccess(obj, prop, debugGet){ | |
var origValue = obj[prop]; | |
Object.defineProperty(obj, prop, { | |
get: function () { | |
if ( debugGet ) | |
debugger; | |
return origValue; | |
}, |
This file contains hidden or 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.prototype.bind | |
*/ | |
if (!isFunc(Function.prototype.bind)){ | |
Function.prototype.bind = function(thisArg){ | |
if(!isFunc(this)){ | |
throw new TypeError("Bind must be called on a function") | |
} | |
var slice = [].slice, |
This file contains hidden or 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
/** | |
* Object.create | |
* from : http://javascript.crockford.com/prototypal.html | |
*/ | |
if (!isFunc(Object.create)){ | |
Object.create = function(proto){ | |
function F(){} | |
F.prototype = proto; | |
return new F(); | |
} |
This file contains hidden or 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
/** | |
* Math.guid | |
* from : http://www.broofa.com/2008/09/javascript-uuid-function/ | |
*/ | |
Math.guid = function(){ | |
return 'xxxxxxxx-xxxx-4xxx-yxxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c){ | |
var r = Math.random() * 16 | 0, | |
v = c === 'x' ? r : (r & 0x3 | 0x8); | |
return v.toString(16) |
This file contains hidden or 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 Person(name){ | |
this.name = name; | |
} | |
Person.prototype.sayName = function(){ | |
console.log(this.name); | |
} | |
function extend(subClass, superClass){ | |
function F(){} |
This file contains hidden or 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 highlight(str){ | |
var colors = ['blue','rgb(9, 197, 9)','red','lightgray']; | |
var reg = /(var|this|new|return|function)|([\"'].*?[\"'])|([+-]?\d+(?:\.\d+)?)|(\/\/.*|\/\*[\s\S]*?\*\/)/g; | |
var res = str.replace(reg, function(match){ | |
var args = [].slice.call(arguments,1); | |
return '<span style="color:' + colors[args.indexOf(match)] + '">' + match + '</span>'; | |
}); | |
return res; | |
} |
This file contains hidden or 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 obj = {}; | |
obj.a = { | |
'a1' : 'a', | |
'b1' : { | |
'aa' : 'aa', | |
'bb' : { | |
'aaa' : 'aaa', |
This file contains hidden or 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
// from jQuery | |
// Evaluates a script in a global context | |
globalEval: function( code ) { | |
var script = document.createElement( "script" ); | |
script.text = code; | |
document.head.appendChild( script ).parentNode.removeChild( script ); | |
} |
This file contains hidden or 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
<html> | |
<head> | |
<title>两拦布局右侧宽度固定-左侧自适应</title> | |
<style media="screen"> | |
.con{width: 90%; overflow:hidden; border:1px dashed red} | |
.right{float: right; width:200px; margin-left:-200px; height:400px; background: green} | |
.left{float:left; width:100%;} | |
.main{margin-right:200px; height:500px; background: orange} | |
</style> | |
</head> |
This file contains hidden or 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
// | |
// ViewController.swift | |
// test | |
// | |
// Created by 张代应 on 14/11/28. | |
// Copyright (c) 2014年 imf2e. All rights reserved. | |
// | |
import UIKit | |
//import CoreText |
OlderNewer