`
ThinkInMyLife
  • 浏览: 47815 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
Highcharts的demo
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts First Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="Highcharts-3.0.7/js/highcharts.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'spline'
},
title: {
text: 'notify消息监控'
},
subtitle: {
text: '关于收藏,上新,优惠'
},
xAxis: {
categories: [ '2013-10-24','2013-10-25','2013-10-26','2013-10-27','2013-10-28' ],
tickInterval: 1
},
yAxis: {
title: {
text: '数量(次)'
},
min: 0
},
plotOptions: {
series: {
lineWidth: 2
}
},
series: [{
name: '收藏更新消息',
data: [409301,0,2139573,7845919,8887847 ]
}, {
name: '收藏更新成功',
data: [409299,0,2139570,7845921,8887619]
}, {
name: '收藏删除消息',
data: [ 117324,0,668381,2577338,2695159 ] 
}, {
name: '收藏删除成功',
data: [ 117324,0,668381,2577338,2695109]
}, {
name: '上新消息数',
data: [ 172563,0,860558,3042167,3434508]
}, {
name: '上新成功数',
data: [ 10013,0,285805,1422303,1363018]
}, {
name: '优惠消息数',
data: [ 222244,0,982588,3632411,4634022]
}, {
name: '优惠成功数',
data: [ 12331,0,318957,1601797,1683636]
}]
});
});
</script>
</head>
<body>
<div>
<!-- Highcharts rendering takes place inside this DIV --> 
<div id="container"></div>
</div>
</body>
</html>
JPEGFilter
public class JPEGFilter extends ImageFilter{
	public static final int HEAD = 0xFFD8;
	private static int maxLength = 2*1024*1024;
	
	public static final int SIGN_SOI = 0xD8;		//文件头
	public static final int SIGN_EOI = 0xD9;		//文件尾
	public static final int SIGN_SOF0 = 0xC0;		//帧开始(标准 JPEG)
	public static final int SIGN_SOF1 = 0xC1;		//扩展,覆盖SOF0
	public static final int SIGN_SOF2 = 0xC2;		//扩展,覆盖SOF1
	public static final int SIGN_DHT = 0xC4;		//定义 HUFFMAN 表(霍夫曼表)
	public static final int SIGN_SOS = 0xDA;		//扫描行开始
	public static final int SIGN_DQT = 0xDB;		//定义量化表
	public static final int SIGN_DRI = 0xDD;		//定义重新开始间隔
	public static final int SIGN_APP0 = 0xE0;		//定义交换格式和图像识别信息
	public static final int SIGN_COM = 0xFE;		//注释

	public static final int SIGN_APP_DEFINE_START = 0xFFE1;		//应用程序注释块开始
	public static final int SIGN_APP_DEFINE_END = 0xFFEF;			//应用程序注释块结束

	private boolean checkWhole = false;			//是否完整检查文件流,缺省是检查文件头

	public boolean isCheckWhole() {
		return checkWhole;
	}

	public void setCheckWhole(boolean checkWhole) {
		this.checkWhole = checkWhole;
	}

	public ImageResult process(InputStream fis,int mode,int length){
		ImageResult result = new ImageResult();
		if (fis == null){
			result.setErrorCode(ImageResult.ERROR_NULL);
			return result;
		}
		boolean valid = false;
		boolean over = false;

		try {
			int startSign = readInt(fis,2);
			if (startSign != 0xFFD8){
				result.setErrorCode(ImageResult.ERROR_INVALID_FORMAT);
				return result;
			}
			int segHead = 0;
			byte[] head = new byte[1024];		//文件头信息
			head[0] = (byte)0xFF;
			head[1] = (byte)0xD8;
			int offset = 2;						//初始偏移量为2
			int skipBytes = 0;					//要忽略的字节数
			while ((writeBuffer(fis, 2, head, offset) == 2) && !over){
				int infoSegLength = 0;			//段长度
				int segOffset = 0;				//段在head数组中的起始偏移量

				segHead = byte2int(head,offset,2);
				offset += 2;					//段标记也是占偏移量滴

				switch (segHead){
//					case 0xFF00 + SIGN_SOI :break;
//					case 0xFF00 + SIGN_EOI :
//						//结束了
//						over = true;
//						break;
					case 0xFF00 + SIGN_SOF0 :
					case 0xFF00 + SIGN_SOF1 :
					case 0xFF00 + SIGN_SOF2 :
//						head[++offset] = (byte)0xFF;
//						if (segHead == 0xFF00 + SIGN_SOF0)
//							head[++offset] = (byte)SIGN_SOF0;
//						else
//							head[++offset] = (byte)SIGN_SOF1;
						if (writeBuffer(fis, 2, head, offset) != 2){
							over = true;
							break;
						}
						offset += 2;			//段长度也是要记录滴
						segOffset = offset;		//这个段内容在head中的偏移量 
						infoSegLength = byte2int(head, offset - 2, 2) - 2;		//计算段长度
						if (writeBuffer(fis, infoSegLength, head, offset) != infoSegLength){		//读入剩余的字节
							over = true;
							break;
						}
						offset += infoSegLength;
						result.setBit(byte2int(head,segOffset,1));			//样本精度
						result.setHeight(byte2int(head,segOffset+1,2));		//图片高度
						result.setWidth(byte2int(head,segOffset+3,2));		//图片宽度
						if (mode == ImageFilter.MODE_HEAD_INFO){			//如果只需要取头信息,那到此为止了
							result.setSucess(true);
							return result;
						}
						break;
					case 0xFF00 + SIGN_SOS :
						if (length - skipBytes > getMaxLength()){
							result.setErrorCode(ImageResult.ERROR_SIZE_EXCEED);
							return result;
						}
						byte[] file = new byte[length - skipBytes];
						for (int i=0;i<offset;i++){
							file[i] = head[i];								//复制头信息
						}
						int scanLineLength = length - offset - skipBytes;
						//可能在末尾之后还有数据,那部分数据应该被滤掉
						boolean end = false;
						//扫描行长度,减去头信息的字节数,被忽略的字节数和当前0xFF+SIGN_SOS的两个字节数
						if (writeBuffer(fis, scanLineLength, file, offset) == scanLineLength){
							for (int i=offset;i<offset + scanLineLength - 1;i++){
								if (byte2int(file, i, 2) == 0xFF00 + SIGN_EOI){
									end = true;
									offset = i;
									break;
								}
							}
							if (end){			//检测到了结束符号
								if (offset == file.length - 1){
									//正常结束
								}else{
									byte[] availFile = new byte[offset + 2];
									System.arraycopy(file, 0, availFile, 0, availFile.length);
									skipBytes += file.length - availFile.length;
									file = availFile;
								}
							}else{				//末尾不是 FF D9 , 手动补上
								if (byte2int(file, file.length - 2, 2) != 0xFF00 + SIGN_EOI){
									file[file.length - 2] = (byte)0xFF;
									file[file.length - 1] = (byte)SIGN_EOI;
									//容错处理,一般在网络状况不佳的情况下发生,客户不是傻瓜,他们看到图片不对会重新传的
								}
							}
							valid = true;
							over = true;
							result.setData(file);
							result.setSkipLength(skipBytes);
						}
						//因为预先已分配了足够大的数组,所以下面这段逻辑暂时不使用(注意是暂时不使用,如果文件足够大的话还是要用的)
/*						boolean unknownEnd = false;
						byte[] b = null;
						while ((b = readBytes(fis, bufferLength)).length > 0){
							if (b.length > 1){
								if (((b[b.length - 2] & 0xFF) << 8) + (b[b.length - 1] & 0xFF) == 0xFF00 + SIGN_EOI){
									valid = true;			//最后两个字节匹配结束
									over = true;
									break;
								}else{		//存在一种很变态的情况
									if ((b[b.length - 1] & 0xFF) == 0xFF){
										unknownEnd = true;
									}else{
										unknownEnd = false;
									}
								}
							}else{
								if (unknownEnd && ((b[0] & 0xFF) == SIGN_EOI)){
									valid = true;			//最后一个字节流刚好掉到了
									over = true;
									break;
								}
							}
						}*/
						break;
//					case 0xFF00 + SIGN_DHT :
//					case 0xFF00 + SIGN_DQT :
//					case 0xFF00 + SIGN_DRI :
//					case 0xFF00 + SIGN_APP0 :
					//case 0xFF00 + SIGN_COM :
					default:				//重点关注点,藏病毒木马的场所,注释和其他应用程序自定义内容一律咔嚓掉
						if (segHead == 0xFF00 + SIGN_COM || (segHead >= SIGN_APP_DEFINE_START && segHead <= SIGN_APP_DEFINE_END)){
							offset -= 2;			//因为要忽略的,所以偏移量是不算在内滴
							int skipLength = readInt(fis, 2);
							skip(fis, skipLength - 2);
							skipBytes += skipLength + 2;		//segHead也占两个字节
						}else{				//其他普通标记,原封不动的带过去
							if (writeBuffer(fis, 2, head, offset) != 2){
								over = true;
								break;
							}
							offset += 2;			//段长度标记也占2个字节
							infoSegLength = byte2int(head, offset - 2, 2) - 2;		//计算段长度,要减2是因为段长度包含了上面的2字节个段长度标记的
							int skip = 0;
							boolean skipThumbnail = (segHead == 0xFF00 + SIGN_APP0 && infoSegLength > 14);
							if (skipThumbnail){		//这个标签比较特殊,可能会带有缩略图
								skip = infoSegLength - 14;
								infoSegLength = 14;
							}
							int read = writeBuffer(fis, infoSegLength, head, offset);
							if (read != infoSegLength){		//读入剩余的字节
								over = true;
								break;
							}
							offset += infoSegLength;
							if (skipThumbnail){
								head[offset - 16] = 0;
								head[offset - 15] = 16;			//头部指定只用16个字节
								head[offset - 2] = 0;
								head[offset - 1] = 0;			//最后两个缩略图字节变为0
								skip(fis, skip);
								skipBytes += skip;
							}
						}
				}
			}
		}catch (Exception e) {
			//错误无视之
		}finally{
			try {
				if (fis != null)
					fis.close();
			} catch (IOException e) {}
		}
		if (valid){
			result.setSucess(true);
		}else{
			result.setSucess(false);
			result.setErrorCode(ImageResult.ERROR_INVALID_FORMAT);
		}
		return result;
	}

	public int getMaxLength() {
		return maxLength;
	}

	public boolean isValidFormat(byte[] headBytes) {
		if (headBytes == null || headBytes.length < 2)
			return false;
		int head = (headBytes[0] & 0xFF)*0x100 + (headBytes[1] & 0xFF);
		return HEAD == head;
	}

	public static void main(String[] args) {
		java.io.File[] fs = new java.io.File("e:\\a\\").listFiles();
		JPEGFilter headInfo = new JPEGFilter();
		for (int i=0;i<fs.length;i++){
			if (fs[i].isFile()){
				try {
					ImageResult result = headInfo.process(fs[i].getAbsolutePath(),ImageFilter.MODE_ALL_DATA);
					if (result.isSucess()){
						System.out.println("Picture Name = " + fs[i].getName() + ",Width = " + result.getWidth() + ", Height = " + result.getHeight());
						FileOutputStream fos = new FileOutputStream("e:\\a\\d" + fs[i].getName());
						fos.write(result.getData());
						fos.flush();
						fos.close();
					}else
						System.err.println("Error " + fs[i].getName());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
}
magick上传文件
import magick.ImageInfo;
import magick.MagickImage;
import magick.MagickException;
import java.io.File;

public class ImgUploadUtil
{

    public static final long MAX_FILE_SIZE   = (1024 * 1024 * 5); //5Mbyte
    public static final int  MAX_IMAGE_PIXEL = (10 * 1000 * 1000);

    private static boolean resizeImage(String fileName, int nWidth, int nHeight, int nMaxPixel) throws MagickException
    {
        MagickImage image  = null;
        boolean ret = false;

        if(!checkFileFize(fileName))
        {
            return ret;
        }
        try
        {
            ImageInfo info = new ImageInfo(fileName);
            image = new MagickImage();
            image.pingImage(info);

            int width   = (int) image.getDimension().getWidth();
            int height  = (int) image.getDimension().getHeight();
            if (nMaxPixel <= 0) nMaxPixel = MAX_IMAGE_PIXEL;
            if(width * height > nMaxPixel)
            {
                return ret;
            }
            image.readImage(info);
            if(nWidth > 0 && nHeight > 0 && width > 0 && height > 0 && (nWidth < width || nHeight < height))
            {
                double wratio = 1.0 * nWidth / width;
                double hratio = 1.0 * nHeight / height;
                if (hratio < wratio) wratio = hratio;
                nWidth = (int)(wratio * width);
                nHeight = (int)(wratio * height);
                MagickImage newImage = image.zoomImage(nWidth, nHeight);
                image.destroyImages();
                image = newImage;
            }
            image.profileImage("*", null); //clean unuse info
            image.setImageAttribute("comment", null); //clean unuse info
            image.setFileName(fileName);
            image.writeImage(new ImageInfo());
            ret = true;
        }
		catch( Exception e )
		{
		}
        finally
        {
            if (image != null)
            {
                image.destroyImages();
            }
        }
        return ret;
    }
    public static boolean checkFileFize(String file)
    {
        File f = new File(file);
        if(f.exists() && f.length() < MAX_FILE_SIZE)
        {
            return true;
        }
        return false;
    }

    //Demo main function
    public static void main(String[] args) throws MagickException
    {

        boolean bRet = false;
		String fileName=null;
		if(args.length>0){
		     fileName=args[0];
        }
		else{
			System.out.println("Please input a filename.");
			System.exit(0);
		}
        bRet = resizeImage(fileName, 100, 150, 0);
        if(bRet)
        {
            System.out.println("Save File:" + fileName);
        }
        else
        {
            System.out.println("Delete dirty file!");
        }
    }

}
Eclipse选中变量名,相同变量都变色显示 的设置
Eclipse选中变量名,相同变量都变色显示 的设置
java文件的设置"Window"-"preferences"-"Java"-"Editor"-"Mark Occurrences"复选框勾选 
js文件的设置"Window"-"preferences"-"web"-"javascript"-"Mark Occurrences"复选框勾选
ext入门第三章-form校验

<link rel="stylesheet" type="text/css"  href="ext/ext-all.css">
<script type="text/javascript" src="ext/ext.js"></script>
<script type="text/javascript" src="ext/bootstrap.js"></script>
<script type="text/javascript" src="ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>

<div id="newClick" style="margin-left:10px;margin-top:10px;"></div>
<br/>
<div id="myGrid"></div>

<script type="text/javascript">
Ext.require([
	    'Ext.grid.*',
	    'Ext.data.*',
	    'Ext.util.*',
	    'Ext.state.*',
	    'Ext.toolbar.Paging',
	    'Ext.form.*',
    	'Ext.window.Window'
	]);
	
	Ext.onReady(function(){ 
		 
		 
		 /**
    	 * 新建组件
    	 */
    	
		
		var statusEn = Ext.create('Ext.data.Store', {
		    fields: ['name', 'value'],
		    data : [
		        {"name":"隐藏", "value":"0"},
		        {"name":"广场展示", "value":"1"}
		    ]
		});
		
		var homeTypeEn = Ext.create('Ext.data.Store', {
		    fields: ['name', 'value'],
		    data : [
		        {"name":"默认页面", "value":"0"},
		        {"name":"TMS页面", "value":"1"}
		    ]
		});

		//扩展VTypes数字验证1-100  
		Ext.apply(Ext.form.VTypes,{  
		        'weight' : function(_v){  
		            if(/^\d+$/.test(_v)){//判断必须是数字    
		                var _weight = parseInt(_v);  
		                //增加业务逻辑,小于100的数字才符合 
		                if(0 < _weight && _weight <= 100){  
		                    return true ;  
		                }  
		            }  
		            return false ;  
		        },  
		        weightText : '请输入1-100的数字' , //出错信息后的默认提示信息      
		    weightMask:/[0-9]/i  //键盘输入时的校验  
		})  
		
		var form = Ext.create('Ext.form.Panel', {
	        plain: true,
	        border: 0,
	        bodyPadding: 5,
	        url: 'json/create_category_admin_json.do?_input_charset=utf-8',
	
	        fieldDefaults: {
	            labelWidth: 55,
	            anchor: '100%'
	        },
	
	        layout: {
	            type: 'vbox'
	        },
	
	        items: [
	        
	        {
                xtype: 'fieldset',
                title: '类目基本信息',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [
	        
			        {
			            xtype: 'textfield',
			            fieldLabel: '名称',
			            maxLength:20,
			            maxLengthText :'最多填20个字',
			            blankText:'必选',
			            allowBlank: false,
			            name: 'name'
			        }, 
			        {
			            xtype: 'textfield',
			            fieldLabel: '排序',
			            name: 'indexed',
			            allowBlank: false,
			            vtype : 'weight'
			        },
			        
			        {
			        	xtype: 'combobox',
			        	name: 'status',
					    fieldLabel: '状态',
					    blankText:'必选',
					    store: statusEn,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: 'value',
					   	margins: '0 6 0 0',
		                allowBlank: false,
		                forceSelection: true
					},
			          {
			          	xtype: 'combobox',
			          	name: 'homeType',
					    fieldLabel: '首页',
					    blankText:'必选',
					    store: homeTypeEn,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: 'value',
					   	margins: '0 6 0 0',
		                allowBlank: false,
		                forceSelection: true
					},
					{
			            xtype: 'textfield',
			            vtype:'url', 
						vtypeText:'不是有效的url', 
			            fieldLabel: 'TMS地址',
			            name: 'homeUrl'
			        },
			        {
			            xtype: 'textfield',
			            fieldLabel: 'icon地址',
			            name: 'icon',
			            allowBlank: false,
			            blankText:'必选'
			        }
			        
			 	]
	        },
	         {
                xtype: 'fieldset',
                title: '宝贝筛选信息',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [
	        
			        {
			            xtype: 'textfield',
			            fieldLabel: '宝贝分值',
			            name: 'itemScore',
			            vtype : 'weight',
			            blankText:'必选',
			            allowBlank: false
			        }, 
			        {
			            xtype: 'textfield',
			            fieldLabel: '宝贝类目',
			            name: 'itemCats',
			            allowBlank: false,
			            blankText:'必选'
			        }
			 	]
	         },
	         {
		        xtype: 'hiddenfield',
		        name: 'id',
		        value: '0'
		    }
	        
	        ],
	        buttons: [{
		        text: '提交',
		        handler: function() {
		            // The getForm() method returns the Ext.form.Basic instance:
		            var form = this.up('form').getForm();
		            if (form.isValid()) {
		                form.submit({
		                    success: function(form, action) {
		                       Ext.Msg.alert('Success', action.result.msg);
		                       newWin.close();
		                    },
		                    failure: function(form, action) {
		                        Ext.Msg.alert('Failed', action.result.msg);
		                        newWin.close();
		                    }
		                });
		            }
		        }
		    }]
	    });
		
		//tms地址的展示和隐藏
		var homeCombx = form.form.findField('homeType');
		homeCombx.on('change', function(newValue ){
			if(newValue.value==0){
				form.form.findField('homeUrl').setVisible(false);
				form.form.findField('homeUrl').getEl().up('.x-form-item').setDisplayed(false);  
			}else{
				form.form.findField('homeUrl').setVisible(true);
				form.form.findField('homeUrl').getEl().up('.x-form-item').setDisplayed(true);
			}
		});
		
		var newWin = Ext.create('Ext.window.Window', {
		    title: '频道分类',
		    height: 350,
		    width: 400,
		    layout: 'fit',
		    items:form,
		    closeAction:'hide'
		});
		
		Ext.create('Ext.Button', {
		    text: '频道类目',
		    renderTo: 'newClick',
		    scale   : 'medium',
		    handler: function() {
		    	form.form.reset();
		        newWin.show();
		    }
		});
		
		 
		/**
		 * 列表渲染
		 */ 
		 Ext.define('catDO', {
	        extend: 'Ext.data.Model',
	        fields: [
	            'id', 'name', 'indexed', 
	            {name: 'status', type: 'int'},
	            {name: 'homeType', type: 'int'},
	            'itemScore','homeUrl','itemCats','icon'
	        ],
	        idProperty: 'id'
	    }); 
		 
		var store = Ext.create('Ext.data.Store', {
	        pageSize: 10,
	        model: 'catDO',
	        //remoteSort: true,
	        proxy: {
	            type: 'ajax',
	            url: 'json/category_admin_json.do?_input_charset=utf-8',
	            reader: {
	                type: 'json',
	                root: 'cats',
	                totalProperty: 'total'
	            },
	           simpleSortMode: true
	        }
	        /*
	        sorters: [{
	            property: 'id',
	            direction: 'DESC'
	        }]
	        */
	    });
		 
		
		function changeStatus(val) {
	        if (val == 0) {
	            return '<span>隐藏</span>';
	        } else if (val == 1) {
	            return '<span>广场展示</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
	     
	     function changeHomeType(val) {
	        if (val == 0) {
	            return '<span>列表</span>';
	        } else if (val == 1) {
	            return '<span>自定义</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
	     
	     function changeHomeUrl(val) {
	        if (val != null) {
	            return '<a href="'+val+'" target="_blank">'+val+'</span>';
	        }else {
	        	return '<span>无url</span>';
	        }
	     }
	     
	     function changeIcon(val) {
	        if (val != null) {
	            return '<span>'+val+'</span>';
	        }else {
	        	return '<span>无icon</span>';
	        }
	     }
	     
	    window.onEdit = function (name){
	   		form.loadRecord(grid.getStore().getAt(name));
	        newWin.show();
	     }
		
		 function changeOpt(value,metaData,record,rowIndex,colIndex,store,view) {
	        return "<input type=\'button\' value=\'编辑\' onclick=\'onEdit(" + rowIndex +");\'/>";
	     }
		
		var grid = new Ext.grid.GridPanel({ 
			renderTo:"myGrid", 
			title:"类目管理", 
			//height:150, 
			//width:650, 
			columns:[	
				{header:"ID",dataIndex:"id"}, 
				{header:"频道名称",dataIndex:"name"}, 
				{header:"排序",dataIndex:"indexed"},
				{header:"状态",dataIndex:"status",renderer : changeStatus},
				{header:"默认首页",dataIndex:"homeType",renderer : changeHomeType},
				{header:"url",dataIndex:"homeUrl",renderer : changeHomeUrl},
				{header:"icon",dataIndex:"icon",renderer : changeIcon},
				{header:"宝贝筛选分值",dataIndex:"itemScore"},
				{header:"宝贝类目",dataIndex:"itemCats"},
				{header:"操作",dataIndex:"id",renderer:changeOpt}
        	], 
			store:store, 
			viewConfig: {
	            forceFit: true
	        },
	        bbar: Ext.create('Ext.PagingToolbar', {
	            //pageSize: 2,
	            store: store,
	            displayInfo: true,
	            displayMsg:'显示第{0}条到{1}条记录,一共{2}条',
	            emptyMsg: "暂无数据"
	        })
			
		}); 
    
    	//预先加载第一页
    	store.loadPage(1);
    	
    	
    	
    	
    	
    
	});
	
	
	

</script>
ext入门第三章-基本form提交
<link rel="stylesheet" type="text/css"  href="ext/ext-all.css">
<script type="text/javascript" src="ext/ext.js"></script>
<script type="text/javascript" src="ext/bootstrap.js"></script>
<script type="text/javascript" src="ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>

<div id="newClick" style="margin-left:10px;margin-top:10px;"></div>

/**
    	 * 新建组件
    	 */
    	
    	Ext.create('Ext.Button', {
		    text: '新建频道类目',
		    renderTo: 'newClick',
		    scale   : 'medium',
		    handler: function() {
		        newWin.show();
		    }
		});
		
		
		var statusEn = Ext.create('Ext.data.Store', {
		    fields: ['name', 'value'],
		    data : [
		        {"name":"隐藏", "value":"0"},
		        {"name":"广场展示", "value":"1"}
		    ]
		});
		
		var homeTypeEn = Ext.create('Ext.data.Store', {
		    fields: ['name', 'value'],
		    data : [
		        {"name":"默认页面", "value":"0"},
		        {"name":"TMS页面", "value":"1"}
		    ]
		});


		
		var form = Ext.create('Ext.form.Panel', {
	        plain: true,
	        border: 0,
	        bodyPadding: 5,
	        url: 'json/create_category_admin_json.do?_input_charset=utf-8',
	
	        fieldDefaults: {
	            labelWidth: 55,
	            anchor: '100%'
	        },
	
	        layout: {
	            type: 'vbox'
	        },
	
	        items: [
	        
	        {
                xtype: 'fieldset',
                title: '类目基本信息',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [
	        
			        {
			            xtype: 'textfield',
			            fieldLabel: '名称',
			            name: 'name'
			        }, 
			        {
			            xtype: 'textfield',
			            fieldLabel: '排序',
			            name: 'indexed'
			        },
			        
			        {
			        	xtype: 'combobox',
			        	name: 'status',
					    fieldLabel: '状态',
					    store: statusEn,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: 'value',
					   	margins: '0 6 0 0',
		                allowBlank: false,
		                forceSelection: true
					},
			          {
			          	xtype: 'combobox',
			          	name: 'home_type',
					    fieldLabel: '首页',
					    store: homeTypeEn,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: 'value',
					   	margins: '0 6 0 0',
		                allowBlank: false,
		                forceSelection: true
					},
					{
			            xtype: 'textfield',
			            fieldLabel: 'TMS地址',
			            name: 'tms_url'
			        }
			        
			 	]
	        },
	         {
                xtype: 'fieldset',
                title: '宝贝筛选信息',
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
                items: [
	        
			        {
			            xtype: 'textfield',
			            fieldLabel: '宝贝分值',
			            name: 'item_score'
			        }, 
			        {
			            xtype: 'textfield',
			            fieldLabel: '宝贝类目',
			            name: 'item_cats'
			        }
			 	]
	         }
	        
	        ],
	        buttons: [{
		        text: '提交',
		        handler: function() {
		            // The getForm() method returns the Ext.form.Basic instance:
		            var form = this.up('form').getForm();
		            if (form.isValid()) {
		                form.submit({
		                    success: function(form, action) {
		                       Ext.Msg.alert('Success', action.result.msg);
		                    },
		                    failure: function(form, action) {
		                        Ext.Msg.alert('Failed', action.result.msg);
		                    }
		                });
		            }
		        }
		    }]
	    });
		
		
		var newWin = Ext.create('Ext.window.Window', {
		    title: '新建频道分类',
		    height: 350,
		    width: 400,
		    layout: 'fit',
		    items:form,
		    closeAction:'hide'
		});
ext入门第二章-表格ajax分页
<link rel="stylesheet" type="text/css"  href="ext/ext-all.css">
<script type="text/javascript" src="ext/ext.js"></script>
<script type="text/javascript" src="ext/bootstrap.js"></script>
<script type="text/javascript" src="ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>

<div id="myGrid"></div>


<script type="text/javascript">


	Ext.require([
	    'Ext.grid.*',
	    'Ext.data.*',
	    'Ext.util.*',
	    'Ext.state.*',
	    'Ext.toolbar.Paging'
	]);
	
	Ext.onReady(function(){ 
		 
		 Ext.define('catDO', {
	        extend: 'Ext.data.Model',
	        fields: [
	            'id', 'name', 'indexed', 
	            {name: 'status', type: 'int'},
	            {name: 'homeType', type: 'int'},
	            'itemScore','homeUrl'
	        ],
	        idProperty: 'id'
	    }); 
		 
		var store = Ext.create('Ext.data.Store', {
	        pageSize: 5,
	        model: 'catDO',
	        //remoteSort: true,
	        proxy: {
	            type: 'ajax',
	            url: 'json/category_admin_json.do?_input_charset=utf-8',
	            reader: {
	                type: 'json',
	                root: 'cats',
	                totalProperty: 'total'
	            },
	           simpleSortMode: true
	        }
	        /*
	        sorters: [{
	            property: 'id',
	            direction: 'DESC'
	        }]
	        */
	    });
		 
		
		function changeStatus(val) {
	        if (val == 0) {
	            return '<span>隐藏</span>';
	        } else if (val == 1) {
	            return '<span>广场展示</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
	     
	     function changeHomeType(val) {
	        if (val == 0) {
	            return '<span>列表</span>';
	        } else if (val == 1) {
	            return '<span>自定义</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
	     
	     function changeHomeUrl(val) {
	        if (val != null) {
	            return '<a href="'+val+'" target="_blank">'+val+'</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
		
		var grid = new Ext.grid.GridPanel({ 
			renderTo:"myGrid", 
			title:"类目管理", 
			//height:150, 
			//width:650, 
			columns:[	
				{header:"ID",dataIndex:"id"}, 
				{header:"频道名称",dataIndex:"name"}, 
				{header:"排序",dataIndex:"indexed"},
				{header:"状态",dataIndex:"status",renderer : changeStatus},
				{header:"默认首页",dataIndex:"homeType",renderer : changeHomeType},
				{header:"url",dataIndex:"homeUrl",renderer : changeHomeUrl},
				{header:"宝贝筛选分值",dataIndex:"itemScore"}
			], 
			store:store, 
			viewConfig: {
	            forceFit: true
	        },
	        bbar: Ext.create('Ext.PagingToolbar', {
	            //pageSize: 2,
	            store: store,
	            displayInfo: true,
	            displayMsg:'显示第{0}条到{1}条记录,一共{2}条',
	            emptyMsg: "暂无数据"
	        })
			
		}); 
    
    	//预先加载第一页
    	store.loadPage(1);
    	
    	Ext.create('Ext.Button', {
		    text: '新建频道类目',
		    renderTo: 'newClick',
		    scale   : 'medium',
		    handler: function() {
		        alert('You clicked the button!')
		    }
		});
    
	});
	
	
	

</script>
ext入门第一章-表格基本展现
<link rel="stylesheet" type="text/css"  href="ext/ext-all.css">
<script type="text/javascript" src="ext/ext.js"></script>
<script type="text/javascript" src="ext/bootstrap.js"></script>
<script type="text/javascript" src="ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>

<div id="myGrid"></div>


<script type="text/javascript">


	Ext.require([
	    'Ext.grid.*',
	    'Ext.data.*',
	    'Ext.util.*',
	    'Ext.state.*',
	    'Ext.toolbar.Paging'
	]);
	
	Ext.onReady(function(){ 
		var data=[
									[1,'小清新',1,1,1,0]
									,
											[5,'小贱人',1,1,1,0]
									,
											[2,'爆大',1,1,1,0]
									,
											[4,'大胡子',1,1,1,0]
									,
											[7,'美女',1,1,1,0]
									,
											[6,'帅哥',1,1,1,0]
									,
											[3,'小孩子',1,1,1,0]
										
				];
		 
		 
		var store=new Ext.data.SimpleStore({data:data,fields:["id","name","indexed","status","homeType","itemScore"]});
		
		
		//data:data,fields:["id","name","indexed","status","homeType","itemScore"]});
		
		function changeStatus(val) {
	        if (val == 0) {
	            return '<span>隐藏</span>';
	        } else if (val == 1) {
	            return '<span>广场展示</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
	     
	     function changeHomeType(val) {
	        if (val == 0) {
	            return '<span>列表</span>';
	        } else if (val == 1) {
	            return '<span>自定义</span>';
	        }else {
	        	return '<span>未知</span>';
	        }
	     }
		
		var grid = new Ext.grid.GridPanel({ 
			renderTo:"myGrid", 
			title:"类目管理", 
			//height:150, 
			//width:650, 
			columns:[
			
				{header:"ID",dataIndex:"id"}, 
				{header:"频道名称",dataIndex:"name"}, 
				{header:"排序",dataIndex:"indexed"},
				{header:"状态",dataIndex:"status",renderer : changeStatus},
				{header:"默认首页",dataIndex:"homeType",renderer : changeHomeType},
				{header:"宝贝筛选分值",dataIndex:"itemScore"}
			
			
			], 
			store:store, 
			viewConfig: {
	            forceFit: true
	        },
	        bbar: Ext.create('Ext.PagingToolbar', {
	            pageSize: 20,
	            store: store,
	            displayInfo: true,
	            displayMsg:'显示第{0}条到{1}条记录,一共{2}条'
	        })
			//autoExpandColumn:2 
		}); 
    
	});
	
	
	

</script>
MD5 加密
public class MD5Util {   
  
    /**  
     * MD5 加密  
     */   
    private static String getMD5Str(String str) {   
        MessageDigest messageDigest = null;   
   
        try {   
            messageDigest = MessageDigest.getInstance("MD5");   
   
            messageDigest.reset();   
   
            messageDigest.update(str.getBytes("UTF-8"));   
        } catch (NoSuchAlgorithmException e) {   
            System.out.println("NoSuchAlgorithmException caught!");   
            System.exit(-1);   
        } catch (UnsupportedEncodingException e) {   
            e.printStackTrace();   
        }   
   
        byte[] byteArray = messageDigest.digest();   
   
        StringBuffer md5StrBuff = new StringBuffer();   
   
        for (int i = 0; i < byteArray.length; i++) {               
            if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)   
                md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));   
            else   
                md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));   
        }   
   
        return md5StrBuff.toString();   
    }   

    
    
  
    public static void main(String[] args) {   
       
            System.out.println(getMD5Str("888888"));   
        
    }   
}  
java打通ssh&ftp获取远程机器文件
for(String host:hosts){
			logger.warn("process start!day=>"+yesterDayStr+";host=>"+host);
			Connection conn = null;
			try {
				conn = sshClient.clientSSH(host, "name", "pwd");
				scpFileUtil.scpFileToLocal(conn, "/home/admin/app/logs/"+logFile, "/home/admin/dgdump");
				file = new File("/home/admin/app/"+logFile);
				if(!file.exists()){
					logger.error("logfile is null=>"+file.getAbsolutePath());
					return;
				}
				
				readFileJob(file);
				
			} catch (Exception e) {
				logger.error("error",e);
			}finally{
				if(conn!=null){
					sshClient.close();
				}
				if(file!=null){
					file.delete();
				}
			}
			
			parserResult(yesterDayKey);
			
			logger.warn("process over!");
		}



public class SSHClient {
	
	Logger logger = LoggerFactory.getLogger(SSHClient.class);

	Connection conn;
	
	public Connection clientSSH(String host,String name,String password) throws Exception{

		if(conn!=null){
			return conn;
		}
		try {
			/* Create a connection instance */
			conn = new Connection(host);
			/* Now connect */
			conn.connect();
			/* Authenticate */
			boolean isAuthenticated = conn.authenticateWithPassword(name, password);
			
			if (isAuthenticated == false)
				throw new IOException("Authentication failed.");
			
			return conn;

		} catch (Exception e) {
			logger.error("error",e);
			throw new IOException("clientSSH failed.");
		}
	}
	
	public void close(){
		if(conn!=null){
			conn.close();
			conn=null;
		}
	}
}





public class ScpFileUtil {
	
	Logger logger = LoggerFactory.getLogger(ScpFileUtil.class);
	
	public void scpFileToLocal(Connection conn,String remoteFileName,String localDirector)
		throws Exception{
		
		if(conn==null||remoteFileName==null||localDirector==null){
			throw new IllegalArgumentException();
		}
		
		try {
			SCPClient client = new SCPClient(conn);
			client.get(remoteFileName, localDirector);
		} catch (Exception e) {
			logger.error("scpFileToLocal error",e);
			throw new Exception();
		}
		
	}

}



执行command命令:
conn = sshClient.clientSSH(host, "name", "pwd");
String itemCount = commandStd(conn,"cd /home/admin/app/logs;grep 'core:item' dgsearch-monitor.log."+day+" -c;");
ibstis的dtd错误
2012-09-20 19:23:52,958 ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/home/admin/dbdump/targe
t/dbdump.war/WEB-INF/classes/bean/sql-love-map.xml]; nested exception is java.net.SocketException: Connection reset
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:416)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.j
ava:143)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.j
ava:178)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.j
ava:149)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicati
onContext.java:123)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422
)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
        at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:644)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:229)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1158)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:587)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:436)
        at com.taobao.hsf.thirdcontainer.jetty.deploy.WebAppContext.doStart(WebAppContext.java:100)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:479)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:136)
        at com.taobao.hsf.thirdcontainer.jetty.deploy.JettyAppProvider.doStart(JettyAppProvider.java:226)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:540)
        at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:219)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:42)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:52)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
        at org.eclipse.jetty.server.Server.doStart(Server.java:258)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1233)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1156)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:477)
        at org.eclipse.jetty.start.Main.start(Main.java:623)
        at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:273)
        at org.eclipse.jetty.start.Main.main(Main.java:81)
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1282)
        at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:283)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1194)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1090)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1003)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:5
11)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
        ... 45 more



解决方案:

 由:
     <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

     换为:
     <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
Java正则解析apache日志
package com.taobao.yunpeng;

import java.util.regex.*;

interface LogExample {

	public static final int NUM_FIELDS = 9;

	public static final String logEntryLine = "101.51.16.34 17725 - [19/Sep/2012:00:00:00 +0800] \"GET http://love.taobao.com/mai/guang/item.htm?spm=1001.1.1545.205.b3d96e&uid=135724856&iid=28210684&s_version=144&s_key=sr3_v2_1545__0_4__0_false_144_null_1&s_index=20&s_title=%C1%AC%D2%C2%C8%B9\" 200 10446 \"http://love.taobao.com/guang/tag_1545.htm?spm=1001.1.21545.1.148f3c&tab=0\" \"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1\"";
}

public class LogSearch implements LogExample {

	public static void main(String argv[]) {

		String logEntryPattern = "^([\\d.]+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})\\] \"(.+?)\" (\\d{3}) (\\d+) \"([^\"]+)\" \"([^\"]+)\"";

		System.out.println("Using RE Pattern:");
		System.out.println(logEntryPattern);

		System.out.println("Input line is:");
		System.out.println(logEntryLine);

		Pattern p = Pattern.compile(logEntryPattern);
		Matcher matcher = p.matcher(logEntryLine);
		if (!matcher.matches() || NUM_FIELDS != matcher.groupCount()) {
			System.err.println("Bad log entry (or problem with RE?):");
			System.err.println(logEntryLine);
			return;
		}
		System.out.println("IP Address: " + matcher.group(1));
		System.out.println("Date&Time: " + matcher.group(4));
		System.out.println("Request: " + matcher.group(5));
		System.out.println("Response: " + matcher.group(6));
		System.out.println("Bytes Sent: " + matcher.group(7));
		if (!matcher.group(8).equals("-"))
			System.out.println("Referer: " + matcher.group(8));
		System.out.println("Browser: " + matcher.group(9));
	}
}
scp无需密码记录
   
1. 运行
  #ssh-keygen -t rsa
  结果如下
  Generating public/private rsa key pair.
  Enter file in which to save the key (/home/.username/ssh/id_rsa):#回车
  Enter passphrase (empty for no passphrase):#回车
  Enter same passphrase again:#回车
  Your identification has been saved in /home/.username /.ssh/id_rsa.
  Your public key has been saved in /home/.username /.ssh/id_rsa.pub.
  The key fingerprint is:
  38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost
  Generating RSA keys:
  Key generation complete.
  会在用户目录~/.ssh/产生两个文件,id_rsa,id_rsa.pub

2.copy到远程机器auth
#! /bin/bash
scp /home/yunpeng/.ssh/id_rsa.pub yunpeng@dgdump113229.cm4:/home/yunpeng/.ssh/id_rsa.pub
ssh yunpeng@dgdump113229.cm4 "more /home/yunpeng/.ssh/id_rsa.pub >> /home/yunpeng/.ssh/authorized_keys"

3.远程机器拉文件到本地

#! /bin/bash

rm -rf result1.txt

scp yunpeng@dgdump113229.cm4:/home/admin/dgdump/logs/result1.txt /home/yunpeng

rm -rf result2.txt

scp yunpeng@dgdump113229.cm4:/home/admin/dgdump/logs/result2.txt /home/yunpeng
导入本地hive&join
hive> 
    > 
    > drop table t;
OK
Time taken: 12.204 seconds

##新建一张表
hive> CREATE TABLE t (id STRING)                                          
    > ROW FORMAT DELIMITED                                                
    > FIELDS TERMINATED BY '\t'                                           
    > STORED AS TEXTFILE;  
OK
Time taken: 3.323 seconds

##导入本地表数据
hive> LOAD DATA LOCAL INPATH '/home/yunpeng/r.txt' OVERWRITE INTO TABLE t;
Copying data from file:/home/yunpeng/r.txt
Loading data to table t
OK
Time taken: 23.103 seconds

##创建结果表2
hive> 
    > 
    > create table if not exists  t_yp_auction_color_info(
    >         
    >     auction_id string, 
    >     focus_color_info string,   
    >     pic_url string
    > ) partitioned by (pt string)
    >    row format delimited 
    >     fields terminated by '\t'
    >     lines terminated by '\n'
    >     STORED AS Sequencefile 
    >     location '/group/verticalmarket/taobao/hive/t_yp_auction_color_info/';
OK
Time taken: 4.134 seconds

##测试临时查询
hive> select id from t
    >     left outer join
    >     (
    >     select pict_url,auction_id from r_auction_auctions
    >     where  pt='20120909000000' and if_online='1'
    >     ) t1 on t.id=t1.auction_id limit 1;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Defaulting to jobconf value of: 30
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
Selecting distributed mode: Input Size (= 213852083283) is larger than hive.exec.mode.local.auto.inputbytes.max (= 134217728)
Starting Job = job_201208241319_2408585, Tracking URL = http://hdpjt:50030/jobdetails.jsp?jobid=job_201208241319_2408585
Kill Command = /home/hadoop/hadoop-current/bin/../bin/hadoop job  -Dmapred.job.tracker=hdpjt:9001 -kill job_201208241319_2408585
2012-09-10 16:43:00,737 Stage-1 map = 0%,  reduce = 0%
2012-09-10 16:43:22,534 Stage-1 map = 4%,  reduce = 0%

##kill掉job
hadoop job -Dmapred.job.tracker=hdpjt:9001 -kill job_201208241319_2408585


##再次跑任务
hive>                               
    > 
    > 
    > insert overwrite table  t_yp_auction_color_info partition(pt='20120910000000')
    > select auction_id,focus_color_info,t4.pic_url
    > from
    > (
    >     select id,pict_url,auction_id from t t1
    >     left outer join
    >     (
    >     select pict_url,auction_id from r_auction_auctions
    >     where  pt='20120909000000' and if_online='1'
    >     ) t2 on t1.id=t2.auction_id
    > ) t3
    > left outer join (
    > select pic_url,focus_color_info from t_da_img_auc where pt='20120909000000' group by pic_url,focus_color_info
    > )t4 on t4.pic_url=t3.pict_url;



                                               
JsonUpdateRequestHandler->UpdateRequestHandler
<requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler" />
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
======>
<requestHandler name="/update/json" class="solr.UpdateRequestHandler" />
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
solr-schema-自定义similarity配置
<similarity class="org.apache.solr.search.similarities.DocValuesPerFieldSimilarityFactory">
   <str name="boostField">score24h_dv,scorepopu_dv</str>
 </similarity> 
deflate的压缩和解压缩 http://www.avajava.com/tutorials/lessons/how-do-i-deflate-and-inflate-a-file.html
package test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;

public class DeflaterInflaterTest {

	public static void main(String[] args) throws Exception {

		FileInputStream fis = new FileInputStream("original.txt");
		FileOutputStream fos = new FileOutputStream("deflated.txt");
		DeflaterOutputStream dos = new DeflaterOutputStream(fos);

		doCopy(fis, dos); // copy original.txt to deflated.txt and compress it

		FileInputStream fis2 = new FileInputStream("deflated.txt");
		InflaterInputStream iis = new InflaterInputStream(fis2);
		FileOutputStream fos2 = new FileOutputStream("inflated.txt");

		doCopy(iis, fos2); // copy deflated.txt to inflated.txt and uncompress it

	}

	public static void doCopy(InputStream is, OutputStream os) throws Exception {
		int oneByte;
		while ((oneByte = is.read()) != -1) {
			os.write(oneByte);
		}
		os.close();
		is.close();
	}

}
Global site tag (gtag.js) - Google Analytics