{"generator":"Jekyll","link":[{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/feed.xml","rel":"self","type":"application\/atom+xml"}},{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/","rel":"alternate","type":"text\/html"}}],"updated":"2019-06-04T14:34:09+00:00","id":"https:\/\/ericlin1001.github.io\/feed.xml","title":"Eric\u2019s Blog","subtitle":"A personal technical blog.","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"entry":[{"title":"My Notes about C++","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/c++-tricks\/","rel":"alternate","type":"text\/html","title":"My Notes about C++"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/c++-tricks","content":"<h1 id=\"funny-tricks\">Funny tricks<\/h1>\n<p><code class=\"highlighter-rouge\">#define foo(...) printf(__VA_ARGS__);<\/code><\/p>\n\n<h1 id=\"unused\">Unused<\/h1>\n<p>The following snippet can be used to suppress the warning: unused-result.<\/p>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>template&lt;typename T&gt;\nvoid inline UNUSED(const T&amp;){} \n<\/code><\/pre><\/div><\/div>\n<p>It works well and do NOT affect any efficency in c++.<\/p>\n\n<h1 id=\"float-trap\">Float trap<\/h1>\n<h2 id=\"guess-whats-the-output-of-the-following-program\">Guess what\u2019s the output of the following program?<\/h2>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>int i=0;\nfor(double x=0;x&lt;10;x+=0.1){\n\ti++;\/\/we means to run i++ 100 times.\n}\n\/\/here, we thought i=100.\ncout&lt;&lt;i&lt;&lt;endl;\n<\/code><\/pre><\/div><\/div>\n<p>I run it in my linux computer, and it outputs <code class=\"highlighter-rouge\">101<\/code>, incredibly right?\nThe secret is, when adding 0.1 to a double variable <code class=\"highlighter-rouge\">x<\/code> 100 times, it could be x may not equal to 10 exactly.<\/p>\n\n<h2 id=\"run-the-following-code-to-investiage-what-happens-meanwhile\">Run the following code to investiage what happens meanwhile?<\/h2>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>int i=0;\nfor(double x=0;x&lt;10;x+=0.1){\n\ti++;\n\tcout&lt;&lt;i&lt;&lt;setprecision(20)&lt;&lt;x&lt;&lt;endl;\n}\ncout&lt;&lt;i&lt;&lt;endl;\n<\/code><\/pre><\/div><\/div>\n<p>In a nutshell, this is caused by accumulated float error.<\/p>\n\n<h1 id=\"sort-trap\">Sort trap<\/h1>\n<p>To use function <code class=\"highlighter-rouge\">sort<\/code> in <algorithm>, be careful of the user-defined compare function, which must be a Strick weak ordering, i.e. satisfying following conditions:<\/algorithm><\/p>\n<ul>\n  <li>irreflexive: For all a, comp(a,a)==false<\/li>\n  <li>antisymmetric: if comp(a,b)==true, then comp(b,a)==false<\/li>\n  <li>transitive: if comp(a,b)==true and comp(b,c)==true then comp(a,c)==true.<\/li>\n<\/ul>\n\n<p>There is a error case, extracted from a project. This program will crash. If you\u2019re interested, try to find out why!<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-cpp\" data-lang=\"cpp\"><span class=\"cp\">#include&lt;iostream&gt;\n#include&lt;cmath&gt;\n#include&lt;assert.h&gt;\n#include&lt;algorithm&gt;\n<\/span>\n<span class=\"cp\">#define INF 1E99\n<\/span><span class=\"k\">using<\/span> <span class=\"k\">namespace<\/span> <span class=\"n\">std<\/span><span class=\"p\">;<\/span>\n<span class=\"cp\">#define Max 101\n<\/span><span class=\"kt\">double<\/span> <span class=\"n\">y<\/span><span class=\"p\">[<\/span><span class=\"n\">Max<\/span><span class=\"p\">]<\/span><span class=\"o\">=<\/span><span class=\"p\">{<\/span><span class=\"mf\">999999999999999967336168804116691273849533185806555472917961779471295845921727862608739868455469056.000000<\/span><span class=\"p\">,<\/span><span class=\"mf\">999999999999999967336168804116691273849533185806555472917961779471295845921727862608739868455469056.000000<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.268631<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.223484<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.213363<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.203873<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.173396<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.171805<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.147066<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.135305<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.134438<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.093370<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.089916<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.081520<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.071410<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.054217<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.053685<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.051608<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.050618<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.050609<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.049449<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.047833<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.044590<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.044254<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.042998<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.041539<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.041011<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.038471<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.037384<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.037166<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.034642<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.034594<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.033551<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.033043<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.031951<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.031941<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.030951<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.030664<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.030208<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.029337<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.028936<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.028868<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.028305<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.027229<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.026968<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.026251<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.023536<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.023084<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.021200<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.021200<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.020107<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.020075<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.019947<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.018689<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.018667<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.018572<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.018344<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.017546<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.017215<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.016306<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.004288<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.015338<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.015144<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.014992<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.015005<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.012036<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.014128<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.014105<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.013985<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.013434<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.012250<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.013691<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011912<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011595<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011551<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011333<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011783<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.011277<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.010987<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.010294<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.010187<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.008622<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.008548<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.008067<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.008052<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.007850<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.007344<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.007235<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.007142<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.007064<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.006905<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.006130<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.005503<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.005436<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.005128<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.004613<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.004352<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.004099<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.003833<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.002572<\/span><span class=\"p\">,<\/span><span class=\"mf\">0.013791<\/span><span class=\"p\">};<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">x<\/span><span class=\"p\">[<\/span><span class=\"n\">Max<\/span><span class=\"o\">+<\/span><span class=\"mi\">50<\/span><span class=\"p\">];<\/span>\n<span class=\"kt\">bool<\/span> <span class=\"n\">cmp<\/span><span class=\"p\">(<\/span><span class=\"k\">const<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">a<\/span><span class=\"p\">,<\/span><span class=\"k\">const<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">b<\/span><span class=\"p\">){<\/span>\n\t<span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"o\">!<\/span><span class=\"p\">(<\/span><span class=\"n\">a<\/span><span class=\"o\">&gt;=<\/span><span class=\"mi\">0<\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"n\">a<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Max<\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"n\">b<\/span><span class=\"o\">&gt;=<\/span><span class=\"mi\">0<\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"n\">b<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Max<\/span><span class=\"p\">))<\/span><span class=\"n\">assert<\/span><span class=\"p\">(<\/span><span class=\"nb\">false<\/span><span class=\"p\">);<\/span>\n\t<span class=\"c1\">\/\/return false;\n<\/span>\t<span class=\"k\">return<\/span> <span class=\"n\">y<\/span><span class=\"p\">[<\/span><span class=\"n\">a<\/span><span class=\"p\">]<\/span><span class=\"o\">&gt;<\/span><span class=\"n\">y<\/span><span class=\"p\">[<\/span><span class=\"n\">b<\/span><span class=\"p\">];<\/span>\n<span class=\"c1\">\/\/\tif(y[a]&gt;=y[b])return true;\n\/\/\treturn false;\n<\/span><span class=\"p\">}<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">main<\/span><span class=\"p\">(){<\/span>\n\t<span class=\"c1\">\/\/int x[5]={0,1,2,3,4};\n<\/span>\t<span class=\"kt\">int<\/span> <span class=\"n\">n<\/span><span class=\"o\">=<\/span><span class=\"n\">Max<\/span><span class=\"p\">;<\/span>\n\t<span class=\"k\">for<\/span><span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span><span class=\"o\">=<\/span><span class=\"mi\">0<\/span><span class=\"p\">;<\/span><span class=\"n\">i<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">n<\/span><span class=\"p\">;<\/span><span class=\"n\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">){<\/span>\n\t\t<span class=\"n\">x<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]<\/span><span class=\"o\">=<\/span><span class=\"n\">i<\/span><span class=\"p\">;<\/span>\n\t<span class=\"p\">}<\/span>\n\t<span class=\"n\">sort<\/span><span class=\"p\">(<\/span><span class=\"n\">x<\/span><span class=\"p\">,<\/span><span class=\"n\">x<\/span><span class=\"o\">+<\/span><span class=\"n\">n<\/span><span class=\"p\">,<\/span><span class=\"n\">cmp<\/span><span class=\"p\">);<\/span>\n\t<span class=\"k\">for<\/span><span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span><span class=\"o\">=<\/span><span class=\"mi\">0<\/span><span class=\"p\">;<\/span><span class=\"n\">i<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">Max<\/span><span class=\"p\">;<\/span><span class=\"n\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">){<\/span>\n\t\t<span class=\"n\">cout<\/span><span class=\"o\">&lt;&lt;<\/span><span class=\"n\">y<\/span><span class=\"p\">[<\/span><span class=\"n\">x<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]]<\/span><span class=\"o\">&lt;&lt;<\/span><span class=\"s\">\",\"<\/span><span class=\"p\">;<\/span>\n\t<span class=\"p\">}<\/span>\n\t<span class=\"n\">cout<\/span><span class=\"o\">&lt;&lt;<\/span><span class=\"s\">\"Hello\"<\/span><span class=\"o\">&lt;&lt;<\/span><span class=\"n\">endl<\/span><span class=\"p\">;<\/span>\n\t<span class=\"k\">return<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Funny tricks #define foo(...) printf(__VA_ARGS__);"},{"title":"common sense","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/common-sense\/","rel":"alternate","type":"text\/html","title":"common sense"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/common-sense","content":"<h1 id=\"foot---inch---centimeter\">Foot &lt;-&gt; Inch &lt;-&gt; Centimeter<\/h1>\n\n<table>\n  <thead>\n    <tr>\n      <th style=\"text-align: center\">abbr.<\/th>\n      <th style=\"text-align: center\">single<\/th>\n      <th style=\"text-align: center\">plural<\/th>\n      <th style=\"text-align: center\">Chinese<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td style=\"text-align: center\">ft<\/td>\n      <td style=\"text-align: center\">foot<\/td>\n      <td style=\"text-align: center\">feet<\/td>\n      <td style=\"text-align: center\">\u82f1\u5c3a<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">in<\/td>\n      <td style=\"text-align: center\">inch<\/td>\n      <td style=\"text-align: center\">inches<\/td>\n      <td style=\"text-align: center\">\u82f1\u5bf8<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">cm<\/td>\n      <td style=\"text-align: center\">centimeter<\/td>\n      <td style=\"text-align: center\">centimeters<\/td>\n      <td style=\"text-align: center\">\u5398\u7c73<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<h2 id=\"conversion\">Conversion<\/h2>\n\n<table>\n  <tbody>\n    <tr>\n      <td>1ft<\/td>\n      <td>30.48cm<\/td>\n    <\/tr>\n    <tr>\n      <td>1in<\/td>\n      <td>2.54cm<\/td>\n    <\/tr>\n    <tr>\n      <td>1ft<\/td>\n      <td>12in<\/td>\n    <\/tr>\n    <tr>\n      <td>1\u5c3a<\/td>\n      <td>30.3cm<\/td>\n    <\/tr>\n    <tr>\n      <td>1\u5bf8<\/td>\n      <td>3.03cm<\/td>\n    <\/tr>\n    <tr>\n      <td>1\u5c3a<\/td>\n      <td>10\u5bf8<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Foot &lt;-&gt; Inch &lt;-&gt; Centimeter"},{"title":"famous algorithm","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/famous-algorithm\/","rel":"alternate","type":"text\/html","title":"famous algorithm"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/famous-algorithm","content":"<h1 id=\"median-of-medians\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Median_of_medians\">Median of medians<\/a><\/h1>\n<p>The optimal algorithm selecting kth largest element,with linear time complexity <script type=\"math\/tex\">O(n)<\/script><br \/>\nReference: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Median_of_medians\">https:\/\/en.wikipedia.org\/wiki\/Median_of_medians<\/a><\/p>\n\n<p>Pseudocode:<\/p>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>function select(list, left, right, n)\n\tif left = right\n\t\treturn left\n\tloop\n\t\tpivotIndex := pivot(list, left, right)\n\t\tpivotIndex := partition(list, left, right, pivotIndex)\n\t\tif n = pivotIndex\n\t\t\treturn n\n\t\telse if n &lt; pivotIndex\n\t\t\tright := pivotIndex - 1\n\t\telse\n\t\t\tleft := pivotIndex + 1\n\nfunction partition(list, left, right, pivotIndex)\n\tpivotValue := list[pivotIndex]\n\tswap list[pivotIndex] and list[right]  \/\/ Move pivot to end\n\tstoreIndex := left\n\tfor i from left to right-1\n\t\tif list[i] &lt; pivotValue\n\t\t\tswap list[storeIndex] and list[i]\n\t\t\tincrement storeIndex\n\tswap list[right] and list[storeIndex]  \/\/ Move pivot to its final place\n\treturn storeIndex\n\n\nfunction pivot(list, left, right)\n\t\/\/ for 5 or less elements just get median\n\tif right - left &lt; 5:\n\t\treturn partition5(list, left, right)\n\t\/\/ otherwise move the medians of five-element subgroups to the first n\/5 positions\n\tfor i from left to right in steps of 5\n\t\t\/\/ get the median of the ith five-element subgroup\n\t\tsubRight := i + 4\n\t\tif subRight &gt; right:\n\t\t\tsubRight := right\n\n\t\tmedian5 := partition5(list, i, subRight)\n\t\tswap list[median5] and list[left + floor((i - left)\/5)]\n\n\t\/\/ compute the median of the n\/5 medians-of-five\n\treturn select(list, left, left + ceil((right - left) \/ 5) - 1, left + (right - left)\/10)\n\nfunction partition5(list,left,right)\n\t\/\/based on insertion sort.\n\tmid=floor((left+right)\/2)\n\tfor i from left+1 to right\n\t\tj=i;\n\t\twhile j&gt;0 &amp;&amp; list[j-1]&gt;list[j]\n\t\t\tswap(list,j-1,j);\n\t\t\tj=j-1\n\treturn mid\n<\/code><\/pre><\/div><\/div>\n\n<h1 id=\"heapsort\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Heapsort\">HeapSort<\/a><\/h1>\n<p>Reference: https:\/\/en.wikipedia.org\/wiki\/Heapsort<\/p>\n\n<p>Pseudocode:<\/p>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Parent(i)     = floor((i-1) \/ 2)\niLeftChild(i)  = 2*i + 1\niRightChild(i) = 2*i + 2\n\nprocedure heapsort(a, count) is\n\tinput: an unordered array a of length count\n\n\t(Build the heap in array a so that largest value is at the root)\n\theapify(a, count)\n\n\t(The following loop maintains the invariants that a[0:end] is a heap and every element\n\t beyond end is greater than everything before it (so a[end:count] is in sorted order))\n\tend \u2190 count - 1\n\twhile end &gt; 0 do\n\t\t(a[0] is the root and largest value. The swap moves it in front of the sorted elements.)\n\t\tswap(a[end], a[0])\n\t\t(the heap size is reduced by one)\n\t\tend \u2190 end - 1\n\t\t(the swap ruined the heap property, so restore it)\n\t\tsiftDown(a, 0, end)\n\n(Put elements of 'a' in heap order, in-place)\nprocedure heapify(a, count) is\n\t(start is assigned the index in 'a' of the last parent node)\n\t(the last element in a 0-based array is at index count-1; find the parent of that element)\n\tstart \u2190 iParent(count-1)\n\n\twhile start \u2265 0 do\n\t\t(sift down the node at index 'start' to the proper place such that all nodes below\n\t\t the start index are in heap order)\n\t\tsiftDown(a, start, count - 1)\n\t\t(go to the next parent node)\n\t\tstart \u2190 start - 1\n\t(after sifting down the root all nodes\/elements are in heap order)\n\n(Repair the heap whose root element is at index 'start', assuming the heaps rooted at its children are valid)\nprocedure siftDown(a, start, end) is\n\troot \u2190 start\n\n\twhile iLeftChild(root) \u2264 end do    (While the root has at least one child)\n\t\tchild \u2190 iLeftChild(root)   (Left child of root)\n\t\tswap \u2190 root                (Keeps track of child to swap with)\n\n\t\tif a[swap] &lt; a[child]\n\t\t\tswap \u2190 child\n\t\t(If there is a right child and that child is greater)\n\t\tif child+1 \u2264 end and a[swap] &lt; a[child+1]\n\t\t\tswap \u2190 child + 1\n\t\tif swap = root\n\t\t\t(The root holds the largest element. Since we assume the heaps rooted at the\n\t\t\t children are valid, this means that we are done.)\n\t\t\treturn\n\t\telse\n\t\t\tswap(a[root], a[swap])\n\t\t\troot \u2190 swap            (repeat to continue sifting down the child now)\n<\/code><\/pre><\/div><\/div>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Median of medians The optimal algorithm selecting kth largest element,with linear time complexity Reference: https:\/\/en.wikipedia.org\/wiki\/Median_of_medians"},{"title":"Linux Management","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/linux-management\/","rel":"alternate","type":"text\/html","title":"Linux Management"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/linux-management","content":"<h1 id=\"whats-ctrl-c-ctrl-d\">What\u2019s Ctrl-C, Ctrl-D\u2026<\/h1>\n<hr \/>\n\n<p>In Linux:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th style=\"text-align: center\">Shortcut keys<\/th>\n      <th style=\"text-align: left\">Description<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-c<\/td>\n      <td style=\"text-align: left\">Send SIGINT signal to all process in foreground process group, always used to terminate a running program.<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-z<\/td>\n      <td style=\"text-align: left\">Send SIGTSTP  signal to all process in foreground process group, used to suspend a process.<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-d<\/td>\n      <td style=\"text-align: left\">Represents EOF.<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-\\<\/td>\n      <td style=\"text-align: left\">Send SIGQUIT to all process in foreground process group, used to terminate a process and produces a core dump file.<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<h1 id=\"keys-its-function\">Keys &amp;Its Function<\/h1>\n\n<table>\n  <thead>\n    <tr>\n      <th style=\"text-align: center\">Key<\/th>\n      <th style=\"text-align: left\">Function<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-c<\/td>\n      <td style=\"text-align: left\">Kill foreground process<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-z<\/td>\n      <td style=\"text-align: left\">Suspend foreground process<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-d<\/td>\n      <td style=\"text-align: left\">Terminate input, or exit shell<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-s<\/td>\n      <td style=\"text-align: left\">Suspend output<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-q<\/td>\n      <td style=\"text-align: left\">Resume output<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-o<\/td>\n      <td style=\"text-align: left\">Discard output<\/td>\n    <\/tr>\n    <tr>\n      <td style=\"text-align: center\">Ctrl-l<\/td>\n      <td style=\"text-align: left\">Clear screen<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"What\u2019s Ctrl-C, Ctrl-D\u2026"},{"title":"Math Related Things","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/math-related-things\/","rel":"alternate","type":"text\/html","title":"Math Related Things"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/math-related-things","content":"<h1 id=\"relation-between-density-and-histrogram-funcion\">Relation between Density and Histrogram funcion<\/h1>\n<p>Given <script type=\"math\/tex\">X \\sim f(x)<\/script> , where <script type=\"math\/tex\">f(x)<\/script> is the density function of <script type=\"math\/tex\">X<\/script> , and the width of each bin <script type=\"math\/tex\">W<\/script> , we can produce histrogram function <script type=\"math\/tex\">H(x)<\/script> , by \nsampling variable <script type=\"math\/tex\">X<\/script>  <script type=\"math\/tex\">N<\/script> times, resulting in <script type=\"math\/tex\">x1,x2...xN<\/script> .<br \/>\nThen, there\u2019s a conclusion: <script type=\"math\/tex\">H(x) \\approx f(x) \\times W \\times N<\/script> .<\/p>\n\n<h1 id=\"how-to-generate-a-random-direction\">How to generate a random direction?<\/h1>\n<p>When doing academic research, I need to generate a random direction, i.e. it points to any direciton in an equalled probability. At first, I thought, assign each dimension a random value(Uniform Distribution) is sufficient. After second thought, I find out it\u2019s not correct. <br \/>\nLet\u2019s say, a N-dimension direction <script type=\"math\/tex\">D<\/script> is defined by <script type=\"math\/tex\">D = (X_1, X_2...X_N)<\/script> .<\/p>\n\n<ul>\n  <li>\n    <p>If we just let <script type=\"math\/tex\">X_i<\/script> be a random variable, i.e. <script type=\"math\/tex\">\\forall i=1,2..N, X_i \\sim U(-1,-1)<\/script> , <script type=\"math\/tex\">D<\/script> is <em>NOT<\/em> a random direction.<\/p>\n  <\/li>\n  <li>\n    <p>To generate a truly random direction, we can let <script type=\"math\/tex\">\\forall i=1,2..N, X_i \\sim N(0,1)<\/script> , where N(0,1) is  a Normal Distribution with <script type=\"math\/tex\">u=0<\/script> , <script type=\"math\/tex\">\\theta=1<\/script> , at this time, <script type=\"math\/tex\">D = (X_1, X_2...X_N)<\/script> points to every direction in the same probability. And length of <script type=\"math\/tex\">D<\/script> , <script type=\"math\/tex\">R = \\sqrt{(X_1^2 + X_2^2 + ... + X_N^2)} \\sim N(0,1)<\/script><\/p>\n  <\/li>\n<\/ul>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Relation between Density and Histrogram funcion Given , where is the density function of , and the width of each bin , we can produce histrogram function , by sampling variable times, resulting in . Then, there\u2019s a conclusion: ."},{"title":"Useful Tools I Use","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/useful-tools-i-use\/","rel":"alternate","type":"text\/html","title":"Useful Tools I Use"}},"published":"2017-04-07T00:00:00+00:00","updated":"2017-04-07T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/useful-tools-i-use","content":"<h1 id=\"k2pdfopt\"><a href=\"http:\/\/www.willus.com\/k2pdfopt\/\">k2pdfopt<\/a><\/h1>\n<p>A tool, transforms pdf files to easy-read pdf in mobile device.\nK2pdfopt optimizes PDF\/DJVU files for mobile e-readers (e.g. the Kindle) and smartphones. It works well on multi-column PDF\/DJVU files and can re-flow text even on scanned PDF files. It can also be used as a general PDF copying\/cropping\/re-sizing\/OCR-ing manipulation tool.<\/p>\n\n<h1 id=\"coherent-pdf\"><a href=\"http:\/\/community.coherentpdf.com\">Coherent PDF<\/a><\/h1>\n<p>The Coherent PDF Command Line Tools allow you to manipulate existing PDF files in a variety of ways. E.g.:<\/p>\n<ul>\n  <li>Merge PDF files together, or split them apart<\/li>\n  <li>Encrypt and decrypt<\/li>\n  <li>Scale, crop and rotate pages<\/li>\n  <li>Read and set document info and metadata<\/li>\n  <li>Copy, add or remove bookmarks<\/li>\n  <li>Stamp logos, text, dates, page numbers<\/li>\n  <li>Add or remove attachments<\/li>\n  <li>Losslessly compress PDF files<\/li>\n<\/ul>\n\n<p>GNU Aspell is a Free and Open Source spell checker.<\/p>\n\n<h2 id=\"basic-usage\">Basic usage<\/h2>\n<ol>\n  <li>For any files: <code class=\"highlighter-rouge\">aspell -c [file]<\/code><\/li>\n  <li>For tex files: <code class=\"highlighter-rouge\">aspell -t -c [file]<\/code><\/li>\n<\/ol>\n\n<h1 id=\"htop\"><a href=\"http:\/\/hisham.hm\/htop\/\">htop<\/a><\/h1>\n<p>An interactive text-mode process viewer for Unix systems.<\/p>\n\n<h2 id=\"basic-usage-1\">Basic usage<\/h2>\n<ol>\n  <li>Run it: <code class=\"highlighter-rouge\">htop<\/code><\/li>\n  <li>Sort by a column: <code class=\"highlighter-rouge\">&lt;F6&gt;<\/code><\/li>\n  <li>Filter to locate your interested process: <code class=\"highlighter-rouge\">&lt;F4&gt;<\/code><\/li>\n  <li>Setup all things: <code class=\"highlighter-rouge\">&lt;F2&gt;<\/code><\/li>\n<\/ol>\n\n<h1 id=\"autoitfor-windows\"><a href=\"https:\/\/www.autoitscript.com\/site\/autoit\/\">AutoIt<\/a>(For windows)<\/h1>\n<p>AutoIt is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.<\/p>\n\n<h2 id=\"what-i-use-it-for\">What I use it for?<\/h2>\n<ol>\n  <li>Game automation.<\/li>\n  <li>Auto fillout web form.<\/li>\n<\/ol>\n\n<h1 id=\"online-markdown-editor-dillinger\">Online markdown editor: <a href=\"http:\/\/dillinger.io\">dillinger<\/a><\/h1>\n<p>Well, a perfect online markdown editor, except not supporting chinese.<\/p>\n\n<h1 id=\"expect\"><a href=\"http:\/\/expect.sourceforge.net\/\">Expect<\/a><\/h1>\n<p>Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect is also useful for testing these same applications. And by adding Tk, you can also wrap interactive applications in X11 GUIs.<\/p>\n\n<h2 id=\"my-example\">My example<\/h2>\n<div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>#!\/usr\/bin\/expect\nset timeout 2\n# This line login your server\nspawn ssh [your-server]\n\n# After login your sever, run a script, which need a sudo priviledge\nexpect \"$\"\nsend \".\/startRun.sh\\r\"\n\n# Send the password.\nexpect \"Password:\"\nsend \"[yourPassword]\\r\"\n\nexpect \"$\"\nsend \"cd ~\/Projects\\r\"\ninteract\n#expect eof\n<\/code><\/pre><\/div><\/div>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"k2pdfopt A tool, transforms pdf files to easy-read pdf in mobile device. K2pdfopt optimizes PDF\/DJVU files for mobile e-readers (e.g. the Kindle) and smartphones. It works well on multi-column PDF\/DJVU files and can re-flow text even on scanned PDF files. It can also be used as a general PDF copying\/cropping\/re-sizing\/OCR-ing manipulation tool."},{"title":"STL container","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/stl-container-notes\/","rel":"alternate","type":"text\/html","title":"STL container"}},"published":"2017-04-06T00:00:00+00:00","updated":"2017-04-06T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/stl-container-notes","content":"<h1 id=\"sequence-container\">Sequence container:<\/h1>\n<ol>\n  <li>\n    <p>array<br \/>\nJust like int a[], it\u2019s a simple wrapper.<\/p>\n  <\/li>\n  <li>vector\n    <ul>\n      <li>front()<\/li>\n      <li>back()<\/li>\n      <li>operator[]<\/li>\n      <li>push_back()<\/li>\n      <li>pop_back();<\/li>\n    <\/ul>\n  <\/li>\n  <li>deque\n    <ul>\n      <li>front()<\/li>\n      <li>back()<\/li>\n      <li>operator[]<\/li>\n      <li>push_front()<\/li>\n      <li>push_back()<\/li>\n      <li>pop_front();<\/li>\n      <li>pop_back();<\/li>\n    <\/ul>\n  <\/li>\n  <li>set\n    <ul>\n      <li>insert()<\/li>\n      <li>find()<\/li>\n      <li>erase();<\/li>\n    <\/ul>\n  <\/li>\n<\/ol>\n\n<h1 id=\"non-sequence-container\">Non-sequence container:<\/h1>\n\n<ol>\n  <li>list\nDoubly-linked lists.\n    <ul>\n      <li>front()<\/li>\n      <li>back()<\/li>\n      <li>push_front()<\/li>\n      <li>push_back()<\/li>\n      <li>pop_front();<\/li>\n      <li>pop_back();<\/li>\n    <\/ul>\n  <\/li>\n  <li>map\n    <ul>\n      <li>opertor[]<\/li>\n      <li>insert(pair())<\/li>\n      <li>operator[]<\/li>\n      <li>find()<\/li>\n    <\/ul>\n  <\/li>\n<\/ol>\n\n<h1 id=\"adaptor\">Adaptor<\/h1>\n\n<ol>\n  <li>stack\n    <ul>\n      <li>top()<\/li>\n      <li>push();<\/li>\n      <li>pop()<\/li>\n    <\/ul>\n  <\/li>\n  <li>priority_queue(underlying containter: vector)\n    <ul>\n      <li>top()<\/li>\n      <li>push();<\/li>\n      <li>pop()<\/li>\n    <\/ul>\n  <\/li>\n  <li>queue (underlying containter: deque)\n    <ul>\n      <li>front()<\/li>\n      <li>back();<\/li>\n      <li>push()<\/li>\n      <li>pop();<\/li>\n    <\/ul>\n  <\/li>\n<\/ol>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Sequence container: array Just like int a[], it\u2019s a simple wrapper."},{"title":"Prove O(log(a+b))=O(log(a)+log(b))","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/prove-log-a-b\/","rel":"alternate","type":"text\/html","title":"Prove O(log(a+b))=O(log(a)+log(b))"}},"published":"2017-04-05T00:00:00+00:00","updated":"2017-04-05T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/prove-log-a--b","content":"<p>To prove: <script type=\"math\/tex\">\\mathbf{O}(\\log{(a+b)})=\\mathbf{O}(\\log{a}+\\log{b})<\/script><br \/>\nWe need to have:<br \/>\n<script type=\"math\/tex\">k_1\\log{(a+b)} \\le \\log{a}+\\log{b} \\le k_2\\log{(a+b)}<\/script><br \/>\nis equivalent to:<br \/>\n<script type=\"math\/tex\">k_1\\log{(a+b)} \\le \\log{(a*b)} \\le k_2\\log{(a+b)}<\/script><\/p>\n\n<p>Let e\u2019s exponent of both side, we have:<br \/>\n<script type=\"math\/tex\">(a+b)^{k_1} \\le a*b \\le (a+b)^{k_2}<\/script><\/p>\n\n<p>Let <script type=\"math\/tex\">k_1=1, A=1, B = 1<\/script>, we know <script type=\"math\/tex\">\\forall{a>A}, \\forall{b>B}<\/script> and  <script type=\"math\/tex\">(a+b) \\le a*b<\/script> is always satisfied.<\/p>\n\n<p>Let <script type=\"math\/tex\">k_2=2, A=1, B = 1<\/script>, we know <script type=\"math\/tex\">\\forall{a>A}, \\forall{b>B}<\/script> <script type=\"math\/tex\">a*b \\le (a+b)^2 \\iff a*b \\le a^2+2ab+b^2 \\iff   0 \\le a^2+ab+b^2<\/script> is always satisfied.<\/p>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"To prove: We need to have: is equivalent to:"},{"title":"About Ordering Theory","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/about-ordering-theory\/","rel":"alternate","type":"text\/html","title":"About Ordering Theory"}},"published":"2017-03-15T00:00:00+00:00","updated":"2017-03-15T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/about-ordering-theory","content":"<h1 id=\"properties-of-various-ordering\">Properties of various ordering<\/h1>\n\n<ol>\n  <li>Preorder\n    <ul>\n      <li>reflexive<\/li>\n      <li>transitive<\/li>\n    <\/ul>\n  <\/li>\n  <li>Partial order(non-strict)\n    <ul>\n      <li>reflexive<\/li>\n      <li>antisymmetric<\/li>\n      <li>transitive.<\/li>\n    <\/ul>\n  <\/li>\n  <li>Partial order(strict)\n    <ul>\n      <li>irreflexive<\/li>\n      <li>antisymmetric<\/li>\n      <li>transitive.<\/li>\n    <\/ul>\n  <\/li>\n  <li>Total order\n    <ul>\n      <li>total<\/li>\n      <li>antisymmetric<\/li>\n      <li>transivtive<\/li>\n    <\/ul>\n  <\/li>\n  <li>Strict weak orderings(strict partial order and transitivityOfIncomparability)\n    <ul>\n      <li>irreflexive<\/li>\n      <li>antisymmetric<\/li>\n      <li>transitivity<\/li>\n      <li>transitivityOfIncomparability<\/li>\n    <\/ul>\n  <\/li>\n  <li>Well-order(total order and every non-empty subset of S has a leat element)\n    <ul>\n      <li>total<\/li>\n      <li>antisymmetric<\/li>\n      <li>transivtive<\/li>\n      <li>leastOfSubset<\/li>\n    <\/ul>\n  <\/li>\n<\/ol>\n\n<h1 id=\"some-definition\">Some definition<\/h1>\n<p>Suppose P is a set and R(&lt;=) is a relation on P, then we have following definition, for all a, b, c in P:<\/p>\n<ol>\n  <li>reflexive: <code class=\"highlighter-rouge\">a&lt;=a <\/code><\/li>\n  <li>antisymmetric: <code class=\"highlighter-rouge\">if a&lt;=b and b&lt;=a then a=b(if a&lt;=b and a!=b then b&lt;=a must NOT hold)<\/code><\/li>\n  <li>transitivity: <code class=\"highlighter-rouge\">if a&lt;=b and b&lt;=c then a&lt;=c<\/code><\/li>\n  <li>totality: <code class=\"highlighter-rouge\">a&lt;=b or b&lt;=a (it deduces reflexive)<\/code><\/li>\n  <li>comparability(a, b): <code class=\"highlighter-rouge\">a&lt;b or a&lt;b<\/code><\/li>\n  <li>incomparability(a, b): <code class=\"highlighter-rouge\">neither a&lt;b nor b&lt;a<\/code><\/li>\n  <li>transitivityOfIncomparability: <code class=\"highlighter-rouge\">for all a, b ,c, if incomparability(a,b) and incomparability(b,c), then incomparability(a,c)<\/code><\/li>\n  <li>leastOfSubset: <code class=\"highlighter-rouge\">for all non-empty subset A of S, there exits a least element is A<\/code><\/li>\n  <li>irreflexive: <code class=\"highlighter-rouge\">not a&lt;=a<\/code><\/li>\n<\/ol>\n\n<h1 id=\"about-strict--non-strict\">About strict &lt;==&gt; non-strict<\/h1>\n<p>If <script type=\"math\/tex\">% <![CDATA[\n<= %]]><\/script> a non-strict partial order, then the corresponding non-strict partial order <script type=\"math\/tex\">% <![CDATA[\n<= %]]><\/script> is the reflexive closure given by: <script type=\"math\/tex\">% <![CDATA[\na<b %]]><\/script> if <script type=\"math\/tex\">% <![CDATA[\na<=b \\wedge a!=b %]]><\/script>.<\/p>\n\n<p>Conversely, strict ==&gt; non-strict: <script type=\"math\/tex\">% <![CDATA[\na<=b %]]><\/script> if <script type=\"math\/tex\">% <![CDATA[\na<b \\vee a=b %]]><\/script>.<\/p>\n\n<h1 id=\"reference\">Reference<\/h1>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Order_theory\">Order theory<\/a><\/p>\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_order_theory_topics\">List of order theory topics<\/a><\/p>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Properties of various ordering"},{"title":"How to onekey to restart a program in Windows","link":{"@attributes":{"href":"https:\/\/ericlin1001.github.io\/windows-how-to-restart-a-program\/","rel":"alternate","type":"text\/html","title":"How to onekey to restart a program in Windows"}},"published":"2017-03-08T00:00:00+00:00","updated":"2017-03-08T00:00:00+00:00","id":"https:\/\/ericlin1001.github.io\/windows-how-to-restart-a-program","content":"<p>Sometimes, I need to restart a program frequently. So I write this script, to easily quckly restart a program.\nHere are steps:<\/p>\n<ol>\n  <li>Save following code as <strong>restart.bat<\/strong>.\n    <div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>taskkill \/F \/IM  [process's name]\n.\/start.vbs\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>Save following code as <strong>start.vbs<\/strong>, in the same directory.\n    <div class=\"highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Set ws = CreateObject(\"WScript.Shell\")\nws.Run \"[the full path of exe file]\"\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>Just double click the <strong>restart.bat<\/strong><\/li>\n<\/ol>","author":{"name":"Eric Junhao Lin","email":"nameljh1001@gmail.com"},"summary":"Sometimes, I need to restart a program frequently. So I write this script, to easily quckly restart a program. Here are steps: Save following code as restart.bat. taskkill \/F \/IM [process's name] .\/start.vbs"}]}