Skip to content

Instantly share code, notes, and snippets.

View hfknight's full-sized avatar

fei.io hfknight

View GitHub Profile
@hfknight
hfknight / gist:7216085
Created October 29, 2013 14:50
JS: Close Element by clicking anywhere on page
$('#element-need-show').click(function(e){
e.stopPropagation();
});
$("#link-for-popup").click(function(e) {
e.preventDefault();
e.stopPropagation();
$('#element-need-show').show();
});
$(document).click(function() {
$('#element-need-show').hide();
@hfknight
hfknight / gist:6308261
Last active December 21, 2015 12:49
Prevent Animation jerky in webkit based browsers (Safari and etc.)
Webkit flicks if the element you want to animate is bigger than the screen.
The Fix:
Add these two properties to prevent flickering effects:
-webkit-transform: translateZ(0);
-webkit-perspective: 1000;
-webkit-backface-visibility: hidden;
Reference: http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/
@hfknight
hfknight / gist:5901593
Created July 1, 2013 14:59
workaround for $.browser.msie and $.browser.version on jQuery 1.9.x, but exclusively for detecting IE.
jQuery.browser={};(function(){jQuery.browser.msie=false;
jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)\./)){
jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();
@hfknight
hfknight / gist:5707408
Created June 4, 2013 16:36
Customize Tomcat Directory Listings
1. in tomcat/conf/server.xml, add the directory to appBase paramter in Host section
<Host name="test.example.com" appBase="/mnt/example" autoDeploy="true" reloadable="true">
2. in the listing directory, add WEB-INF/ folder, add web.xml in WEB-INF w/ the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">