Skip to content

Instantly share code, notes, and snippets.

Ford Lee fordlee404

Block or report user

Report or block fordlee404

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fordlee404
fordlee404 / boot2docker-NFS.md
Last active Aug 29, 2015 — forked from haggen/README.md
boot2docker on nfs
View boot2docker-NFS.md

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:

View util.css
/* ==========================================================================
基础工具
*@ Name: utils.css V1.0.0
*@ Author: 一丝
*@ Update: 2013-9-30 15:39:57;
*@ Copyright: MIT License
========================================================================== */
/**
* 闭合浮动
View clearfix.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.
*/
.cf:before,
View onceEventHandler.js
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 Sep 10, 2013
解决由浮点数精度原因造成的 1.0-0.9!==0.1 的问题
View floatNumberIsEqual.js
// 通过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){
View cookie.js
@fordlee404
fordlee404 / inArray.js
Created Sep 10, 2013
判断数组中是否有某个值
View inArray.js
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 Sep 10, 2013
显示/隐藏元素
View toggle.js
function toggle(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
View eventListener.js
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 {
View parseURL.js
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,
You can’t perform that action at this time.