Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
View GitHub Profile
@lanqy
lanqy / deferred_google_analytics.html
Created Nov 26, 2011 — forked from anonymous/deferred_google_analytics.html
jQuery version of deferred Google Analytics. See http://neil.fraser.name/news/2010/04/07/ for more details.
View deferred_google_analytics.html
<script type="text/javascript">
(function($) {
$("body").load(function() {
setTimeout(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}, 1);
});
})(jQuery);
View gist:2597472
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
View gist:2597519
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
View gist:2597567
var x,y;
document.onmousemove = function(e){
e = e || window.event;
x = e.clientX;
y = e.clientY;
};
function elementAtMousePosition() {
return document.elementFromPoint(x,y);
@lanqy
lanqy / rAF.js
Created May 25, 2012 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
View rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
View image_replacer.js
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@lanqy
lanqy / dabblet.css
Created Jun 7, 2012
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
View CSS3 loading
.spinner {
position: absolute;
top: 50%;
left: 50%;
margin: -25px 0px 0px -25px;
width: 50px;
height: 50px;
background: url('loading.png') no-repeat center center;
-moz-animation-name: spin;
-moz-animation-duration: 1s;
@lanqy
lanqy / gist:4507603
Last active Dec 10, 2015
判断数组值唯一
View gist:4507603
_unique: function (arr) { //判断数组值唯一
var i,len = arr.length,a = [],o = {};
for (i = 0; i < len; i++) {
o[arr[i]] = 0;
}
for (i in o) {
a.push(i);
}
return a;
}
@lanqy
lanqy / email.js
Last active Dec 13, 2015
Email validate
View email.js
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
You can’t perform that action at this time.