Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / FibonacciSequenceSum.java
Created December 24, 2012 07:15
数列求和
/**
* 求FebonacciSequence数列
*/
import java.util.Scanner;
public class FibonacciSequenceSum {
public static void main(String[] args) {
long sum;
while (true) {
@leohxj
leohxj / isArray.js
Created August 2, 2013 03:36
JS判断变量是否是数组
isArray = ('isArray' in Array) ? Array.isArray : function(value) {
return Object.prototype.toString.call(value) === '[object Array]';
}
@leohxj
leohxj / body.html
Last active December 20, 2015 19:19
body撑满屏幕
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin:0;
padding: 0;
}
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'MSTransition':'msTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
@leohxj
leohxj / CSS加载字体
Created August 19, 2013 00:55
CSS加载字体
@font-face {
font-family: 'FontName';
src: url('fonts/FontName.eot?#iefix') format('embedded-opentype'),
url('fonts/FontName.woff') format('woff'),
url('fonts/FontName.ttf') format('truetype'),
url('fonts/FontName.svg#FontName') format('svg');
font-weight: normal;
font-style: normal;
}
@leohxj
leohxj / changeJS.html
Created August 19, 2013 02:32
IE加载jQuery.js, 其他加载zepto.js
<script>
// This detects whether the browser requires the Zepto or Ender library
document.write('<script src=js/' +
('__proto__' in {} ? 'zepto' : 'jquery') +
'.min.js><\/script>');
</script>
@leohxj
leohxj / mobile_reset.css
Created August 19, 2013 03:26
移动平台广告的Reset CSS
/*============= Begin Reset CSS =============*/
* {
margin: 0;
padding: 0;
border: 0;
outline: 0;
vertical-align: baseline;
background: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
@leohxj
leohxj / floor.js
Created August 20, 2013 03:03
取整
videoDuration = parseInt(video.duration);
videoDuration = video.duration.toFixed(0);
@leohxj
leohxj / touchEvent.js
Created August 21, 2013 02:52
使用Modernizr检测触摸/点击事件
var isTouch = Modernizr.touch;
var defaults = {
name: "range",
tapGesture: isTouch ? "tap" : "click",
startGesture: isTouch ? "touchstart" : "mousedown",
moveGesture: isTouch ? "touchmove" : "mousemove",
stopGesture: isTouch ? "touchend touchcancel" : "mouseup",
hoverGesture: isTouch ? "touchstart" : "mouseover"
};
@leohxj
leohxj / originalEventDetection.js
Created August 21, 2013 02:55
原生JS判断是否支持触摸屏
var SupportsTouches = ("createTouch" in document);
var default = {
StartEvent : SupportsTouches ? "touchstart" : "mousedown",//支持触摸式使用相应的事件替代
MoveEvent : SupportsTouches ? "touchmove" : "mousemove",
EndEvent : SupportsTouches ? "touchend" : "mouseup"
}