Skip to content

Instantly share code, notes, and snippets.

@fordlee404
fordlee404 / boot2docker-NFS.md
Last active August 29, 2015 14:25 — forked from haggen/README.md
boot2docker on nfs

A script to switch boot2docker to use NFS instead of VBoxfs for speed.

1) In your Mac, open the file /etc/nfs.conf and add this line:

nfs.server.mount.require_resv_port = 0

2) Then, open /etc/exports and add this line, changing the values to match your case:

/* ==========================================================================
基础工具
*@ Name: utils.css V1.0.0
*@ Author: 一丝
*@ Update: 2013-9-30 15:39:57;
*@ Copyright: MIT License
========================================================================== */
/**
* 闭合浮动
/**
* 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.
*/
.cf:before,
@fordlee404
fordlee404 / onceEventHandler.js
Created November 18, 2013 05:38
创建一次性事件
document.getElementById("myelement").addEventListener("click", handler);
// 处理器函数
function handler(e) {
// 移除处理器
e.target.removeEventListener(e.type, arguments.callee);
alert("You'll only see this once!");
}
@fordlee404
fordlee404 / floatNumberIsEqual.js
Created September 10, 2013 02:44
解决由浮点数精度原因造成的 1.0-0.9!==0.1 的问题
// 通过isEqual工具方法判断数值是否相等
function isEqual(number1, number2, digits){
digits = digits === undefined? 10: digits; // 默认精度为10
return number1.toFixed(digits) === number2.toFixed(digits);
}
isEqual(1.0-0.7, 0.3); // return true
// 原生扩展方式,更喜欢面向对象的风格
Number.prototype.isEqual = function(number, digits){
@fordlee404
fordlee404 / cookie.js
Created September 10, 2013 02:34
操作cookie
@fordlee404
fordlee404 / inArray.js
Created September 10, 2013 02:22
判断数组中是否有某个值
Array.prototype.inArray = function (value) {
for (var i=0,l = this.length ; i <l ; i++) {
if (this === value) {
return true;
}
}
return false;
};
@fordlee404
fordlee404 / toggle.js
Created September 10, 2013 02:19
显示/隐藏元素
function toggle(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
@fordlee404
fordlee404 / eventListener.js
Created September 10, 2013 02:14
添加/移除事件
var addEvent,removeEvent;
addEvent = function(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);//DOM2.0
return true;
}else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);//IE5+
return r;
}else {
function parseURL(url) {
var a = document.createElement('a');
//创建一个链接
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,