Skip to content

Instantly share code, notes, and snippets.

andy wu and80506

Block or report user

Report or block and80506

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
View tinyServer.js
// hey, everybody! it's a tiny Web server!
// instead of a bunch of foo = reqire("foo")
// list our required modules and loop through
var r = ["fs", "http", "path", "url"];
for (var i = 0; i < r.length; i++) {
global[r[i]] = require(r[i]);
}
// some constants
@and80506
and80506 / 多行文本溢出显示省略号
Created Aug 28, 2014
多行文本溢出显示省略号
View 多行文本溢出显示省略号
{
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
View guid
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
@and80506
and80506 / isOnViewPort
Last active Dec 30, 2015
Check if element is visible on viewport
View isOnViewPort
var isOnViewPort = (function() {
var compatMode = document.compatMode;
function posY(elm) {
var test = elm, top = 0;
while(!!test && test.tagName.toLowerCase() !== "body") {
top += test.offsetTop;
test = test.offsetParent;
}
@and80506
and80506 / jQuery.support
Created Dec 9, 2013
jQuery.support 实现
View jQuery.support
/**
* Support testing using an element
* @param {Function} fn Passed the created div and expects a boolean result
*/
function assert( fn ) {
var div = document.createElement("div");
try {
return !!fn( div );
} catch (e) {
View jQuery.isNative
function isNative( fn ) {
return /^[^{]+\{\s*\[native \w/.test( fn + "" );
}
You can’t perform that action at this time.