<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Passion is like genius; a miracle.</title>
	<atom:link href="http://mkseo.pe.kr/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://mkseo.pe.kr/blog</link>
	<description></description>
	<lastBuildDate>Sun, 29 Aug 2010 05:04:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Cross Channel Scripting Attack, or XCS</title>
		<link>http://mkseo.pe.kr/blog/?p=2181</link>
		<comments>http://mkseo.pe.kr/blog/?p=2181#comments</comments>
		<pubDate>Sun, 29 Aug 2010 05:04:48 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2181</guid>
		<description><![CDATA[http://bojinov.org/professional/ccs2009-xcs-paper.pdf Attacks on consumer devices with web interfaces, e.g., NAS, by exploiting not-necessarily http protocol, e.g., FTP. As an example, an attacker loads crafted contents via FTP to victims&#8217;s web based control panel. When the admin visits the admin web app, it&#8217;s owned by the attacker.]]></description>
			<content:encoded><![CDATA[<p><a href="http://bojinov.org/professional/ccs2009-xcs-paper.pdf">http://bojinov.org/professional/ccs2009-xcs-paper.pdf</a></p>
<p>Attacks on consumer devices with web interfaces, e.g., NAS, by exploiting not-necessarily http protocol, e.g., FTP. As an example, an attacker loads crafted contents via FTP to victims&#8217;s web based control panel. When the admin visits the admin web app, it&#8217;s owned by the attacker.  </p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2181</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Boolean and Array &#8211; oh my!</title>
		<link>http://mkseo.pe.kr/blog/?p=2177</link>
		<comments>http://mkseo.pe.kr/blog/?p=2177#comments</comments>
		<pubDate>Wed, 28 Jul 2010 14:35:48 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2177</guid>
		<description><![CDATA[&#60;html&#62; &#60;script type=text/javascript&#62; document.write(&#34;Never use new Boolean.&#60;br&#62;&#34;); var b = new Boolean(&#34;false&#34;); if (b) { document.write(&#34;new Boolean is an Object and it's always true.&#60;br&#62;&#34;); } var oh_my_god = new Boolean(false) if (oh_my_god) { document.write(&#34;I told you. Object is true!&#60;br&#62;&#34;); } document.write(&#34;Also, stay away from new Array. Use [].&#60;br&#62;&#34;); function PrintArray(ar) { for (var i = [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript;">
&lt;html&gt;
&lt;script type=text/javascript&gt;
document.write(&quot;Never use new Boolean.&lt;br&gt;&quot;);
var b = new Boolean(&quot;false&quot;);
if (b) {
  document.write(&quot;new Boolean is an Object and it's always true.&lt;br&gt;&quot;);
}

var oh_my_god = new Boolean(false)
if (oh_my_god) {
  document.write(&quot;I told you. Object is true!&lt;br&gt;&quot;);
}

document.write(&quot;Also, stay away from new Array. Use [].&lt;br&gt;&quot;);
function PrintArray(ar) {
  for (var i = 0; i &lt; ar.length; ++i) {
    document.write(ar[i]);
  }
  document.write(&quot;&lt;br&gt;&quot;);
}

document.write(&quot;See. new Array is confusing.&lt;br&gt;&quot;);
PrintArray(new Array(10));
PrintArray(new Array(10, 20));

document.write(&quot;[elem1, elem2, ...] is obvious.&lt;br&gt;&quot;);
PrintArray([10]);
PrintArray([10, 20]);

&lt;/script&gt;
&lt;/html&gt;
</pre>
<p>Output:<br />
Never use new Boolean.<br />
new Boolean is an Object and it&#8217;s always true.<br />
I told you. Object is true!<br />
Also, stay away from new Array. Use [].<br />
See. new Array is confusing.<br />
undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined<br />
1020<br />
[elem1, elem2, ...] is obvious.<br />
10<br />
1020</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2177</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Javascript style guide</title>
		<link>http://mkseo.pe.kr/blog/?p=2174</link>
		<comments>http://mkseo.pe.kr/blog/?p=2174#comments</comments>
		<pubDate>Sun, 18 Jul 2010 05:30:39 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2174</guid>
		<description><![CDATA[Google Javascript style guide]]></description>
			<content:encoded><![CDATA[<p><a href="http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml">Google Javascript style guide</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2174</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript string and number</title>
		<link>http://mkseo.pe.kr/blog/?p=2171</link>
		<comments>http://mkseo.pe.kr/blog/?p=2171#comments</comments>
		<pubDate>Sat, 17 Jul 2010 06:54:40 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2171</guid>
		<description><![CDATA[&#8220;3&#8243; + 1 : &#8220;31&#8243; 1 + &#8220;3&#8243; : &#8220;13&#8243; But, &#8220;3&#8243;-1 : 2 &#8220;4&#8243; / 2 : 2 &#8220;2&#8243; * 2 : 4 &#8220;2&#8243; * &#8220;2&#8243;: 4]]></description>
			<content:encoded><![CDATA[<p>&#8220;3&#8243; + 1 : &#8220;31&#8243;<br />
1 + &#8220;3&#8243; : &#8220;13&#8243;</p>
<p>But,<br />
&#8220;3&#8243;-1 : 2<br />
&#8220;4&#8243; / 2 : 2<br />
&#8220;2&#8243; * 2 : 4<br />
&#8220;2&#8243; * &#8220;2&#8243;: 4</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2171</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Consistent Hashing</title>
		<link>http://mkseo.pe.kr/blog/?p=2169</link>
		<comments>http://mkseo.pe.kr/blog/?p=2169#comments</comments>
		<pubDate>Sat, 10 Jul 2010 13:50:35 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2169</guid>
		<description><![CDATA[http://en.wikipedia.org/wiki/Consistent_hashing A hash scheme that does not affects the entire hash table when a node is inserted or deleted. Machines are assigned to the circular nodes, and if a machine crashes, the keys in the crashed machine are moved to the following node in the circle. This is becoming really popular due to no SQL [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Consistent_hashing">http://en.wikipedia.org/wiki/Consistent_hashing</a></p>
<p>A hash scheme that does not affects the entire hash table when a node is inserted or deleted. Machines are assigned to the circular nodes, and if a  machine crashes, the keys in the crashed machine are moved to the following node in the circle. This is becoming really popular due to no SQL movements. </p>
<p>Used by distributed hash table (This is basically consistent hashing + node lookup algorithm) or amazon dynamo.</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2169</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gossip Protocol</title>
		<link>http://mkseo.pe.kr/blog/?p=2168</link>
		<comments>http://mkseo.pe.kr/blog/?p=2168#comments</comments>
		<pubDate>Sat, 10 Jul 2010 13:28:59 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2168</guid>
		<description><![CDATA[http://en.wikipedia.org/wiki/Gossip_protocol Pairewise periodic comm. based protocol to spread information which resembles the way how gossip spreads among ppl. This protocol assumes a faulty network and decentralized. Epidemic algorithms are the ones that adopt gossip protocol. Simple algorithm w/ cute name.]]></description>
			<content:encoded><![CDATA[<p><a href=http://en.wikipedia.org/wiki/Gossip_protocol>http://en.wikipedia.org/wiki/Gossip_protocol</a></p>
<p>Pairewise periodic comm. based protocol to spread information which resembles the way how gossip spreads among ppl. This protocol assumes a faulty network and decentralized. Epidemic algorithms are the ones that adopt gossip protocol. </p>
<p>Simple algorithm w/ cute name. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2168</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hash Teee(Merkle Tree)</title>
		<link>http://mkseo.pe.kr/blog/?p=2156</link>
		<comments>http://mkseo.pe.kr/blog/?p=2156#comments</comments>
		<pubDate>Fri, 18 Jun 2010 16:30:38 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2156</guid>
		<description><![CDATA[http://en.wikipedia.org/wiki/Hash_tree A tree where a parent contains hash of it&#8217;s children. Likewise, root has hash of all nodes. Useful for contents comparison without downloading entire tree or files. Also useful for file synchronization(e.g., Amazon Dynamo); detect missing files easily and sync.]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Hash_tree">http://en.wikipedia.org/wiki/Hash_tree</a></p>
<p>A tree where a parent contains hash of it&#8217;s children. Likewise, root has hash of all nodes. Useful for contents comparison without downloading entire tree or files. Also useful for file synchronization(e.g., Amazon Dynamo); detect missing files easily and sync. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2156</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interpolation search &#8211; beating the binary search</title>
		<link>http://mkseo.pe.kr/blog/?p=2154</link>
		<comments>http://mkseo.pe.kr/blog/?p=2154#comments</comments>
		<pubDate>Thu, 17 Jun 2010 14:27:17 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2154</guid>
		<description><![CDATA[http://sna-projects.com/blog/2010/06/beating-binary-search/ Instead of just picking the middle, guess the position where the target value appears, and compares the value in the position with the target. This obtains O(loglogN).]]></description>
			<content:encoded><![CDATA[<p><a href="http://sna-projects.com/blog/2010/06/beating-binary-search/">http://sna-projects.com/blog/2010/06/beating-binary-search/</a></p>
<p>Instead of just picking the middle, guess the position where the target value appears, and compares the value in the position with the target. This obtains O(loglogN).</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2154</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simhash (minhash)</title>
		<link>http://mkseo.pe.kr/blog/?p=2105</link>
		<comments>http://mkseo.pe.kr/blog/?p=2105#comments</comments>
		<pubDate>Mon, 17 May 2010 15:56:53 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2105</guid>
		<description><![CDATA[Near duplicate documents 를 찾는 식 중에 Jaccard coefficient라는 것이 있습니다. 어떤 문서내 term id들이 로 정의된다고 하면, Jaccard coefficient는 로 정의됩니다. 즉 term이 몇개나 겹치나하는 것이죠. 이런 term의 겹침을 계산하는 방법 중 하나는 locality sensitive hashiing입니다. 위키의 식 중 하나를 인용해서 설명하면 가 localitiy sensitive hashing입니다. 즉, 어떤 해싱 함수를 써서 a와 b를 변환한다음 [...]]]></description>
			<content:encoded><![CDATA[<p>Near duplicate documents 를 찾는 식 중에 Jaccard coefficient라는 것이 있습니다. 어떤 문서내 term id들이 <img src='http://s.wordpress.com/latex.php?latex=T%28d%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='T(d)' title='T(d)' class='latex' />로 정의된다고 하면, Jaccard coefficient는 <img src='http://s.wordpress.com/latex.php?latex=%28T%28d_1%29%20%5Ccap%20T%28d_2%29%29%20%2F%20%28T%28d_1%29%20%5Ccup%20T%28d_2%29%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(T(d_1) \cap T(d_2)) / (T(d_1) \cup T(d_2))' title='(T(d_1) \cap T(d_2)) / (T(d_1) \cup T(d_2))' class='latex' /> 로 정의됩니다. 즉 term이 몇개나 겹치나하는 것이죠.</p>
<p>이런 term의 겹침을 계산하는 방법 중 하나는 <a href="http://en.wikipedia.org/wiki/Locality_sensitive_hashing">locality sensitive hashiing</a>입니다. 위키의 식 중 하나를 인용해서 설명하면 <img src='http://s.wordpress.com/latex.php?latex=Pr%28h%28a%29%3Dh%28b%29%29%20%3D%20%5Cphi%28a%2Cb%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Pr(h(a)=h(b)) = \phi(a,b)' title='Pr(h(a)=h(b)) = \phi(a,b)' class='latex' /> 가 localitiy sensitive hashing입니다.  즉, 어떤 해싱 함수를 써서 a와 b를 변환한다음 그 값이 같을 확률은 a와 b의 유사도와 같다라는 것입니다.</p>
<p>여기까지가 introduction이고 본문은 <a href="http://knol.google.com/k/simple-simhashing">http://knol.google.com/k/simple-simhashing</a>에 있습니다. 혹은 Soumen Chakrabarti, Mining the web, Morgan Kaufmann에도 설명되어있습니다. (좋은 책입니다.)</p>
<p>knol의 글에서는 여러번반복해서 <img src='http://s.wordpress.com/latex.php?latex=%28%28T%28d_1%29%20%5Ccap%20T%28d_2%29%29%20%2F%20%28T%28d_1%29%20%5Ccup%20T%28d_2%29%29%29%5En&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='((T(d_1) \cap T(d_2)) / (T(d_1) \cup T(d_2)))^n' title='((T(d_1) \cap T(d_2)) / (T(d_1) \cup T(d_2)))^n' class='latex' />을 구한다고 되어있는데, Mining the web에서는 m개의 hash function을 찾은다음 그 중에서 k회 <img src='http://s.wordpress.com/latex.php?latex=h%28a%29%3Dh%28b%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='h(a)=h(b)' title='h(a)=h(b)' class='latex' />가 성립하면 <img src='http://s.wordpress.com/latex.php?latex=%5Cphi%28a%2Cb%29%3Dk%2Fm&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\phi(a,b)=k/m' title='\phi(a,b)=k/m' class='latex' />으로 계산하고 있습니다.</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Never, ever, swallow your stack trace.</title>
		<link>http://mkseo.pe.kr/blog/?p=2094</link>
		<comments>http://mkseo.pe.kr/blog/?p=2094#comments</comments>
		<pubDate>Tue, 11 May 2010 11:05:14 +0000</pubDate>
		<dc:creator>MKSeo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mkseo.pe.kr/blog/?p=2094</guid>
		<description><![CDATA[I came across this kind of exception handling code. import java.util.Observable; import java.util.Observer; public class Framework extends Observable { public void SendMessage(String msg) { setChanged(); try { notifyObservers(msg); } catch (RuntimeException re) { throw new RuntimeException(&#34;Something bad happend.&#34;); } } public static void main(String[] args) { Framework f = new Framework(); f.addObserver(new Observer() { @Override [...]]]></description>
			<content:encoded><![CDATA[<p>I came across this kind of exception handling code.</p>
<pre class="brush: java;">
import java.util.Observable;
import java.util.Observer;

public class Framework extends Observable {

  public void SendMessage(String msg) {
    setChanged();
    try {
      notifyObservers(msg);
    } catch (RuntimeException re) {
      throw new RuntimeException(&quot;Something bad happend.&quot;);
    }
  }

  public static void main(String[] args) {
    Framework f = new Framework();
    f.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        System.out.println(&quot;I am fine: &quot; + arg.toString());
      }
    });
    f.SendMessage(&quot;hello world&quot;);
  }
}
</pre>
<p>This is pretty common pattern. Right? You create a list of several instances and iterate over them to do something. Actually, that&#8217;s the beautiful pattern commonly used. </p>
<p>But, the code actually has a pitfall. Look at the error handling part. Can you identify it?</p>
<pre class="brush: java;">
try {
  notifyObservers(msg);
} catch(RuntimeException re) {
  throw new RuntimeException(&quot;Something bad happend.&quot;);
}
</pre>
<p>At first glance, this looks fine. It&#8217;s trying to tell something to the user. It&#8217;s not even swallowing the exception. But that&#8217;s not all for the framework developer. What happens if I add an innocent observer but got some error?</p>
<pre class="brush: java;">
  public static void main(String[] args) {
    Framework f = new Framework();
    f.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        System.out.println(&quot;I am fine: &quot; + arg.toString());
      }
    });
    f.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        throw new RuntimeException(&quot;I got an error: &quot; + arg.toString());
      }
    });
    f.SendMessage(&quot;hello world&quot;);
  }
</pre>
<p>Now the code spits out this:</p>
<p>Exception in thread &#8220;main&#8221; java.lang.RuntimeException: Something bad happend.<br />
	at Framework.SendMessage(Framework.java:11)<br />
	at Framework.main(Framework.java:29)</p>
<p>Seriously, that&#8217;s all I get. If this happens, I&#8217;m left with no clue but something went wrong. </p>
<p>Please do not swallow not just your exception but also your stack trace. How can I believe that all other observers are fine but it&#8217;s just my fault without any proof?</p>
<p>Keep the stack trace:</p>
<pre class="brush: java;">
try {
    notifyObservers(msg);
} catch (RuntimeException re) {
    throw new RuntimeException(&quot;Something bad happend.&quot;, re);
}
</pre>
<p>Now I get this awesome trace:</p>
<p>Exception in thread &#8220;main&#8221; java.lang.RuntimeException: Something bad happend.<br />
	at Framework.SendMessage(Framework.java:11)<br />
	at Framework.main(Framework.java:29)<br />
Caused by: java.lang.RuntimeException: I got an error: hello world<br />
	at Framework$2.update(Framework.java:26)<br />
	at java.util.Observable.notifyObservers(Unknown Source)<br />
	at Framework.SendMessage(Framework.java:9)<br />
	&#8230; 1 more</p>
]]></content:encoded>
			<wfw:commentRss>http://mkseo.pe.kr/blog/?feed=rss2&amp;p=2094</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
