

































































![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
驗證代理是否可以使用
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ip.txt 125.245.196.194:8080 203.110.240.22:80 77.240.82.6:80 71.5.68.4:3128 213.41.71.164:80 203.160.1.103:80 200.174.85.195:3128 60.28.194.172:80 148.233.159.58:8080 207.248.228.166:80 203.162.183.222:80 60.218.99.18:8080 203.160.1.112:80 193.93.112.33:8080 222.134.58.246:3128 121.57.4.17:8080 221.214.220.228:3128 20.132.16.22:80 121.12.249.207:3128 219.80.28.24:80 200.174.85.193:3128 public class FMultiPageEditor extends MultiPageEditorPart implements IResourceChangeListener{
/** * Creates page f of the multi-page editor, * which contains a text editor. */ void createHPage() { FEditorInput fInput = (FEditorInput) getEditorInput(); // h file IFile hFile = formInput.getHFile(); try { FileEditorInput fed = new FileEditorInput(hFile); htmlEditorPart = makeDefaultEditorFor("default" + ".html"); int index = addPage(htmlEditorPart, fed); setPageText(index, ""); setPageImage(index, fed.getImageDescriptor().createImage()); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), "r", null, e.getStatus()); } catch (Exception e) { e.printStackTrace(); } } private IEditorPart makeDefaultEditorFor(String name) { IEditorDescriptor editorDescriptor = getSite().getWorkbenchWindow() .getWorkbench().getEditorRegistry().getDefaultEditor(name); IEditorRegistry reg = WorkbenchPlugin.getDefault().getEditorRegistry(); EditorDescriptor desc = (EditorDescriptor) reg .findEditor(editorDescriptor.getId()); if (desc == null) return /*new TextEditor()*/null; IEditorPart part = null; try { if (desc.getClassName() != null && desc.getClassName().equals(getClass().getName())) { IEditorDescriptor[] editors = getSite().getWorkbenchWindow() .getWorkbench().getEditorRegistry().getEditors(name); for (int i = 0; i < editors.length; i++) { if (editors[i].getId() != editorDescriptor.getId()) { editorDescriptor = editors[i]; desc = (EditorDescriptor) reg .findEditor(editorDescriptor.getId()); if (desc.getClassName() != null && !desc.getClassName().equals( getClass().getName())) break; } } } if (desc.getClassName() == null || desc.getClassName().equals(getClass().getName())) part = new TextEditor(); else part = desc.createEditor(); } catch (CoreException e) { e.printStackTrace(); part = new TextEditor(); } return part; } public class HtmlEditor extends MultiPageEditorPart
public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { initResourceChangeListener(); } private IWorkspace getWorkspace() { return ((IFileEditorInput) getEditorInput()).getFile().getWorkspace(); } private void initResourceChangeListener() { IResourceChangeListener resourceChangeListener = new IResourceChangeListener() { public void resourceChanged(IResourceChangeEvent event) { handleResourceChange(event); } }; getWorkspace().addResourceChangeListener(resourceChangeListener); } private void handleResourceChange(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) { IFile file = ((IFileEditorInput) getEditorInput()).getFile(); // update editor } } /** *當更新或者刪除文件的時候 **/ public void resourceChanged(final IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) Display.getDefault().asyncExec(new Runnable() { public void run() { IResourceDelta rootDelta = event.getDelta(); if(rootDelta ==null){ return; } IResourceDelta htmlDelta = rootDelta.findMember(new Path("DefaultProject/t.html")); if(htmlDelta == null){ return; } } }); if (event.getType() == IResourceChangeEvent.PRE_CLOSE) { Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) getSourceEditor().getEditorInput()).getFile().getProject().equals(event.getResource())) { IEditorPart editorPart = pages[i].findEditor(getSourceEditor().getEditorInput()); pages[i].closeEditor(editorPart, true); } } } }); } }
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
import java.util.ArrayList;
public final class StringUtils {
&n... 閱讀全文
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> public static String convertRGB2HexString(RGB theRGB... 閱讀全文
為了便于管理,先引入個基礎類:
package algorithms;
一 插入排序/** * @author yovn * */ public abstract class Sorter<E extends Comparable<E>> { public abstract void sort(E[] array,int from ,int len); public final void sort(E[] array) { sort(array,0,array.length); } protected final void swap(E[] array,int from ,int to) { E tmp=array[from]; array[from]=array[to]; array[to]=tmp; } } 該算法在數據規模小的時候十分高效,該算法每次插入第K+1到前K個有序數組中一個合適位置,K從0開始到N-1,從而完成排序: package algorithms;
/** * @author yovn */ public class InsertSorter<E extends Comparable<E>> extends Sorter<E> { /* (non-Javadoc) * @see algorithms.Sorter#sort(E[], int, int) */ public void sort(E[] array, int from, int len) { E tmp=null; for(int i=from+1;i<from+len;i++) { tmp=array[i]; int j=i; for(;j>from;j--) { if(tmp.compareTo(array[j-1])<0) { array[j]=array[j-1]; } else break; } array[j]=tmp; } } } 二 冒泡排序 這可能是最簡單的排序算法了,算法思想是每次從數組末端開始比較相鄰兩元素,把第i小的冒泡到數組的第i個位置。i從0一直到N-1從而完成排序。(當然也可以從數組開始端開始比較相鄰兩元素,把第i大的冒泡到數組的第N-i個位置。i從0一直到N-1從而完成排序。) package algorithms;
/** * @author yovn * */ public class BubbleSorter<E extends Comparable<E>> extends Sorter<E> { private static boolean DWON=true; public final void bubble_down(E[] array, int from, int len) { for(int i=from;i<from+len;i++) { for(int j=from+len-1;j>i;j--) { if(array[j].compareTo(array[j-1])<0) { swap(array,j-1,j); } } } } public final void bubble_up(E[] array, int from, int len) { for(int i=from+len-1;i>=from;i--) { for(int j=from;j<i;j++) { if(array[j].compareTo(array[j+1])>0) { swap(array,j,j+1); } } } } @Override public void sort(E[] array, int from, int len) { if(DWON) { bubble_down(array,from,len); } else { bubble_up(array,from,len); } } } 三,選擇排序 選擇排序相對于冒泡來說,它不是每次發現逆序都交換,而是在找到全局第i小的時候記下該元素位置,最后跟第i個元素交換,從而保證數組最終的有序。 相對與插入排序來說,選擇排序每次選出的都是全局第i小的,不會調整前i個元素了。 package algorithms;
四 Shell排序/** * @author yovn * */ public class SelectSorter<E extends Comparable<E>> extends Sorter<E> { /* (non-Javadoc) * @see algorithms.Sorter#sort(E[], int, int) */ @Override public void sort(E[] array, int from, int len) { for(int i=0;i<len;i++) { int smallest=i; int j=i+from; for(;j<from+len;j++) { if(array[j].compareTo(array[smallest])<0) { smallest=j; } } swap(array,i,smallest); } } } Shell排序可以理解為插入排序的變種,它充分利用了插入排序的兩個特點: 1)當數據規模小的時候非常高效 2)當給定數據已經有序時的時間代價為O(N) 所以,Shell排序每次把數據分成若個小塊,來使用插入排序,而且之后在這若個小塊排好序的情況下把它們合成大一點的小塊,繼續使用插入排序,不停的合并小塊,知道最后成一個塊,并使用插入排序。 這里每次分成若干小塊是通過“增量” 來控制的,開始時增量交大,接近N/2,從而使得分割出來接近N/2個小塊,逐漸的減小“增量“最終到減小到1。 一直較好的增量序列是2^k-1,2^(k-1)-1,.....7,3,1,這樣可使Shell排序時間復雜度達到O(N^1.5) 所以我在實現Shell排序的時候采用該增量序列 package algorithms;
/** * @author yovn */ public class ShellSorter<E extends Comparable<E>> extends Sorter<E> { /* (non-Javadoc) * Our delta value choose 2^k-1,2^(k-1)-1, ![]() ![]() * complexity is O(n^1.5) * @see algorithms.Sorter#sort(E[], int, int) */ @Override public void sort(E[] array, int from, int len) { //1.calculate the first delta value; int value=1; while((value+1)*2<len) { value=(value+1)*2-1; } for(int delta=value;delta>=1;delta=(delta+1)/2-1) { for(int i=0;i<delta;i++) { modify_insert_sort(array,from+i,len-i,delta); } } } private final void modify_insert_sort(E[] array, int from, int len,int delta) { if(len<=1)return; E tmp=null; for(int i=from+delta;i<from+len;i+=delta) { tmp=array[i]; int j=i; for(;j>from;j-=delta) { if(tmp.compareTo(array[j-delta])<0) { array[j]=array[j-delta]; } else break; } array[j]=tmp; } } } 五 快速排序 快速排序是目前使用可能最廣泛的排序算法了。 一般分如下步驟: 1)選擇一個樞紐元素(有很對選法,我的實現里采用去中間元素的簡單方法) 2)使用該樞紐元素分割數組,使得比該元素小的元素在它的左邊,比它大的在右邊。并把樞紐元素放在合適的位置。 3)根據樞紐元素最后確定的位置,把數組分成三部分,左邊的,右邊的,樞紐元素自己,對左邊的,右邊的分別遞歸調用快速排序算法即可。 快速排序的核心在于分割算法,也可以說是最有技巧的部分。 package algorithms;
/** * @author yovn * */ public class QuickSorter<E extends Comparable<E>> extends Sorter<E> { /* (non-Javadoc) * @see algorithms.Sorter#sort(E[], int, int) */ @Override public void sort(E[] array, int from, int len) { q_sort(array,from,from+len-1); } private final void q_sort(E[] array, int from, int to) { if(to-from<1)return; int pivot=selectPivot(array,from,to); pivot=partion(array,from,to,pivot); q_sort(array,from,pivot-1); q_sort(array,pivot+1,to); } private int partion(E[] array, int from, int to, int pivot) { E tmp=array[pivot]; array[pivot]=array[to];//now to's position is available while(from!=to) { while(from<to&&array[from].compareTo(tmp)<=0)from++; if(from<to) { array[to]=array[from];//now from's position is available to--; } while(from<to&&array[to].compareTo(tmp)>=0)to--; if(from<to) { array[from]=array[to];//now to's position is available now from++; } } array[from]=tmp; return from; } private int selectPivot(E[] array, int from, int to) { return (from+to)/2; } } 還有歸并排序,堆排序,桶式排序,基數排序,下次在歸納。
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown table engine 'InnoDB'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) 原來我使用了綠色版的mysql,以前能用是因為my.ini文件已經存在了。而我重新ghost一下,就沒有這個文件了。 默認情況下配置文件可以放在以下目錄中(假定我的mysql安裝在d:\server\mysql下): 你可以用mysqld-nt.exe --install,把mysql添加到系統服務中,然后就可以了。 另外我發現原來可以指定表的engine
MySQL兩種表存儲結構MyISAM和InnoDBMySQL支持的兩種主要表存儲
格式MyISAM,InnoDB,上個月做個項目時,先使用了InnoDB,結果速度特別慢,1秒鐘只能插入10幾條。后來換成MyISAM格式,一秒鐘
插入上萬條。當時決定這兩個表的性能也差別太大了吧。后來自己推測,不應該差別這么慢,估計是寫的插入語句有問題,決定做個測試: 2、MyISAM用事務表: 3、InnoDB關閉AutoCommit,不用事務: |