Code //找出所有具有相同类名的元素 function hasClass(name, type) { var r = []; var re =new RegExp("(^|\\s)"+ name +"(\\s|$)"); var e = document.getElementsByTagName(type ||"*"); for (var j =0; j < e.length; j++) if (re.test(e[j].className)) r.push(e[j]); return r; };
Code // 实现渐隐或者渐显动画的函数 // 参数:动画元素,开始透明度,结束透明度,动画持续时间 // 返回:动画句柄数组 function fade(elem, startVal, finishVal, time) { var diff = finishVal - startVal; var t = time ||1000; var handles = []; for (var i =0; i <100; i++) { (function(n) { handles.push( setTimeout(function() { setOpacity(elem, (startVal + diff * n /100)); }, t * n /100)); })(i); } return handles; }
slide函数
Code // 实现滑动动画的函数,可以实现横/纵向滑动展开/收拢,或者横/纵向滑动位移 // 参数:动画元素,动画属性,开始值,结束值,动画持续时间 // 动画属性可选值:'top', 'left', 'height', 'left', 'padding', 'margin' // 返回:动画句柄数组 function slide(elem, styleName, startVal, finishVal, time) { var diff = finishVal - startVal; var t = time ||1000; var handles = []; for (var i =0; i <200; i++) { (function(n) { handles.push( setTimeout(function() { elem.style[styleName] = (startVal + (diff * n /200)) +'px'; }, t * n /200)); })(i); } return handles; }
一系列获取当前页面或窗口相关长宽和位置的并具有兼容性的函数
Code // 获取页面宽度 function pageWidth() { return document.body.scrollWidth; }
// 获取页面高度 function pageHeight() { return document.body.scrollHeight; }
// 获取浏览器视口高度 function windowHeight() { var de = document.documentElement; return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight; }
// 获取浏览器视口宽度 function windowWidth() { var de = document.documentElement; return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; }
// 获取当前向右卷动的长度 function scrollX() { var de = document.documentElement; return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft; }
// 获取当前像下卷动的长度 function scrollY() { var de = document.documentElement; return self.pageYOffset || (de && de.scrollTop) || document.body.scrollTop; }
Code var ol = document.getElementById('DDoverlay'); var box = document.getElementById('DDimgBox'); var im = pb.getElementsByTagName('img')[0]; var note = pb.getElementsByTagName('div')[1]; var mg =50;
var elems = hasClass('DDbox', 'a'); for (var i =0; i < elems.length; i++) { elems[i].onclick = showDDbox; }
//找出所有具有相同类名的元素 function hasClass(name, type) { var r = []; var re =new RegExp("(^|\\s)"+ name +"(\\s|$)"); var e = document.getElementsByTagName(type ||"*"); for (var j =0; j < e.length; j++) if (re.test(e[j].className)) r.push(e[j]); return r; };
function stopBubble(e) { // 如果传入了事件对象,那么就是非IE浏览器 if (e && e.stopPropagation) // 支持W3C的stopPropation()方法 e.stopPropagation(); else // 否则,我们得使用IE的方式来取消事件冒泡 window.event.cancelBubble =true; }
function stopDefault(e) { if (e && e.preventDefault) e.preventDefault(); else window.event.returnValue =false; returnfalse; }
function setOpacity(elem, level) { //注意这里两个filter的单复数形式 if (elem.filters) elem.style.filter ='alpha(opacity='+ level +')'; else elem.style.opacity = level /100; }
function fade(elem, startVal, finishVal, time) { var diff = finishVal - startVal; var t = time ||1000; var handles = []; for (var i =0; i <100; i++) { (function(n) { handles.push( setTimeout(function() { setOpacity(elem, (startVal + diff * n /100)); }, t * n /100)); })(i); } return handles; }
function slide(elem, styleName, startVal, finishVal, time) { var diff = finishVal - startVal; var t = time ||1000; var handles = []; for (var i =0; i <200; i++) { (function(n) { handles.push( setTimeout(function() { elem.style[styleName] = (startVal + (diff * n /200)) +'px'; }, t * n /200)); })(i); } return handles; }
// 获取页面宽度 function pageWidth() { return document.body.scrollWidth; }
// 获取页面高度 function pageHeight() { return document.body.scrollHeight; }
// 获取浏览器视口高度 function windowHeight() { var de = document.documentElement; return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight; }
// 获取浏览器视口宽度 function windowWidth() { var de = document.documentElement; return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; }
// 获取当前向右卷动的长度 function scrollX() { var de = document.documentElement; return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft; }
// 获取当前像下卷动的长度 function scrollY() { var de = document.documentElement; return self.pageYOffset || (de && de.scrollTop) || document.body.scrollTop; }
// addEvent/removeEvent written by Dean Edwards, 2005 // with input from Tino Zijdel // http://dean.edwards.name/weblog/2005/10/add-event/ function addEvent(element, type, handler) { // assign each event handler a unique ID if (!handler.$$guid) handler.$$guid = addEvent.guid++; // create a hash table of event types for the element if (!element.events) element.events = {}; // create a hash table of event handlers for each element/event pair var handlers = element.events[type]; if (!handlers) { handlers = element.events[type] = {}; // store the existing event handler (if there is one) if (element["on"+ type]) { handlers[0] = element["on"+ type]; } } // store the event handler in the hash table handlers[handler.$$guid] = handler; // assign a global event handler to do all the work element["on"+ type] = handleEvent; }; // a counter used to create unique IDs addEvent.guid =1;
function removeEvent(element, type, handler) { // delete the event handler from the hash table if (element.events && element.events[type]) { delete element.events[type][handler.$$guid]; } };
function handleEvent(event) { var returnValue =true; // grab the event object (IE uses a global event object) event = event || fixEvent(window.event); // get a reference to the hash table of event handlers var handlers =this.events[event.type]; // execute each event handler for (var i in handlers) { this.$$handleEvent = handlers[i]; if (this.$$handleEvent(event) ===false) { returnValue =false; } } return returnValue; };
function domReady( f ) { // If the DOM is already loaded, execute the function right away if ( domReady.done ) return f();
// If we’ve already added a function if ( domReady.timer ) { // Add it to the list of functions to execute domReady.ready.push( f ); } else { // Attach an event for when the page finishes loading, // just in case it finishes first. Uses addEvent. addEvent( window, "load", isDOMReady );
// Initialize the array of functions to execute domReady.ready = [ f ];
// Check to see if the DOM is ready as quickly as possible domReady.timer = setInterval( isDOMReady, 13 ); } }
// Checks to see if the DOM is ready for navigation function isDOMReady() { // If we already figured out that the page is ready, ignore if ( domReady.done ) returnfalse;
// Check to see if a number of functions and elements are // able to be accessed if ( document && document.getElementsByTagName && document.getElementById && document.body ) {
// If they’re ready, we can stop checking clearInterval( domReady.timer ); domReady.timer =null;
// Execute all the functions that were waiting for ( var i =0; i < domReady.ready.length; i++ ) domReady.ready[i]();
// Remember that we’re now done domReady.ready =null; domReady.done =true; } }
DDbox.js
addEvent(window, 'load', runDDbox);
function runDDbox() { createBox(); var ol = document.getElementById('DDoverlay'); var box = document.getElementById('DDimgBox'); var im = pb.getElementsByTagName('img')[0]; var note = pb.getElementsByTagName('div')[1]; var mg =50;
var elems = hasClass('DDbox', 'a'); for (var i =0; i < elems.length; i++) { elems[i].onclick = showDDbox; }
Task not serializable是Spark开发过程最令人头疼的问题之一,这里记录下出现这个问题的两个实例,一个是自己遇到的,另一个是stackoverflow上看到。等有时间了再仔细探究出现Task not serialiazable的各种原因以及出现问题后如何快速定位问题的所在,至少目前阶段碰到此类问题,没有什么章法
1.
package spark.exampl
mysql 查看当前正在执行的操作,即正在执行的sql语句的方法为:
show processlist 命令
mysql> show global status;可以列出MySQL服务器运行各种状态值,我个人较喜欢的用法是show status like '查询值%';一、慢查询mysql> show variab
1. 只有Map任务的Map Reduce Job
File System Counters
FILE: Number of bytes read=3629530
FILE: Number of bytes written=98312
FILE: Number of read operations=0
FILE: Number of lar
import java.util.LinkedList;
import java.util.List;
import ljn.help.*;
public class BTreeLowestParentOfTwoNodes {
public static void main(String[] args) {
/*
* node data is stored in
本文介绍Java API 中 Date, Calendar, TimeZone和DateFormat的使用,以及不同时区时间相互转化的方法和原理。
问题描述:
向处于不同时区的服务器发请求时需要考虑时区转换的问题。譬如,服务器位于东八区(北京时间,GMT+8:00),而身处东四区的用户想要查询当天的销售记录。则需把东四区的“今天”这个时间范围转换为服务器所在时区的时间范围。
入口脚本
入口脚本是应用启动流程中的第一环,一个应用(不管是网页应用还是控制台应用)只有一个入口脚本。终端用户的请求通过入口脚本实例化应用并将将请求转发到应用。
Web 应用的入口脚本必须放在终端用户能够访问的目录下,通常命名为 index.php,也可以使用 Web 服务器能定位到的其他名称。
控制台应用的入口脚本一般在应用根目录下命名为 yii(后缀为.php),该文