<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4859738021814147401</id><updated>2011-12-26T19:09:47.723+09:00</updated><category term='ruby'/><category term='xml'/><category term='activerecord'/><category term='specification'/><category term='daily life'/><category term='data mining'/><category term='mysql'/><category term='java'/><category term='cygwin'/><category term='web'/><category term='encoding'/><category term='cluster'/><category term='data preprocess'/><category term='web-extraction'/><category term='msys'/><category term='latex'/><category term='swig'/><category term='synthetic data generation'/><category term='tomcat'/><category term='meta data'/><category term='chart'/><category term='gui'/><category term='mingw'/><category term='standard'/><category term='blogger'/><category term='opensource'/><category term='browser'/><category term='rails'/><category term='javassist'/><category term='ria'/><category term='eclipse'/><category term='linux-dev'/><category term='ubuntu'/><category term='persistent'/><category term='cpp'/><category term='database'/><title type='text'>Swimming in bits</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-3543927005651941033</id><published>2011-12-26T17:15:00.001+09:00</published><updated>2011-12-26T19:09:47.746+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='web-extraction'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><title type='text'>Nokogiri &amp; Char encodings</title><content type='html'>Personally, Nokogiri is the best library for ruby to look into html structures, especially css-selector support rocks. However, when dealing with i18n webpages, char encoding is always painful for beginners.&lt;br /&gt;&lt;br /&gt;for a reminder, mark this page:&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/2572396/nokogiri-open-uri-and-unicode-characters"&gt;http://stackoverflow.com/questions/2572396/nokogiri-open-uri-and-unicode-characters&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;the following one works&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;difference is, open-uri read first and then feed into Nokogiri,&amp;nbsp;&lt;/div&gt;&lt;div&gt;if feed directly, will result in hard encoding pain&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class="lang-rb prettyprint" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; text-align: left; vertical-align: baseline; width: auto;"&gt;&lt;code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;span class="com" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: grey; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;# encoding: UTF-8&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;require &lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;'nokogiri'&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;require &lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;'open-uri'&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;br /&gt;html &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;=&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; open&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;(&lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;'http://www.biblegateway.com/passage/?search=Mateo1-2&amp;amp;version=NVI'&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;)&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;doc &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;=&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="typ" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;Nokogiri&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;::&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;HTML&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;(&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;html&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;read&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;)&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;doc&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;encoding &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;=&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;'utf-8'&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;h52 &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;=&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; doc&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;css&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;(&lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;'h5'&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;)[&lt;/span&gt;&lt;span class="lit" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;1&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;].&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;text&lt;br /&gt;puts h52&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;,&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; h52&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;encoding&lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;,&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; h52 &lt;/span&gt;&lt;span class="pun" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;==&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt; &lt;/span&gt;&lt;span class="str" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;"Genealogía de Jesucristo"&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="com" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: grey; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;#=&amp;gt; Genealogía de Jesucristo&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="com" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: grey; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;#=&amp;gt; UTF-8&lt;/span&gt;&lt;span class="pln" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="com" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: grey; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"&gt;#=&amp;gt; true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;When inserting into mysql without going through rails, but mysql gem, set the UTF8&amp;nbsp;specifically&amp;nbsp;is mandatory:&lt;br /&gt;&lt;br /&gt;this page describes this in detail:&lt;br /&gt;&lt;a href="http://wiki.a2hosting.com/index.php/UTF-8_MySQL_connections_with_Ruby"&gt;http://wiki.a2hosting.com/index.php/UTF-8_MySQL_connections_with_Ruby&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: white; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;"&gt;db = Mysql.init&lt;br /&gt;db.options(Mysql::SET_CHARSET_NAME, 'utf8')&lt;br /&gt;db.real_connect('host', 'user', 'password', 'database', 3306, '/usr/local/lib/mysql.sock')&lt;br /&gt;db.query("SET NAMES utf8")&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-3543927005651941033?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/3543927005651941033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=3543927005651941033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3543927005651941033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3543927005651941033'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2011/12/nokogiri-char-encodings.html' title='Nokogiri &amp; Char encodings'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-882599329495400957</id><published>2011-11-08T11:00:00.000+09:00</published><updated>2011-11-08T11:00:26.301+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>java generic stuff memo</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;1. all generic derived classes share one static object&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;-&amp;gt; as jvm will not separately construct generic classes&lt;/div&gt;&lt;div&gt;e.g. Employee&lt;t&gt;, is the template&lt;/t&gt;&lt;/div&gt;&lt;div&gt;Employee&lt;developer&gt;, Employee&lt;designer&gt;, are the same class Employee in JVM&lt;/designer&gt;&lt;/developer&gt;&lt;/div&gt;&lt;div&gt;thus, assuming Employee&lt;t&gt; has a static field, say counter, &lt;/t&gt;&lt;/div&gt;&lt;div&gt;then increase the &lt;b&gt;&lt;i&gt;counter &lt;/i&gt;&lt;/b&gt;in Employee&lt;developer&gt;, then Employee&lt;designer&gt; will have the updated &lt;b&gt;&lt;i&gt;counter &lt;/i&gt;&lt;/b&gt;too. (actually, only one counter)&lt;/designer&gt;&lt;/developer&gt;&lt;/div&gt;&lt;div&gt;see: &lt;a href="http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#Is there one instances of a static field per instantiation of a parameterized type?"&gt;http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#Is there one instances of a static field per instantiation of a parameterized type?&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;2. need tricks to get the runtime template class object&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;say Employee&lt;t&gt; has a function, Class&lt;t&gt; getEmployeeType(), &lt;/t&gt;&lt;/t&gt;&lt;/div&gt;&lt;div&gt;it's not trivial to implement the function, and get the Class&lt;t&gt;. &lt;/t&gt;&lt;/div&gt;&lt;div&gt;- one way to walk around is : Class&lt;t&gt; getEmployeeType(Class curr_class)&lt;/t&gt;&lt;/div&gt;&lt;div&gt;- another way: &lt;a href="http://www.artima.com/weblogs/viewpost.jsp?thread=208860"&gt;http://www.artima.com/weblogs/viewpost.jsp?thread=208860&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-882599329495400957?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/882599329495400957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=882599329495400957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/882599329495400957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/882599329495400957'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2011/11/java-generic-stuff-memo.html' title='java generic stuff memo'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6667134563726113348</id><published>2011-11-08T10:59:00.001+09:00</published><updated>2011-11-08T11:00:05.469+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>tricky modulo operator</title><content type='html'>&lt;br /&gt;&lt;div&gt;&lt;table border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;div&gt;in Ruby: &lt;/div&gt;&lt;div&gt;197%5 = 2&lt;/div&gt;&lt;div&gt;-197%5 = 3&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&lt;div&gt;in Java:&lt;/div&gt;&lt;div&gt;197%5 = 2&lt;/div&gt;&lt;div&gt;-197%5 = &lt;b&gt;-2&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;... ... &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6667134563726113348?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6667134563726113348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6667134563726113348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6667134563726113348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6667134563726113348'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2011/11/tricky-modulo-operator.html' title='tricky modulo operator'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-824632749713607843</id><published>2010-04-16T12:20:00.005+09:00</published><updated>2010-04-19T00:03:36.934+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>compile uuid ossp to dll and used it in VS</title><content type='html'>&lt;div&gt;Project these days requires cross-platform feature (.Net 4.0, Android 2.1, in house Linux and etc ...). Thus the common used components, we plan to use standard C. Thanks to so many open source libraries, they save us a lot of work. However, compiling and using *nix libraries to windows is a kind of craftsmanship. &lt;/div&gt;  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the project, we need a uuid library. The only free &amp;amp; open &amp;amp; reliable solution probably is &lt;a href="http://www.ossp.org/pkg/lib/uuid/"&gt;OSSP UUID&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I started with the newest version&lt;a href="ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz"&gt; uuid-1.6.2.tar.gz&lt;/a&gt; with mingw @ a windows xp sp3 pc. I did not use cygwin, due to the license problem. &lt;/div&gt;  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;1. routine job &lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;./configure&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;make&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;make check&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; It does not generate any dynamic library, but a static one, libuuid.a &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2. generate dll&lt;/b&gt;&lt;/div&gt;  &lt;div&gt;well, by reading the stdout make process, i tried&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.1 get dll &amp;amp; def&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt; gcc -shared -o uuid-ossp.dll uuid.o uuid_md5.o uuid_sha1.o uuid_prng.o uuid_mac.o uuid_time.o uuid_ui64.o uuid_ui128.o uuid_str.o -Wl,--output-def,uuid.dll.def&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.2 get lib&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;dlltool -d uuid.dll.def --dllname uuid-ossp.dll --output-lib uuid-ossp.lib&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;div&gt;&lt;b&gt;2.3 test it with the command line tool uuid_cli.c&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;gcc -I . uuid_cli.c -o uuid.exe uuid_ossp.lib&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  everything works so well, the command line uuid.exe generated really works. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3. decide how to use and what do we need&lt;/b&gt;&lt;/div&gt;&lt;div&gt;sadly, this library, i could not find related API documents. &lt;/div&gt;  &lt;div&gt;what i need is just to generate the uuid, by reading uuid_cli.c, i got some hint, here's a simple &lt;b&gt;example.c&lt;/b&gt;, after cropping the uuid_cli.c to generate a version 1 uuid. &lt;/div&gt;&lt;pre&gt;#include "uuid.h"&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;uuid_t *uuid;&lt;br /&gt;uuid_rc_t rc;&lt;br /&gt;char *vp;&lt;br /&gt;size_t n;&lt;br /&gt;unsigned int version;&lt;br /&gt;&lt;br /&gt;version = UUID_MAKE_V1;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_create(&amp;amp;uuid)) != UUID_RC_OK)&lt;br /&gt; printf("uuid_create error");&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_make(uuid, version)) != UUID_RC_OK)&lt;br /&gt; printf("uuid_make error");&lt;br /&gt;&lt;br /&gt;vp = NULL;&lt;br /&gt;if ((rc = uuid_export(uuid, UUID_FMT_STR, &amp;amp;vp, &amp;amp;n)) != UUID_RC_OK)&lt;br /&gt; printf("uuid_export error");&lt;br /&gt;if (vp)&lt;br /&gt;printf("%s\n", vp);&lt;br /&gt;free(vp);&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)&lt;br /&gt; printf("uuid_destroy error");&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;&lt;div&gt;The code works well, and can link to the dll well. The only header file we need it uuid.h, no aother uuid*.h needed&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;4. used in Visual Studio&lt;/b&gt;&lt;/div&gt;  &lt;div&gt;in the visual studio project, configure the project by using the uuid-ossp.lib, and include the uuid.h in the search path. copy the example.c into the project. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;compile and run, oops ...&lt;/div&gt;  &lt;div&gt;&lt;b&gt;4.1 uuid.h &lt;/b&gt;&lt;/div&gt;&lt;div&gt;the compiler complains the uuid.h include &amp;lt;unistd.h&amp;gt;, it can not find&lt;/div&gt;&lt;div&gt;sure, the file is in mingw include path. i tried, to include related mingw headers into the project. but i failed, with lots of compilation errors. &lt;/div&gt;  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;u&gt;&lt;b&gt;but you can safely delete this line from the uuid.h, i tried, everything works the same&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;4.2 heap error&lt;/b&gt;&lt;/div&gt;&lt;div&gt;cool, now, the compiler has no complain, but when run, the example.c get a runtime error, in the line&lt;/div&gt;  &lt;blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;free(vp);&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;I dig this for a while, and realized that , the vp is malloc-ed and free-ed by different memory malloc &amp;amp; free implementations. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;the workable program in mingw, should changed to the following, then, example.c can work fine now:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;#include "uuid.h"&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;uuid_t *uuid;&lt;br /&gt;uuid_rc_t rc;&lt;br /&gt;char *vp;&lt;br /&gt;size_t n;&lt;br /&gt;unsigned int version;&lt;br /&gt;&lt;br /&gt;version = UUID_MAKE_V1;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;&lt;b&gt;n = 37;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;&lt;b&gt;vp = (char*)malloc(n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_create(&amp;amp;uuid)) != UUID_RC_OK)&lt;br /&gt;    printf("uuid_create error");&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_make(uuid, version)) != UUID_RC_OK)&lt;br /&gt;    printf("uuid_make error");&lt;br /&gt;&lt;br /&gt;vp = NULL;&lt;br /&gt;if ((rc = uuid_export(uuid, UUID_FMT_STR, &amp;amp;vp, &amp;amp;n)) != UUID_RC_OK)&lt;br /&gt;    printf("uuid_export error");&lt;br /&gt;if (vp)&lt;br /&gt;  printf("%s\n", vp);&lt;br /&gt;free(vp);&lt;br /&gt;&lt;br /&gt;if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)&lt;br /&gt;    printf("uuid_destroy error");&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new', monospace;"&gt;cool, everything works now. &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-824632749713607843?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/824632749713607843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=824632749713607843' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/824632749713607843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/824632749713607843'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2010/04/compile-uuid-ossp-to-dll-and-used-it-in.html' title='compile uuid ossp to dll and used it in VS'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-3172834700546963985</id><published>2009-12-09T16:12:00.002+09:00</published><updated>2009-12-09T16:13:31.364+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>compile xerces-c &amp; xalan-c on cygwin</title><content type='html'>&lt;p&gt;Yet another cygwin log again. Since the unfamiliar with under surface details of how it works, whenever sometime wrong happens on cygwin, it'll be a nightmare. This time is the xerces-c &amp;amp; xalan-c.  &lt;/p&gt; &lt;div&gt;&lt;br /&gt;&lt;/div&gt; &lt;div&gt;Since recent project requires to use the xpath in c++, the only choice probably is the xalan-c. I did think that if the library of c++ become rich enough, everyone c++ worker will be much easier from a developer coming from enterprise computing language and script language perspective. = = &lt;/div&gt;    &lt;div&gt;&lt;br /&gt;&lt;/div&gt; &lt;div&gt;This time, the story goes like this, i need to compile the xerces-c 2.7 as xalan 1.1 compatibility. The original binary package for cygwin is 3.0.1-1 or 2.8.0-5 under Devel/libxerces-c-devel. The steps of compilation as the Readme.html said:&lt;/div&gt;    &lt;div&gt;1. set the XERCESCROOT virable to the directory contains the extracting of xerces. for example ~/dev/xerces-c-src_2_7_0 &lt;/div&gt; &lt;div&gt;2. go the the XERCESCROOT/src/xercesc, use ./runConfigure -pcygwin -cgcc -xg++ to make the Makefile (runConfigure is a helper script, we can use ./configure also)&lt;/div&gt; &lt;div&gt;3. if everything's done properly, just make it. and make install &lt;/div&gt; &lt;div&gt;&lt;br /&gt;&lt;/div&gt; &lt;div&gt;My problem comes at the step 3, the make can not be processed when reaching the '&lt;span style="white-space:pre;font-family:Tahoma;font-size:12px;"&gt;deprecated DOM part'. The Problem is the exactly the same as this bug report &lt;a href="http://marc.info/?l=xerces-c-dev&amp;amp;m=112678686021543&amp;amp;w=2" target="_blank"&gt;XERCESC-1501&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;    &lt;div&gt;&lt;span style="font-family:Tahoma;font-size:100%;"&gt;&lt;span style="white-space:pre;font-size:12px;"&gt;&lt;span style="white-space:normal;font-family:'Times New Roman';font-size:medium;"&gt;&lt;pre&gt;&lt;span style="color:#666666;"&gt;Creating library file: \ /cygdrive/d/tmp/xerces-c-src_&lt;/span&gt;&lt;span style="color:#666666;"&gt;2_7_0/lib/libxerces-depdom27.&lt;/span&gt;&lt;span style="color:#666666;"&gt;dll.a \ CYGWIN/depdom/AttrImpl.o(.&lt;/span&gt;&lt;span style="color:#666666;"&gt;text+0x4bb):AttrImpl.cpp: undefined reference to \ `xercesc_2_7::XMemory::&lt;/span&gt;&lt;span style="color:#666666;"&gt;operator delete(void*)' \ CYGWIN/depdom/AttrImpl.o(.&lt;/span&gt;&lt;span style="color:#666666;"&gt;text+0x50d):AttrImpl.cpp: undefined reference to \ `xercesc_2_7::XMemory::&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#666666;"&gt;...&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#666666;"&gt;...&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#666666;"&gt;... ::fgNoString' collect2: ld returned 1 exit status make&lt;/span&gt;&lt;span style="color:#666666;"&gt;&lt;a name="12572309ecc046ba_125721acdf2e9aa1_1257218424202ebd_1256c239a0ef6baa_1256c1e555afc35b_-1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;a href="http://marc.info/?l=xerces-c-dev&amp;amp;m=112678686021543&amp;amp;w=2#1" target="_blank"&gt;&lt;span style="color:#666666;"&gt;[1]&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#666666;"&gt;: *** [/cygdrive/d/tmp/xerces-c-src_&lt;/span&gt;&lt;span style="color:#666666;"&gt;2_7_0/lib/cygxerces-depdom27.&lt;/span&gt;&lt;span style="color:#666666;"&gt;dll] Error 1 make&lt;/span&gt;&lt;a href="http://marc.info/?l=xerces-c-dev&amp;amp;m=112678686021543&amp;amp;w=2#1" target="_blank"&gt;&lt;span style="color:#666666;"&gt;[1]&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#666666;"&gt;: Target `ALL' not remade because of errors. make: *** [/cygdrive/d/tmp/xerces-c-src_&lt;/span&gt;&lt;span style="color:#666666;"&gt;2_7_0/lib/cygxerces-c27.dll] Error 2&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="white-space:normal;font-family:arial;font-size:small;"&gt;&lt;span style="font-size:85%;"&gt;The error seems saying the it can not find certain deprecated dom library. First, I went through the way &lt;/span&gt;&lt;a href="http://thread.gmane.org/gmane.text.xml.xerces-c.devel/7075" target="_blank"&gt;&lt;span style="font-size:85%;"&gt;this post&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt; said. After spending 1 hour to find where I can add that link options in the Makefile, the make still not work. &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;color:#3333ff;"&gt;Then I thought probably, it's the libxerces-c-devel problem. I uninstalled it. Then everything just works, with some auto-import warning, INFO. &lt;/span&gt;&lt;/div&gt;   &lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;After make install the compiled code, we can do test with the sample. The compilation of the sample works well. Everything works now. &lt;/span&gt;&lt;/div&gt;   &lt;div&gt;&lt;span style="font-family:Arial;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;Next, compilation of xalan-c. Nightmare again ...&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;1. set the XALANCROOT virable to the extracted xalan/c , make sure the XERCESCROOT is still there&lt;/span&gt;&lt;/div&gt;   &lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;2. in the XALANCROOT, run ./runConfigure -p cygwin -c gcc -x g++ -P /usr/local , make sure including the -P in order to use the 'make install'. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;3. type 'make', here comes the problem, exactly the same as this one: &lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2" target="_blank"&gt;http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;    &lt;div&gt;&lt;span style="font-family:Tahoma;font-size:100%;"&gt;&lt;span style="white-space:pre;font-size:12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:'Times New Roman';font-size:medium;"&gt;&lt;pre&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;make -C src/xalanc all make&lt;/span&gt;&lt;span style="color:#666666;"&gt;&lt;a name="12572309ecc046ba_125721acdf2e9aa1_-1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2#1" target="_blank"&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;[1]&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;: Entering directory `/usr/src/xml-xalan/c/src/xalanc' Preparing the directory structure for a build ... mkdir -p ../../obj mkdir -p ../../lib mkdir -p ../../bin make -C Utils prepare make&lt;/span&gt;&lt;span style="color:#666666;"&gt;&lt;a name="12572309ecc046ba_125721acdf2e9aa1_-2"&gt;&lt;/a&gt;&lt;/span&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2#2" target="_blank"&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;[2]&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;: Entering directory `/usr/src/xml-xalan/c/src/xalanc/Utils' Makefile:71: *** multiple target patterns.  Stop. make&lt;/span&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2#2" target="_blank"&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;[2]&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;: Leaving directory `/usr/src/xml-xalan/c/src/xalanc/Utils' make&lt;/span&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2#1" target="_blank"&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;[1]&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;: *** [prepare] Error 2 make&lt;/span&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=115953899805021&amp;amp;w=2#1" target="_blank"&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;[1]&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new,monospace;color:#666666;"&gt;: Leaving directory `/usr/src/xml-xalan/c/src/xalanc' make: *** [all] Error 2&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;/span&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;The thread is very interesting. The last one solved this problem partly: &lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;a href="http://marc.info/?l=xalan-c-users&amp;amp;m=116048865019326&amp;amp;w=2" target="_blank"&gt;http://marc.info/?l=xalan-c-users&amp;amp;m=116048865019326&amp;amp;w=2&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="text-transform:none;text-indent:0px;border-collapse:separate;font:medium 'Times New Roman';white-space:normal;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0px"&gt;&lt;pre&gt;  &lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;&lt;span style="font-family:courier new,monospace;"&gt;I could now compile Xalan. &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;   &lt;span style="font-family:courier new,monospace;"&gt;The problem was the empty XLIFF_FILE_NAME. &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;&lt;span style="font-family:courier new,monospace;"&gt;I hard coded the Windows form of the file, "C:/cygwin/usr/....", to Utils/Makefile and changed the line &lt;/span&gt;&lt;/blockquote&gt;   &lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;&lt;span style="font-family:courier new,monospace;"&gt;$(XSL_NLS_DIR)/include/LocalMsgData.hpp : $(XSL_BIN_DIR)/MsgCreator $(XLIFF_FILE_NAME) to &lt;/span&gt;&lt;/blockquote&gt;   &lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;&lt;span style="font-family:courier new,monospace;"&gt;$(XSL_NLS_DIR)/include/LocalMsgData.hpp : $(XSL_BIN_DIR)/MsgCreator &lt;/span&gt;&lt;/blockquote&gt;   &lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;&lt;span style="font-family:courier new,monospace;"&gt;But the "make install" fails:&lt;/span&gt;&lt;/blockquote&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Actually it says the problem is because the XLIFF_FILE_NAME has not been processed successfully, but with an empty string in the real make run. In order to fix that one, we need to set it manually in the Utils/Makefile.&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;1. In the line 38 of the Utils/Makefile, we can find the XLIFF_FILE_NAME for Cygwin. comment out that line, add add XLIFF_FILENAME=$XALANCROOT/src/xalanc/NLS/en_US/XalanMsg_en_US.xlf &lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;2. In the line 71, i found that keep it the same still can make successful. so what we need is do the step 1. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;I said the solution solves the problem partly, because when I make the xalan now, the result is not that stable, sometimes errors, sometimes successful, and everytime the errors are different. In the make output, After lots of g++ -O, it starts to create the .dll file. The problem here is sometimes, it says some *.o can not be found in obj/ . &lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The time I successfully compiled it is I redirected the make output into a text file. = = Otherwise, different *.o are reported as can  not be found in different run. = = very wired.&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Anyway, the compilation seems finished, then comes the 'make install'. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;  &lt;span style="font-family:Arial;font-size:85%;"&gt;Remember when doing ./runConfigure, we should specify the -P as the installation directory. I set as /usr/local/ at the beginning. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The make file will try to install the file at //usr/local//bin|lib|include, and // can not be recogonized by bash in cygwin. &lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The solution is to modify the Makefile.incl at the root directory. Line 40, change 'prefix=/usr/local/' to 'prefix=usr/local'. I tried to rerun the runConfigure with -P usr/local, but it does not work because absolute path checking. &lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Then the 'make install' works. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Next nightmare to me, is the installation seems having something wrong. &lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The cygxalan-c110.dll has been installed in /usr/local/lib, not in /usr/local/bin, and the cygxalanMsg110.dll has been kept in the XALANCROOT/lib, but not in /usr/local/bin&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;I compiled the samples by 'make samples' to see whether everything works. But the result is frustrating. only the MsgCreator.exe works, others said:&lt;/span&gt;&lt;/pre&gt;   &lt;pre&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span style="text-transform:none;text-indent:0px;border-collapse:separate;font:small arial, sans-serif;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0px"&gt;&lt;span style="border-collapse:collapse;white-space:pre;font-size:17px;"&gt;&lt;blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"&gt;   &lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span style="text-transform:none;text-indent:0px;border-collapse:separate;font:small arial, sans-serif;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0px"&gt;&lt;span style="border-collapse:collapse;white-space:pre;font-size:17px;"&gt;the procedure entry point AddAtomA could not be located in the dynamic link library cygwin1.dll&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;   &lt;div&gt;&lt;span class="Apple-style-span"   style="  ;font-family:arial, helvetica, sans-serif;font-size:small;"&gt;Googled the AddAtomA, it said that AddAtomA has been exported by kernal32.dll : &lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;&lt;a href="http://www.pc1news.com/virus/function-addatoma-1177.html" target="_blank"&gt;http://www.pc1news.com/virus/function-addatoma-1177.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;pre&gt;  &lt;span style="font-family:arial,helvetica,sans-serif;font-size:85%;"&gt;&lt;span style="line-height:normal;text-transform:none;font-variant:normal;font-style:normal;text-indent:0px;border-collapse:separate;white-space:normal;letter-spacing:normal;color:rgb(0,0,0);font-weight:normal;word-spacing:0pxfont-family:'Times New Roman';"&gt;&lt;span style="white-space:pre;font-family:Tahoma;"&gt;kernal32.dll is in C:\Windows\system32&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre&gt;&lt;span class="Apple-style-span"   style="border-collapse: separate;   font-family:Tahoma, helvetica, sans-serif;font-size:small;"&gt;but why cygwin1.dll can not locate that??&lt;/span&gt;&lt;/pre&gt; &lt;pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-3172834700546963985?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/3172834700546963985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=3172834700546963985' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3172834700546963985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3172834700546963985'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/12/compile-xerces-c-xalan-c-on-cygwin.html' title='compile xerces-c &amp; xalan-c on cygwin'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-1232303425577949692</id><published>2009-08-27T18:07:00.000+09:00</published><updated>2009-08-27T18:08:13.610+09:00</updated><title type='text'>Cygwin/X, cygwin with gui : )</title><content type='html'>&lt;div&gt;Still using cygwin in the current project. These days the job is setting up a cygwin rails server with RMagick installed. On the RMagick FAQ page I read some information about setting up the cygwin/x, so I started, which makes this rainy afternoon interesting. : ) &lt;/div&gt;   &lt;div&gt; &lt;/div&gt; &lt;div&gt;Cygwin/x makes x server run happily on windows. The install instruction is straightforward:&lt;/div&gt; &lt;div&gt;&lt;a href="http://x.cygwin.com/docs/ug/cygwin-x-ug.pdf"&gt;http://x.cygwin.com/docs/ug/cygwin-x-ug.pdf&lt;/a&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;Cygwin/x comes with a &lt;font color="#ff0000"&gt;xwin&lt;/font&gt; exe. When xwin started, it&amp;#39;ll start a xserver integrated with a windows notification, which means you can use the xserver as other windows apps. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;With &lt;font color="#ff0000"&gt;startx&lt;/font&gt; command, we can start xserver using &lt;font color="#ff0000"&gt;.xinitrc&lt;/font&gt; configuration. Using &lt;font color="#ff0000"&gt;xterm&lt;/font&gt; started by xserver, we can use &lt;font color="#ff0000"&gt;display&lt;/font&gt; and &lt;font color="#ff0000"&gt;animate&lt;/font&gt; if we installed ImageMagick. Note: here is xterm, not the original cgwin shell winodw. If we start from there, we&amp;#39;ll get an error : display: unable to open X server `&amp;#39;&lt;/div&gt;   &lt;div&gt; &lt;/div&gt; &lt;div&gt;btw, by installing the &lt;font color="#ff0000"&gt;procps&lt;/font&gt; package, on cygwin, we can use the &lt;font color="#ff0000"&gt;top&lt;/font&gt; on cygwin. &lt;/div&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-1232303425577949692?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/1232303425577949692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=1232303425577949692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1232303425577949692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1232303425577949692'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/08/cygwinx-cygwin-with-gui.html' title='Cygwin/X, cygwin with gui : )'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-3681591345898623103</id><published>2009-08-21T19:39:00.002+09:00</published><updated>2009-08-23T00:24:17.768+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='swig'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>using SWIG + Cygwin + Ruby</title><content type='html'>&lt;div&gt;Basiclly using swig+cygwin+ruby is not that hard. After reading first few pages from the manual, we can get up and start writing simple examples. However, the first example spends me a whole afternoon. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;At first, SWIG seems a very inviting tool for me, since it provides the unified development process to deal with different languages integration with C/C++. Due to the project constraint, I can only use Cygwin to simulate Unix/Linux environment.&lt;/div&gt;   &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;1.&lt;/strong&gt; get swig from cygwin setup OR the windows version works also)&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;2.&lt;/strong&gt; get ruby from cygwin setup, and download rubygems from rubyforge and install it at cygwin&lt;/div&gt; &lt;div&gt;&lt;strong&gt;3.&lt;/strong&gt; write a simple &lt;span style="color:#ff0000;"&gt;test.c&lt;/span&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;int add(int a, int b) {&lt;/div&gt; &lt;div&gt;     return a + b;&lt;/div&gt; &lt;div&gt;}&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;4.&lt;/strong&gt; write a simple &lt;span style="color:#ff0000;"&gt;test.i&lt;/span&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;%module test &lt;/div&gt; &lt;div&gt;%{&lt;/div&gt; &lt;div&gt;extern int add(int a, int b); &lt;/div&gt; &lt;div&gt;%}&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;extern int add(int a, int b);&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;5.&lt;/strong&gt; using swig to generate the wrapper, (if win version, add swig.exe to PATH,  restart cygwin to read it)&lt;/div&gt; &lt;div&gt;&lt;span style="color:#ff0000;"&gt;swig -ruby test.i&lt;/span&gt;  (if using cpp, swig -c++ -ruby test.i)&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;this will generate the test_wrap.c, don't forget -ruby mark, by default is tcl&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;6.&lt;/strong&gt; compile the test.c test_wrap.c&lt;/div&gt; &lt;div&gt;&lt;span style="color:#ff0000;"&gt;gcc -c test.c test_wrap.c -I/usr/lib/ruby/1.8/i386-cygwin&lt;/span&gt; (or the right place having the ruby C h files)&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;this wil generate test.o, test_wrap.o&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;7.&lt;/strong&gt; generate the dynamic library from .o&lt;/div&gt; &lt;div&gt;&lt;span style="color:#ff0000;"&gt;gcc -shared test.o test_wrap.o /usr/lib/libruby.dll.a -enable-auto-import -o test.so&lt;/span&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;if not auto import, this will complain about the auto complete config but will generate file correctly. after this, test.so will be generated. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;strong&gt;8.&lt;/strong&gt; use the irb to test it&lt;/div&gt; &lt;div&gt;start irb from the same directory&lt;/div&gt; &lt;div&gt;irb ... &amp;gt; &lt;span style="color:#ff0000;"&gt;require 'test'&lt;/span&gt;&lt;span style="color:#000000;"&gt;                     # test is .so file name&lt;/span&gt;&lt;/div&gt; &lt;div&gt;=&amp;gt; true&lt;/div&gt; &lt;div&gt;irb ... &amp;gt; &lt;span style="color:#ff0000;"&gt;puts Test.add(100, 101)&lt;/span&gt;&lt;span style="color:#000000;"&gt;    # Test.add, Test is module name, should be capitalized. &lt;/span&gt;&lt;/div&gt; &lt;div&gt;201&lt;/div&gt; &lt;div&gt;=&amp;gt; nil&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;that's it. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;Here's the tricky points:&lt;/div&gt; &lt;div&gt;1. ruby problem, better install the cygwin version ruby, for me the ruby at windows, when compile report error about mismatch versions of ms windows&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;2. ruby gems problem, if you don't install ruby gem sperately at cygwin, start ruby program, you'll get some error like 'ubygems could not find .. '. That's because the RUBYOPT environment usually is set by one click installer at windows. The cygwin ruby can see it also, it'll try to find the rubygems program at /usr/lib/ruby/..., but at cygwin rubygems is not installed by default.&lt;/div&gt;   &lt;div&gt; &lt;/div&gt; &lt;div&gt;3. when compiling, the ruby header files locations&lt;/div&gt; &lt;div&gt;the manual said at /usr/local/include/ruby ...&lt;/div&gt; &lt;div&gt;at cygwin, it's at /usr/lib/ruby/1.8/i386-cygwin &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;4. when linking, the ruby library locations&lt;/div&gt; &lt;div&gt;the manual does not include it at all, if you use that, you'll get lots of errors like '_rb_error undefined ...'&lt;/div&gt; &lt;div&gt;for ruby 1.8.x, the cygwin path of it is /usr/lib/libruby.dll.a&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;libruby-static.a is not the right one&lt;/div&gt; &lt;div&gt;don't use the windows version linking library, which is at C:\Ruby\lib\msvcrt-ruby18.lib, use it you'll get lots of errors. that's for ms vc linker. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;5. most trickiest, when the module name should be capitalized. (spend most of the afternoon here!!)&lt;/div&gt; &lt;div&gt;irb ..&amp;gt; require 'test'&lt;/div&gt; &lt;div&gt;=&amp;gt; true&lt;/div&gt; &lt;div&gt;irb ..&amp;gt; puts test.add(100, 101)&lt;/div&gt; &lt;div&gt;undefined test ... &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;should be Test.add(100, 101)&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;at last. everything finally works. = =!!! &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;The capitalized problem made me confused a lot, since the references for using swig+ruby+cygwin is not that much, you need to have question at each step ... &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;btw: Ctrl + L  at cygwin console can have the 'cls' function. : ) just got to know ...&lt;/div&gt; &lt;div&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-3681591345898623103?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/3681591345898623103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=3681591345898623103' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3681591345898623103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3681591345898623103'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/08/using-swig-cygwin-ruby.html' title='using SWIG + Cygwin + Ruby'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-5779441129518864973</id><published>2009-08-05T09:25:00.002+09:00</published><updated>2009-08-23T00:22:10.789+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>gcc's [Undefined reference to 'vtable for ...'] error handling</title><content type='html'>&lt;div&gt;I did not touch c++ ooad at least 4 years ... after some standization, the language looks good though, still not that comfortable to me so far. due to some project requirement, i'm struggling with c++ ooad these days. after drawing class chart, i spent lots of time to pick up the ooad features, rules and conventions in cpp. &lt;/div&gt;  &lt;div&gt; &lt;/div&gt; &lt;div&gt;one of the wired thing today, is after i added some virtual function to some class hierachy, gcc linker reports 'Undefined reference to 'vtable for ...' . after googling, i found this is a gcc feature or limitation or specific implementation towards the iso standard. &lt;/div&gt;  &lt;div&gt;here's the official solution: &lt;a href="http://gcc.gnu.org/faq.html#vtables"&gt;http://gcc.gnu.org/faq.html#vtables&lt;/a&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;well, i do believe after spending enough time on this language, i'll be much more comfortable with it. hope so ~ ^^&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-5779441129518864973?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/5779441129518864973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=5779441129518864973' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5779441129518864973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5779441129518864973'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/08/gccs-undefined-reference-to-vtable-for.html' title='gcc&apos;s [Undefined reference to &apos;vtable for ...&apos;] error handling'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6025248869358966207</id><published>2009-08-04T17:56:00.002+09:00</published><updated>2009-08-23T00:21:52.115+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux-dev'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>fancy auto dependency generation?? = =</title><content type='html'>&lt;div&gt;i encountered some error from g++ today said 'undefined reference to xx method'&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;the compiler actually said, it can not find the implementation of this method, which means the file may not be compiled.&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;that's true. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;i checked the makefile which i adopted from some open source project. it uses advanced &lt;a href="http://make.paulandlesley.org/autodep.html"&gt;auto dependency generation&lt;/a&gt; to check needed files .. however, the dependency generator can only finds the .h file, but it'll not compile the .cpp file. == &lt;/div&gt;  &lt;div&gt; &lt;/div&gt; &lt;div&gt;i modified the makefile, everything works fine now. = = however, 2hrs just vanished ...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6025248869358966207?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6025248869358966207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6025248869358966207' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6025248869358966207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6025248869358966207'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/08/fancy-auto-dependency-generation.html' title='fancy auto dependency generation?? = ='/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7722855973279036873</id><published>2009-07-31T10:00:00.002+09:00</published><updated>2009-08-23T00:20:05.871+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>how to deal with bit stream or bit set in cpp</title><content type='html'>&lt;div&gt;what's a byte: uint8_t&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;containers: bitset vs vector&amp;lt;bool&amp;gt; &lt;/div&gt; &lt;div&gt;comparation: &lt;a href="http://www.ddj.com/cpp/184401382"&gt;http://www.ddj.com/cpp/184401382&lt;/a&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;how to print: hex, dec, oct, in std namespace. all have lasting effects which is confusing at some time. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;note char = 'A' does not mean 0xA&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7722855973279036873?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7722855973279036873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7722855973279036873' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7722855973279036873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7722855973279036873'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/07/how-to-deal-with-bit-stream-or-bit-set.html' title='how to deal with bit stream or bit set in cpp'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-2749493676061090126</id><published>2009-07-24T10:39:00.003+09:00</published><updated>2009-08-23T00:19:22.597+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>how to set cygwin bash environment</title><content type='html'>&lt;div&gt;according to cygwin site : &lt;a href="http://www.cygwin.com/cygwin-ug-net/setup-env.html"&gt;http://www.cygwin.com/cygwin-ug-net/setup-env.html&lt;/a&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;to set up the environment variables in cygwin, we need to edit the c:\cygwin\Cygwin.bat, not the .bashrc &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;the cygwin user's guide seems a good resource for working with cygwin:&lt;/div&gt; &lt;div&gt;&lt;a href="http://www.cygwin.com/cygwin-ug-net/cygwin-ug-net.html"&gt;http://www.cygwin.com/cygwin-ug-net/cygwin-ug-net.html&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-2749493676061090126?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/2749493676061090126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=2749493676061090126' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2749493676061090126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2749493676061090126'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/07/how-to-set-cygwin-bash-environment.html' title='how to set cygwin bash environment'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-8337605259553994735</id><published>2009-07-23T16:49:00.002+09:00</published><updated>2009-07-24T01:40:22.496+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='linux-dev'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>how to use cygwin to run a helloworld in eclipse 3.5</title><content type='html'>&lt;div&gt;== i would say i spend one hour on it. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;For the mingw hello world, it's very straightforward. Just follow the wizard, 'hello world' will print on the console happily. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;However, when change to cygwin toolchain, some trouble comes, here's a flow about how to run a hello world makefile project. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;ol&gt; &lt;li&gt;Create a project c++, hello world makefile&lt;/li&gt; &lt;li&gt;project -&amp;gt; properties -&amp;gt; C/C++ Build -&amp;gt; Discovery Options -&amp;gt; Cygwin C++/C Compiler -&amp;gt; check off the automate discoverey of paths and symbols. &lt;/li&gt; &lt;li&gt;project -&amp;gt; properties -&amp;gt; C/C++ General -&amp;gt; Paths and Symbols -&amp;gt; Includes -&amp;gt; GNU C -&amp;gt; Add ... C:\cygwin\usr\include&lt;/li&gt; &lt;li&gt;project -&amp;gt; properties -&amp;gt; C/C++ General -&amp;gt; Paths and Symbols -&amp;gt; Includes -&amp;gt; GNU C++ -&amp;gt; Add ... C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++&lt;/li&gt; &lt;li&gt;build the project&lt;/li&gt; &lt;li&gt;project -&amp;gt; Run/Debug Settings -&amp;gt; Select *.exe -&amp;gt; Edit ... -&amp;gt; Environment -&amp;gt; Add PATH = C:\cygwin\bin;&lt;/li&gt;&lt;/ol&gt; &lt;div&gt;Something is worth noticing&lt;/div&gt; &lt;ul&gt; &lt;li&gt;-mno-cygwin flag seems not workable in gcc now, we should put cygwin dll into the path maybe .. still figuring how to do that ... if there is, post a new post. &lt;/li&gt; &lt;li&gt;in the 6th step, add PATH into the Run/Debug Settings instead of system environment is better, since if use mingw on the same machine, mingw sometimes will mess up due to cygwin bin in the PATH variable. &lt;/li&gt; &lt;li&gt;in the 2nd step, since cygwin is not gnu compiler, the automatic discovery of path and symbols is not workable, disable it will remove some warnings. &lt;/li&gt; &lt;li&gt;in 3rd and 4th step, to specify the include path variables.&lt;/li&gt;&lt;/ul&gt; &lt;div&gt;== not that trivial, really ...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-8337605259553994735?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/8337605259553994735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=8337605259553994735' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8337605259553994735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8337605259553994735'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/07/how-to-use-cygwin-to-run-helloworld-in.html' title='how to use cygwin to run a helloworld in eclipse 3.5'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6745370660934053514</id><published>2009-07-23T15:19:00.002+09:00</published><updated>2009-07-24T01:39:52.795+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='msys'/><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='linux-dev'/><category scheme='http://www.blogger.com/atom/ns#' term='meta data'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>how to build exiv2 on windows and run samples</title><content type='html'>&lt;div&gt;R/w exif is not that trivial. Good news is there's a exiv2 library out there, we can use. Bad news is it's not that easy to compile it and run the samples on windows. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;My work environment due to some drm system can only be in windows. And because of cross platform extension reason, I can not use vcproj provided by exiv2. Here's the process i tried. &lt;/div&gt; &lt;ul&gt; &lt;li&gt;Plan to use eclipse cdt as the ide, so install eclipse and mingw 5.1.13 and MSYS-1.0.10 as eclipse recommended. &lt;/li&gt; &lt;li&gt;Use mingw tool chain to compile exiv2, encountered several problems&lt;/li&gt; &lt;ul&gt; &lt;li&gt;when run configure, the script can not determine the build systems&lt;/li&gt; &lt;ul&gt; &lt;li&gt;read the configure file, find the arg format cpu-manufactor-os&lt;/li&gt; &lt;li&gt;so set the --build arg as i686-pc-mingw32&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;compile again, some memory invalid access error, however, can continue run&lt;/li&gt; &lt;li&gt;at the last stage, configure script will create the config.status script, the config.status script will create some tmp directory.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;error: config.status cannot create a temporary directory&lt;/li&gt; &lt;li&gt;read the config.status script, find the last part contains the error, but don't know how the $tmp is assigned. &lt;/li&gt; &lt;li&gt;read configure script, find that by using -n arg, config.status can be generated, but it will not automatically run config.status and generate Makefile&lt;/li&gt; &lt;li&gt;so use ./configure --build-i686-pc-mingw32 -n -without-zlib -disable-xmp to compile, it can generate the Makefile&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;make the Makefile, however problem happened in the middle, many memory invalid access ...&lt;/li&gt; &lt;ul&gt; &lt;li&gt;guess mingw's developer toolkit problem, so download the automake, autoconf and libtool and want to install these on the computer. &lt;/li&gt; &lt;li&gt;when compile either one of them, always has the same make problem. (note, also ./configure -n -prefix=/mingw setted.)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;decide to drop mingw and turn to cygwin and have a try&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;turn to cygwin, download setup.exe and make sure the following libs are installed. &lt;/li&gt; &lt;ul&gt; &lt;li&gt;zlib, gettex, libiconv, expat, pkg-config (for samples)&lt;/li&gt; &lt;li&gt;then ./configure, no problem with the config.status could not create temporary dir. good. &lt;/li&gt; &lt;li&gt;then make, no problem, though wait around 5 minutes. &lt;/li&gt; &lt;li&gt;then make install, exiv2, is installed at /usr/local/lib (.a and pkg-config) and /usr/local/bin (dll)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;start to compile the samples&lt;/li&gt; &lt;ul&gt; &lt;li&gt;in the exiv2 root dir, run the make samples, problems happen&lt;/li&gt; &lt;ul&gt; &lt;li&gt;pkg-config would not find the exiv2.pc &lt;/li&gt; &lt;ul&gt; &lt;li&gt;to solve it, copy /usr/local/lib/pkgconfig/exiv2.pc to /usr/lib/pkgconfig/&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;run again, it said that would not find the libexiv2.a&lt;/li&gt; &lt;ul&gt; &lt;li&gt;to solve it, export LD_LIBRARY_PATH=/usr/local/lib;$LD_LIBRARY_PATH to include the path into the library path. &lt;/li&gt;&lt;/ul&gt; &lt;li&gt;compile again, everything is find now ...&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;run exifprint.exe&lt;/li&gt; &lt;ul&gt; &lt;li&gt;problem, no print out at cygwin console and on windows it said would not find *.dll (cygwin1.dll, ... )&lt;/li&gt; &lt;ul&gt; &lt;li&gt;to solve it, copy the dll and exe together into one directory, everything is fine now, the program can execute happily. but the solution is very ugly. still not figure out how to compile into one stand alone exe yet ... anyway so far it has been workable. good news ...&lt;/li&gt; &lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;div&gt;         &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6745370660934053514?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6745370660934053514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6745370660934053514' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6745370660934053514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6745370660934053514'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/07/how-to-build-exiv2-on-windows-and-run.html' title='how to build exiv2 on windows and run samples'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-4525902868530946910</id><published>2009-07-22T17:41:00.003+09:00</published><updated>2009-07-24T01:39:08.072+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='msys'/><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='linux-dev'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>how to deal with msys 'Couldn't reserve space for cygwin's heap,  Win32 error 6' problem</title><content type='html'>&lt;div&gt;i installed eclipse cdt to develop some cpp programs. the before beginning section of c++ development in eclipse help is quite useful, which includes necessary download links. however, when install the MSYS, i encounter a error:&lt;/div&gt;  &lt;ul&gt; &lt;li&gt;'Couldn't reserve space for cygwin's heap, Win32 error 6'&lt;/li&gt;&lt;/ul&gt; &lt;div&gt;After googling, lots of post was found. most of it was suspecting that cywin installation. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;For me, I install the mingw on a fresh system without cygwin, so cygwin environment variable problem would not happen. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;Finally, I solved it used the instructions from the MSYS official site. &lt;a href="http://www.mingw.org/wiki/msys"&gt;http://www.mingw.org/wiki/msys&lt;/a&gt;&lt;/div&gt; &lt;div&gt;Install MSYS 1.0.10 is just one step of the installation. &lt;/div&gt; &lt;div&gt;After following the instructions there, MSYS is workable now. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-4525902868530946910?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/4525902868530946910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=4525902868530946910' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4525902868530946910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4525902868530946910'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/07/how-to-deal-with-msys-couldnt-reserve.html' title='how to deal with msys &apos;Couldn&apos;t reserve space for cygwin&apos;s heap,  Win32 error 6&apos; problem'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-992585040419924965</id><published>2009-06-17T10:51:00.002+09:00</published><updated>2009-06-17T10:52:49.884+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><title type='text'>working with latex in eclipse</title><content type='html'>the sourceforge project &lt;a href="http://texlipse.sourceforge.net/"&gt;texlipse&lt;/a&gt; is a good plugin for eclipse for working with latex. it calls installed latex commands and integrates with preview programs. by using eclipse, the editing becomes enjoyable, since it supports spell checking, wrap up and many other familiar eclipse code editing features. create a project becomes easy also. the project website has very good documents also. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-992585040419924965?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/992585040419924965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=992585040419924965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/992585040419924965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/992585040419924965'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/06/working-with-latex-in-eclipse.html' title='working with latex in eclipse'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-1061419469210620721</id><published>2009-05-28T21:05:00.002+09:00</published><updated>2009-05-28T21:07:28.145+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='blogger'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>syntax ruby code to html in gnome</title><content type='html'>before, when syntax codes to blog, i use some online tool or offline tool like java2html to convert codes. i tried gnu &lt;a href="http://www.gnu.org/software/src-highlite/"&gt;source-highlight&lt;/a&gt;, but not successful yet. when time goes by, i lost those tools, links and more how to use them, so i decided to create the wheel again. after googling, i found several links all of which say that ruby syntax is good at doing that.&lt;br /&gt;&lt;br /&gt;here's the link:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://rails.brentsowers.com/2007/12/formatting-ruby-and-html-code-for-blog.html"&gt;windows clipboard working code and css style sheets in blogspot&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blog.wolfman.com/articles/2006/05/26/howto-format-ruby-code-for-blogs"&gt;kde clipboard working code&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;both of them create the snippets by getting code from clipboard, format it and set it back to clipboard. i found this idea really useful when posting codes in blogs. however, i could not find the gnome version since i use ubuntu when working.&lt;br /&gt;&lt;br /&gt;so i created one and using the clipboard.rb in &lt;a href="http://swimminginbits.blogspot.com/2009/05/get-and-set-gnome-clipboard-data-from.html"&gt;the previous post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;when use it, copy the code you want to syntax, and run the code, the clipboard will be changed to the formatted code. just copy it to the blog html editor. also remember to change the blog template file to include the css from previous links, thanks for the css.&lt;br /&gt;&lt;pre&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;gem&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;syntax&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;syntax/convertors/html&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;clipboard&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="ident"&gt;in_data&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Clipboard&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="ident"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;convertor&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Syntax&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Convertors&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;HTML&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;for_syntax&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;ruby&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;code_html&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;convertor&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;convert&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;in_data&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="constant"&gt;Clipboard&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="ident"&gt;set&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;code_html&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-1061419469210620721?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/1061419469210620721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=1061419469210620721' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1061419469210620721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1061419469210620721'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/05/syntax-ruby-code-to-html-in-gnome.html' title='syntax ruby code to html in gnome'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-1853363495839562036</id><published>2009-05-28T20:52:00.006+09:00</published><updated>2009-05-28T21:01:22.781+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='gui'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>get and set gnome clipboard data from ruby</title><content type='html'>I checked ruby gtk2 library today for operating the clipboard data in gnome. i could not find similar snippets in gnome, but in kde there are several examples.&lt;br /&gt;&lt;br /&gt;about the ruby gtk2 code, refer to Ruby-GNOME2 &lt;a href="http://ruby-gnome2.sourceforge.jp/"&gt;official site&lt;/a&gt;. they create a impressing site including tutorials. the Api docs do not contain working examples which leads to create quick demo slower.&lt;br /&gt;&lt;br /&gt;here's solution, really simple. thanks to the ruby gnome2 project:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;gtk2&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# copy the text from clipboard &amp;amp; set text to clipboard&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# the code references: &lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# -- http://ruby-gnome2.sourceforge.jp/ja/hiki.cgi?Gtk%3A%3AClipboard&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# -- http://ruby.pastebin.com/f5ef5f028&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;#  also another post about xclip is also interesting&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# -- http://www.ruby-forum.com/topic/137368&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# the reason to create this code was to syntax ruby code to html from clipboard&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# May 28, 2009 - imoldcat&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;Clipboard&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.set&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;c&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Gtk&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Clipboard&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;get&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;Gdk&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Selection&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;CLIPBOARD&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;c&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;set_text&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_s&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;c&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;store&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.get&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;clipboard&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Gtk&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Clipboard&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;get&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;Gdk&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Selection&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;CLIPBOARD&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;clipboard&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;wait_for_text&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;#Example&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="global"&gt;$0&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="constant"&gt;__FILE__&lt;/span&gt; &lt;span class="keyword"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;"&lt;/span&gt;&lt;span class="string"&gt;before text: &lt;span class="expr"&gt;#{Clipboard::get}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;"&lt;/span&gt;&lt;span class="string"&gt;set clipboard as hello ruby: &lt;span class="expr"&gt;#{Clipboard::set("hello ruby")}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;"&lt;/span&gt;&lt;span class="string"&gt;after text: &lt;span class="expr"&gt;#{Clipboard::get}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;"&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-1853363495839562036?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/1853363495839562036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=1853363495839562036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1853363495839562036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1853363495839562036'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/05/get-and-set-gnome-clipboard-data-from.html' title='get and set gnome clipboard data from ruby'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7601100319640091385</id><published>2009-05-28T20:39:00.003+09:00</published><updated>2009-05-28T20:41:57.214+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='chart'/><title type='text'>plot a histogram using gnuplot and ruby</title><content type='html'>today i encountered a paper written problem which needs a histogram. i remembered that gnuplot has a chart called "histogram", so at first i did not worry at all. however, things are not like what i thought.&lt;br /&gt;&lt;br /&gt;the gnuplot histogram actually is a kind of history chart ==!!. after plotting a demo and looking at those &lt;a href="http://gnuplot.sourceforge.net/demo_4.3/histograms.html" target="_blank"&gt;examples&lt;/a&gt;, i realized that. == maybe it's right since linux/unix softwares usually do one thing and do it well. gnuplot is not responsible to calculate the frequency for us. &lt;br /&gt;&lt;br /&gt;so i calculated the frequency manually and give two columns data to gnuplot with boxes. the box chart use the middle point to show the freuqency which not i want, so we need to add some offset value which equals to half of the step in the histogram.&lt;br /&gt;&lt;br /&gt;to use &lt;a href="http://rgnuplot.sourceforge.net/" target="_blank"&gt;rubygnuplot&lt;/a&gt;, i wrote a class for reuse purpose, and paste it here. some of code referes &lt;a href="http://www.math.kobe-u.ac.jp/%7Ekodama/tips-ruby-histogram.html" target="_blank"&gt;histogram class&lt;/a&gt; by Kodama. The histogram class has some mistake when calculating the frequencies. In Kodama's code, the first and last frequencies are not with the same step as other ones, but the frequencies are treated the same.&lt;br /&gt;&lt;br /&gt;the ruby code is syntaxed by a script created using ideas from &lt;a href="http://rails.brentsowers.com/2007/12/formatting-ruby-and-html-code-for-blog.html" target="_blank"&gt;this post&lt;/a&gt; using ruby syntax lib.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;gnuplot&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# the class use gnuplot to calculate frequency and draw a histogram &lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# limitations: the step is the same in this code. it can not be used to draw&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# histogram with different steps.&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# May 28, 2009 - imoldcat&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;GnuplotHistogram&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;h_class&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="punct"&gt;((&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;-&lt;/span&gt;&lt;span class="attribute"&gt;@min&lt;/span&gt;&lt;span class="punct"&gt;)/&lt;/span&gt;&lt;span class="attribute"&gt;@step&lt;/span&gt;&lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;truncate&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span class="comment"&gt;# array is the raw data, step is used when calculate frequency&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;initialize&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;array&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;step&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@min&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;array&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;min&lt;/span&gt; &lt;span class="punct"&gt;-&lt;/span&gt; &lt;span class="number"&gt;0.5&lt;/span&gt;&lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;round&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@fix_boxes_offset&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;step&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_f&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt; &lt;span class="number"&gt;2.0&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@x&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;[];&lt;/span&gt; &lt;span class="attribute"&gt;@x&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="attribute"&gt;@min&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="attribute"&gt;@fix_boxes_offset&lt;/span&gt;&lt;br /&gt;  &lt;span class="ident"&gt;max&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;array&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;max&lt;/span&gt;&lt;br /&gt;  &lt;span class="keyword"&gt;while&lt;/span&gt; &lt;span class="attribute"&gt;@x&lt;/span&gt;&lt;span class="punct"&gt;[-&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;max&lt;/span&gt; &lt;span class="punct"&gt;-&lt;/span&gt; &lt;span class="attribute"&gt;@fix_boxes_offset&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;   &lt;span class="attribute"&gt;@x&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="attribute"&gt;@x&lt;/span&gt;&lt;span class="punct"&gt;[-&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="ident"&gt;step&lt;/span&gt;&lt;br /&gt;  &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@max&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@x&lt;/span&gt;&lt;span class="punct"&gt;[-&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;];&lt;/span&gt; &lt;span class="attribute"&gt;@step&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;step&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@y&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Array&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;h_class&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="attribute"&gt;@max&lt;/span&gt;&lt;span class="punct"&gt;)+&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;0&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="ident"&gt;array&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt;&lt;span class="punct"&gt;{|&lt;/span&gt;&lt;span class="ident"&gt;i&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;push&lt;/span&gt; &lt;span class="ident"&gt;i&lt;/span&gt;&lt;span class="punct"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;push&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="comment"&gt;# if x&amp;lt;@min or @max&amp;lt;x then return; end;&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@y&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;h_class&lt;/span&gt;&lt;span class="punct"&gt;([[&lt;/span&gt;&lt;span class="attribute"&gt;@min&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;max&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="attribute"&gt;@max&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;min&lt;/span&gt;&lt;span class="punct"&gt;)]+=&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;br /&gt;  &lt;span class="constant"&gt;self&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;fig_name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;histogram&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;fig_dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;x_lab&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;y_lab&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;i_xtics&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt;&lt;span class="number"&gt;10&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;br /&gt;  &lt;span class="ident"&gt;i_file&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;postscript eps color enhanced&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;i_size&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;0.5,0.5&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;i_style&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;fill solid 0.5 border&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="attribute"&gt;@y&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="number"&gt;0&lt;/span&gt;&lt;br /&gt;  &lt;span class="constant"&gt;Gnuplot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;open&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;gp&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;&lt;br /&gt;   &lt;span class="constant"&gt;Gnuplot&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="ident"&gt;gp&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;term&lt;/span&gt; &lt;span class="ident"&gt;i_file&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;output&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{fig_dir}&lt;/span&gt;/&lt;span class="expr"&gt;#{fig_name}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;autoscale&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;size&lt;/span&gt; &lt;span class="ident"&gt;i_size&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;xrange&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;[&lt;span class="expr"&gt;#{@x[0] - @fix_boxes_offset - 1}&lt;/span&gt;:&lt;span class="expr"&gt;#{@x[-1] + @fix_boxes_offset + 1}&lt;/span&gt;]&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;xtics&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{i_xtics}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;yrange&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;[0:&lt;span class="expr"&gt;#{@y.max * 1.1}&lt;/span&gt;]&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;notitle&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;xlabel&lt;/span&gt; &lt;span class="ident"&gt;x_lab&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;ylabel&lt;/span&gt; &lt;span class="ident"&gt;y_lab&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;style&lt;/span&gt;  &lt;span class="ident"&gt;i_style&lt;/span&gt;&lt;br /&gt;    &lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;data&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;  &lt;br /&gt;     &lt;span class="constant"&gt;Gnuplot&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;DataSet&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;([&lt;/span&gt;&lt;span class="attribute"&gt;@x&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="attribute"&gt;@y&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;ds&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;&lt;br /&gt;      &lt;span class="ident"&gt;ds&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;with&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;boxes&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      &lt;span class="ident"&gt;ds&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;title&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;step = &lt;span class="expr"&gt;#{@step}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;     &lt;span class="punct"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class="punct"&gt;]&lt;/span&gt;&lt;br /&gt;   &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt; &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;#Example&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="global"&gt;$0&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="constant"&gt;__FILE__&lt;/span&gt; &lt;span class="keyword"&gt;then&lt;/span&gt;&lt;br /&gt; &lt;span class="ident"&gt;a&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;3&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;32&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;23&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;43&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;54&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;55&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;60&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;&lt;br /&gt; &lt;span class="ident"&gt;hist&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;GnuplotHistogram&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;a&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;5&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span class="ident"&gt;hist&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;plot&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;test.eps&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;test&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;test_Y&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="number"&gt;5&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7601100319640091385?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7601100319640091385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7601100319640091385' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7601100319640091385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7601100319640091385'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/05/plot-histogram-using-gnuplot-and-ruby.html' title='plot a histogram using gnuplot and ruby'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-3534932976716215662</id><published>2009-02-07T05:44:00.006+09:00</published><updated>2009-05-28T20:43:23.863+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>when auto boxing and unboxing happens in codes using java generic</title><content type='html'>auto boxing and unboxing in java converts 'int' like primitive types variables to 'Integer' like objects.&lt;br /&gt;One thing is the generic type checking always let the primitive type pass!!&lt;br /&gt;today i found a bug in some code due to that.&lt;br /&gt;&lt;br /&gt;the following will compile successfully when JDK &amp;gt;= 1.5, since generic is introduced in 1.5. autoboxing and unboxing also.&lt;br /&gt;&lt;pre&gt;int i = 1;&lt;br /&gt;LinkedList&amp;lt;Integer&amp;gt; listOfIntSet = new LinkedList&amp;lt;Integer&amp;gt;();&lt;br /&gt;if (listOfIntSet.contains(i)) {&lt;br /&gt; System.out.println(&amp;quot;!! this had better to be found by compiler&amp;quot;);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;the code above can pass the compile. and be run silently in the running. =, =&lt;br /&gt;the strong type language here is not strong. =, = , due to the generic implementation model in java.&lt;br /&gt;&lt;br /&gt;this point is worth remember.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-3534932976716215662?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/3534932976716215662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=3534932976716215662' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3534932976716215662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3534932976716215662'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/02/when-auto-boxing-and-unboxing-happens.html' title='when auto boxing and unboxing happens in codes using java generic'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-2905478868171813867</id><published>2009-02-05T06:10:00.011+09:00</published><updated>2009-05-28T20:45:14.805+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>how to measure execution time in milliseconds, microseconds in cpp</title><content type='html'>&amp;lt;time.h&amp;gt; only provides the way to get difftime in seconds. however, the algorithm i'm working with these days runs pretty fast sometime. in order to measure the milliseconds, i need to find some way. here's the solution, paste here for future use.&lt;br /&gt;&lt;br /&gt;solution, use &amp;lt;sys/time.h&amp;gt; instead. there's a 'gettimeofday' funtion whose signiture is : int gettimeofday(struct timeval *tv, struct timezone *tz);  the first parameter struct timeval has two members:&lt;br /&gt;time_t    tv_sec; //seconds&lt;br /&gt;suseconds_t    tv_usec; //microseconds part of the time&lt;br /&gt;in most cases, microseconds is enough to be used as measurement.&lt;br /&gt;&lt;pre&gt;#include &amp;lt;sys/time.h&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    struct timeval begin, end;&lt;br /&gt;gettimeofday(&amp;amp;begin, NULL);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    //algortihm to be measured here. ......&lt;br /&gt;&lt;br /&gt;gettimeofday(&amp;amp;end, NULL);&lt;br /&gt;    double diff_sec = difftime(end.tv_sec, begin.t_sec) * 1000000;&lt;br /&gt;    double diff_milli = difftime(end.tv_usec, begin.tv_usec);&lt;br /&gt;cout&amp;lt;&amp;lt;&amp;quot;diff (in milliseconds): &amp;quot;&amp;lt;&amp;lt;diff_sec + diff_milli&amp;lt;&amp;lt;endl;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;if need to use second, the above way works too. however if we don't wanna use &amp;lt;sys/time.h&amp;gt;, but &amp;lt;time.h&amp;gt; use the method &lt;a href="http://www.cplusplus.com/reference/clibrary/ctime/difftime.html"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-2905478868171813867?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/2905478868171813867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=2905478868171813867' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2905478868171813867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2905478868171813867'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/02/how-to-measure-execution-time-in.html' title='how to measure execution time in milliseconds, microseconds in cpp'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6062372866758863719</id><published>2009-01-31T21:24:00.002+09:00</published><updated>2009-01-31T21:26:12.795+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>get hardware details in ubuntu</title><content type='html'>writing experiment part of a paper requires listing the machine specifications, however, after several minutes of navigating the menu in ubuntu, i can not find such functions like windows device manager. so, google it, &lt;a href="http://ubuntu.wordpress.com/2007/02/18/find-hardware-specs-details-on-your-computer/"&gt;here&lt;/a&gt;'s an excellent answer. just write it down for remind. in the link, there's a handy way to use lshw to create a html file of the specs. cool.&lt;br /&gt;&lt;br /&gt; sudo lshw -html &amp;gt; hwspec.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6062372866758863719?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6062372866758863719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6062372866758863719' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6062372866758863719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6062372866758863719'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/get-hardware-details-in-ubuntu.html' title='get hardware details in ubuntu'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-2870571590980303278</id><published>2009-01-28T23:25:00.002+09:00</published><updated>2009-01-28T23:26:31.848+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>TreeMap and HashMap</title><content type='html'>The Map interface in java collection framework is pretty handy. There're several implementations of this interface, such as HashMap and TreeMap. The hashCode(), equals(), and compareTo() are several methods need to be implemented when using own classes as hash keys. However, the implementation requirement of own classes to HashMap and TreeMap are different, which I realized today.&lt;br /&gt; &lt;b&gt;&lt;br /&gt;HashMap - requires equals() and hashCode()&lt;/b&gt;&lt;br /&gt;HashMap is a implementation of Map using the hashtable data structure, each object as the key need to implement both equals() and hashCode() methods in Object. Equals() is to be used when get(key) is invoked. Since one key is associated with a list of values in the hashtable data structure, to find the exact object in the list, equals() is needed. hashCode() method is to be used by system libraries as hash key. Different object will be assigned to different hash lists. HashCode's implementation has several rules, such as different calls on the same object, the hashCode value should be the same. If two obejcts are equal according to equals(), then their hashCode() should be the same also, and etc.&lt;br /&gt;&lt;br /&gt;The best hashCode() usually gives different objects different values according to their members. Thus the access cost can be reduced to O(1). However, such a kind of hashCode sometimes is really hard to find or even impossible to be found. For example, in Java, the cpp &amp;lt;util&amp;gt; Pair class is not provided as a standard class, assuming our pair class has two integer members, say x and y, how to write a hash function, f(x,y), guarantees different x and y having different f(x,y) ? Normal way to implement this is f(x,y) = x * big_prime + y, though the access cost will increase when different values of x, y increases.&lt;br /&gt;&lt;br /&gt;If we don't want to implement the equals and hashCode, but wanna use Map interface, one possible solution is use TreeMap.&lt;br /&gt;&lt;b&gt;&lt;br /&gt;TreeMap - requires compareTo()&lt;/b&gt;&lt;br /&gt;TreeMap is a implementation of Map using red black tree according to jdk doc. So the access time is O(lgN), sometimes it's better than the normalized hashMap. More important, we don't need to implement equals and hashCode. The equivalence check is done by calling compareTo twice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-2870571590980303278?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/2870571590980303278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=2870571590980303278' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2870571590980303278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2870571590980303278'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/treemap-and-hashmap.html' title='TreeMap and HashMap'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-5631396065522011498</id><published>2009-01-25T23:16:00.002+09:00</published><updated>2009-01-25T23:17:31.472+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>remote control ubuntu from windows xp</title><content type='html'>these days, the weather in seoul is continuously snowing. also since the lunar new year period, few people are in the lab. the machine i'm working on is a ubuntu desktop. i plan to work in the dorm using the laptop. after searching google, &lt;a href="http://ubuntuswitch.wordpress.com/2007/07/01/securely-remote-control-your-ubuntu-via-putty-from-a-windows-host-vncssh/"&gt;the post&lt;/a&gt; is really useful. i failed to use vnc service in ubuntu before, even though i've set the preference of remove control. after read the post, i found the reason was lack of SSH tunnel setting. =, = anyway, everything works well now. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-5631396065522011498?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/5631396065522011498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=5631396065522011498' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5631396065522011498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5631396065522011498'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/remote-control-ubuntu-from-windows-xp.html' title='remote control ubuntu from windows xp'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-9087892263412912339</id><published>2009-01-24T10:14:00.002+09:00</published><updated>2009-01-24T10:15:10.247+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>getline and eof</title><content type='html'>cpp's library is pretty tricky. today encounter anther problem. when use getline and eof together, if the code is not carefully written, may result in errors. here's the example.&lt;br /&gt;&lt;br /&gt;ifstream input(some_file, ios::in)&lt;br /&gt;string line;&lt;br /&gt;if (!getline(input, line).eof()) {&lt;br /&gt;        cout&amp;lt;&amp;lt;line&amp;lt;&amp;lt;endl;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;pretty simple. the code will print all the lines in the file. the tricky part is the &lt;b&gt;getline(..).eof()&lt;/b&gt;.&lt;br /&gt;file1:&lt;br /&gt;a&lt;br /&gt;b&lt;br /&gt;c[EOF]&lt;br /&gt;&lt;br /&gt;the result of print file1 using that code will be:&lt;br /&gt;a&lt;br /&gt;b&lt;br /&gt;&lt;br /&gt;the last line 'c' will not be printed, since the [EOF] is in the last line. maybe that's the reason that the ruby interpertaor requires the ruby file should contain a empty last line with EOF. almost half a day is spent on this part when porting a ruby code to cpp code. the same file result in different results. however, the file reading part has been ignored for testing, since i thought it's easy. the fact is not.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-9087892263412912339?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/9087892263412912339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=9087892263412912339' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/9087892263412912339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/9087892263412912339'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/getline-and-eof.html' title='getline and eof'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-689218566728888247</id><published>2009-01-23T06:28:00.002+09:00</published><updated>2009-01-23T06:29:00.615+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>vector &amp; iterator combination hell in stl cpp</title><content type='html'>since iterator is implemented as out iterator pattern in stl, a vector object can not update those iterators referencing some part of it. when the vector is resized, all the iterators will becomes invalid, and thus cause the segment fault. =, = writing cpp is really trying. you should know the detail of its library model, which however requires time to be got familiar with. comparing with java, although the model is similar, however, jvm can produce much more meaningful information other than only a &amp;#39;segment fault&amp;#39; which can be caused by many kinds of mistakes.&lt;br&gt; &lt;br&gt;and gdb is really handy. at least we can easily know which line happens &amp;#39;segment fault&amp;#39; with very basic gdb instructions. today stuck in this part again, however, the debug time is much less comparing with last time. it seems to me that time and experience are important factors for a professionals, at least developers.&amp;nbsp; &lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-689218566728888247?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/689218566728888247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=689218566728888247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/689218566728888247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/689218566728888247'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/vector-iterator-combination-hell-in-stl.html' title='vector &amp; iterator combination hell in stl cpp'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-249644232313256874</id><published>2009-01-22T21:28:00.048+09:00</published><updated>2009-01-22T22:16:49.756+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='blogger'/><category scheme='http://www.blogger.com/atom/ns#' term='daily life'/><title type='text'>a interesting test about right major</title><content type='html'>Here's the &lt;a href="http://quizfarm.com/quizzes/new/ohiojoshua/what-major-is-right-for-you"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;You Scored as &lt;b&gt;Psychology/Sociology&lt;/b&gt;&lt;p&gt;You should strongly consider majoring (or minoring) in Psychology, Sociology, or related majors (e.g., Counseling, Industrial-Organizational (I-O) Psychology, Social Work, or other social science majors).&lt;br /&gt;&lt;br /&gt;It is possible that the best major for you is your 2nd, 3rd, or even 5th listed category, so be sure to consider ALL majors in your OTHER high scoring categories (below). You may score high in a category you didnt think you would--it is possible that a great major for you is something you once dismissed as not for you. The right major for you will be something 1) you love and enjoy and 2) are really great at it.&lt;br /&gt;&lt;br /&gt;Consider adding a minor or double majoring to make yourself standout and to combine your interests. Psychology and Sociology are both great minors to add to any major. Please post your results in your myspace/blog/journal.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Psychology/Sociology 80%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Physics/Engineering/Computer 75%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;History/Anthropology/LiberalArts 75%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Education/Counseling 69%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;HR/BusinessManagement 69%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Mathematics/Statistics 69%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Accounting/Finance/Marketing 63%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;English/Journalism/Comm 63%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;French/Spanish/OtherLanguage 63%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Biology/Chemistry/Geology 63%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Religion/Theology 56%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;PoliticalScience/Philosophy 50%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Visual&amp;amp;PerformingArts 44%&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;Nursing/AthleticTraining/Health 44%&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;btw, it seems the html table tag works not very well with blogger. if the article contains some table with no format settings, there'll be a large number of empty lines? &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-249644232313256874?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/249644232313256874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=249644232313256874' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/249644232313256874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/249644232313256874'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/interesting-test-about-right-major.html' title='a interesting test about right major'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-62375812131508199</id><published>2009-01-22T16:34:00.002+09:00</published><updated>2009-01-22T16:46:48.614+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><title type='text'>ruby's array delete</title><content type='html'>It seems that the delete method of array class uses different conventions comparing with other methods. The '!' usually used after a method in ruby means that the method will change the status of the object. However, 'delete' of array is against that rule. I encountered the problem today, and spent some time on debugging. Pretty annoying. Also, copy is copying reference by default, not by value comparing with c++.&lt;br /&gt;&lt;br /&gt;the next example shows it more clearly:&lt;br /&gt;irb&amp;gt; a = [1,2,3]&lt;br /&gt;=&amp;gt; [1,2,3]&lt;br /&gt;irb&amp;gt; a.delete 1&lt;br /&gt;=&amp;gt; [2,3]&lt;br /&gt;irb&amp;gt; a&lt;br /&gt;=&amp;gt; [2,3]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-62375812131508199?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/62375812131508199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=62375812131508199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/62375812131508199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/62375812131508199'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/rubys-array-delete.html' title='ruby&apos;s array delete'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-4999755360923017535</id><published>2009-01-15T09:05:00.002+09:00</published><updated>2009-01-15T09:05:33.723+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='synthetic data generation'/><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>to calculate the cdf and inverse cdf of normal distribution in c++</title><content type='html'>Also in the synthetic data generation, it requires calculating inverse cdf.&lt;br /&gt;Without using boost or heavy libraries, here's the links to the codes.&lt;br /&gt;&lt;br /&gt;calculate the cdf :&lt;br /&gt;&lt;a href="http://www.sitmo.com/doc/Calculating_the_Cumulative_Normal_Distribution"&gt;http://www.sitmo.com/doc/Calculating_the_Cumulative_Normal_Distribution&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;inverse cdf:&lt;br /&gt;&lt;a href="http://home.online.no/%7Epjacklam/notes/invnorm/"&gt;http://home.online.no/~pjacklam/notes/invnorm/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-4999755360923017535?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/4999755360923017535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=4999755360923017535' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4999755360923017535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4999755360923017535'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/to-calculate-cdf-and-inverse-cdf-of.html' title='to calculate the cdf and inverse cdf of normal distribution in c++'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-2566778385762039272</id><published>2009-01-15T05:41:00.002+09:00</published><updated>2009-01-15T05:43:12.843+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='synthetic data generation'/><title type='text'>A good library for generating synthetic data set</title><content type='html'>I'm working on generating synthetic data set for an algorithm these days. The generation model changes a lot, including the distributions we select. To implement a distribution efficiently and accurately is not that easy. The synthetic data generation code was originally maintained in ruby. However, in my limited knowledge, there were few random number distribution codes available in ruby. Recently I found the &lt;a href="http://acs.lbl.gov/%7Ehoschek/colt/index.html" target="_blank"&gt;Colt &lt;/a&gt;lib, which provides a set of Open Source Libraries for High Performance Scientific and Technical Computing in Java, as they declare in the introduction. This library is supported by CERN - European Organization for Nuclear Research. Pretty handy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-2566778385762039272?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/2566778385762039272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=2566778385762039272' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2566778385762039272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2566778385762039272'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2009/01/good-library-for-generating-synthetic.html' title='A good library for generating synthetic data set'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-4908041174003976168</id><published>2008-10-31T20:06:00.002+09:00</published><updated>2008-10-31T20:07:29.992+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>the copy constructor makes people crazy</title><content type='html'>in c++, it always copies those values. this makes the pointer management really tricky. just like the last month post, value is by default. when return value happens, means all the pointers to the old value are invalid. = -b this time, the object there're some self indexes structures. since each object will not share such structure, the structure is declared as objects also. to visit this structure, i also need to introduce some orders. the orders are maintained as pointers to the indexes structure. After 2 hours debug, i found when the copy happens, all the index structure orders becomes invalid. = -. T, T cxx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-4908041174003976168?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/4908041174003976168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=4908041174003976168' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4908041174003976168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4908041174003976168'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/10/copy-constructor-makes-people-crazy.html' title='the copy constructor makes people crazy'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-8005432095150443170</id><published>2008-10-29T06:36:00.002+09:00</published><updated>2008-10-29T06:36:39.661+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>pointer to a vector element, caution !</title><content type='html'>have a pointer to a vector element, then just push_back element to the vector, then the pointer will be invalid when vector enlarge the content. &lt;div&gt;e.g:&lt;/div&gt;&lt;div&gt;vector&amp;lt;A&amp;gt; vec;&lt;/div&gt;&lt;div&gt;vec.push_back(A(1));&lt;/div&gt; &lt;div&gt;A* p_a = &amp;amp;vec[0];&lt;/div&gt;&lt;div&gt;vec.push_back(A(2));&lt;/div&gt;&lt;div&gt;vec.push_back(A(3));&lt;/div&gt;&lt;div&gt;...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then try to access p_a, it will report wild pointer error ... &lt;/div&gt;&lt;div&gt;2 hours debug ... T, T&lt;/div&gt; &lt;div&gt;being too flexible sometime means disaster. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-8005432095150443170?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/8005432095150443170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=8005432095150443170' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8005432095150443170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8005432095150443170'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/10/pointer-to-vector-element-caution.html' title='pointer to a vector element, caution !'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7818289521920327695</id><published>2008-10-28T04:30:00.002+09:00</published><updated>2008-10-28T04:31:01.893+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>convert int to string, cpp</title><content type='html'>&lt;a href="http://notfaq.wordpress.com/2006/08/30/c-convert-int-to-string/#"&gt;http://notfaq.wordpress.com/2006/08/30/c-convert-int-to-string/#&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to convert an int (or any other numeric type, e.g., float, double, etc.) to string, you can use:&lt;/div&gt; &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#include &amp;lt;sstream&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int i = 5;&lt;/div&gt;&lt;div&gt;std::string s;&lt;/div&gt;&lt;div&gt;std::stringstream out;&lt;/div&gt;&lt;div&gt;out &amp;lt;&amp;lt; i;&lt;/div&gt;&lt;div&gt;s = out.str();&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7818289521920327695?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7818289521920327695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7818289521920327695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7818289521920327695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7818289521920327695'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/10/convert-int-to-string-cpp.html' title='convert int to string, cpp'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-4893016962361752615</id><published>2008-10-23T20:37:00.001+09:00</published><updated>2008-10-23T20:41:39.328+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>about exporting query results in mysql</title><content type='html'>Though dumping database can be done easily in mysql by the mysqldump command, it can not be used to export query result into files. Using sql to do data preprocessing is very useful approach in various cases. After reading the mysql cookbook, there're two ways:&lt;div&gt; 1. select ... into outfile 'filename'&lt;/div&gt;&lt;div&gt;this is a specific sql pattern supported by the mysql. when we're work on the server machine and wanna export the file on the sever itself, then we can use this command. The file in default will be output into the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;data&lt;/span&gt; directory of mysql installation. Another thing is we need to give mysql command the file r/w privileges. &lt;/div&gt; &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. mysql -e 'select ....' -N &lt;span class="Apple-style-span" style="font-style: italic;"&gt;dbname&lt;/span&gt; &amp;gt; &lt;span class="Apple-style-span" style="font-style: italic;"&gt;filename&lt;/span&gt; -u &lt;span class="Apple-style-span" style="font-style: italic;"&gt;user &lt;/span&gt;-p&lt;/div&gt; &lt;div&gt;if we can not use the server machine, for example accessing the server from a client machine, then this command can produce what we want. -e specified the query in quotes. -N tells mysql to produce the output file without the column names. &lt;span class="Apple-style-span" style="font-style: italic;"&gt;dbname&lt;/span&gt; is the database name where the query run against, -u is follows the user who have privilege to access the db, -p is the password. &lt;/div&gt; &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;both commands will add the tab mark between different files and new line mark between different rows by default. there're lots of commands to change the output format, that is omitted here. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-4893016962361752615?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/4893016962361752615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=4893016962361752615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4893016962361752615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4893016962361752615'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/10/about-exporting-query-results-in-mysql.html' title='about exporting query results in mysql'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6805754859832147086</id><published>2008-10-18T13:49:00.002+09:00</published><updated>2008-10-18T13:49:30.024+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><title type='text'>use Marshal instead of YAML when interoperability is not important</title><content type='html'>&lt;div dir="ltr"&gt;YAML is slow. Even in research dataset, the data can be pretty huge, if interoperability is not that important, use Marshal.dump/load to manipulate the data. It is very fast, but the file is not readable by both people and other languages. I've some experience waiting for the YAML dumping some 50000 elements hash for more than three hours. Ater a quick marshalling, better let the YAML run again slowly when sleeping if you also want interoperability. &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6805754859832147086?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6805754859832147086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6805754859832147086' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6805754859832147086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6805754859832147086'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/10/use-marshal-instead-of-yaml-when.html' title='use Marshal instead of YAML when interoperability is not important'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-5358237160984430093</id><published>2008-09-09T20:35:00.002+09:00</published><updated>2008-09-09T20:35:59.735+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>default is by value</title><content type='html'>&lt;div dir="ltr"&gt;not like in java, everything is by default by reference. in c++, is by value. dreaming in java, but writing c++ gave me a nightmare yesterday night. the story is something like this:&lt;br /&gt;&lt;br /&gt;class Family {&lt;br /&gt;    vector&amp;lt;Child&amp;gt; children;&lt;br /&gt;    vector&amp;lt;Child&amp;gt; getChildren() { return children; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;the calling code to the children in the family is by calling getChildren. then iterators are initialized like this:&lt;br /&gt;&lt;br /&gt;vector&amp;lt;Child&amp;gt;::iterator pos = ourfamily.getChildren().begin();&lt;br /&gt;vector&amp;lt;Child&amp;gt;::iterator end = ourfamily.getChildren().end();&lt;br /&gt;while(pos != end) {&lt;br /&gt;    //print children&lt;br /&gt;    pos++;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;another way to do this is like this way:&lt;br /&gt;&lt;br /&gt;vector&amp;lt;Child&amp;gt;::iterator pos = ourfamily.getChildren().begin();&lt;br /&gt;while (pos != ourfamily.getChildren().end()) {&lt;br /&gt;    //print children&lt;br /&gt;    pos++;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;guess what? the two types of calling results in different print outs, not the orders, i mean the number of children. i thought i was wired at the beginning, is that a bug in the libstdc++ ? since, if the family is large enough, there'll be some segement fault. by checking everywhere, 3 hours passed.&lt;br /&gt;&lt;br /&gt;in the morning, my post in some forum got a reply, the answer is :&lt;br /&gt;&lt;br /&gt;vector&amp;lt;Child&amp;gt;&lt;span style="font-size:6;"&gt;&lt;b&gt;&lt;span style="background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);"&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; getChildren() { return children; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;because of being lack of this reference marker, the iterator pos and end are iterators of two different temporate objects !! and the second way to iterator even worse, which generate more than two temporate objects. segement fault maybe because some pointers in the iterator implementation pointed to some taken addresses. = -&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DO REMEMBER: BY DEFAULT, CXX IS BY VALUE&lt;/span&gt;&lt;br /&gt;this is really easy to be forgot if we wrote other languages for a long time. 3 hours just for a reference marker. orz...&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-5358237160984430093?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/5358237160984430093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=5358237160984430093' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5358237160984430093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5358237160984430093'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/09/default-is-by-value.html' title='default is by value'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-1071885718611912189</id><published>2008-09-09T03:09:00.002+09:00</published><updated>2008-09-09T03:10:50.466+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cpp'/><title type='text'>DON'T generate too much temperate variables in c++</title><content type='html'>&lt;div dir="ltr"&gt;writing too much java or ruby makes people too comfortable. the prof asked me to rewrite the implementation in c++, so i turned to this these days. last time, i used c++ was back to the 2003. still undergraduate freshman. no experience with any programming language expect some qbasic. c++ to me at that time was ok. after that turned to java, then c++ turns to me very ugly. lots of things you need to consider, memory leaks, meaningless compiler errors, one mistake leads hundres of error complaint and etc. after 5 years, c++ to me know, changed a lot. namespaces give somewhat name seperations, stl seems not that bad, boost provides many features whoever no binary which needs compilation yourself == at least 2 hours if you're lucky. after struggling several days, i still did not feel any beauty in it, though i'll still use it.&lt;br /&gt;&lt;br /&gt;don't generate too much temperate variables in c++ since it has some copy constructor. if you defined a copy constructor, then any place the copy construction happens, the constructor will be used. but the problem is, without some knowledge about the circumenstance copy happens, the program is really tricky. programming methdology changed to agile these days. today lots of people do programming using those friendly langugages, can just refactoring without considering too much. however in c++, the situation is different. some step in refactoring leads to tricky problems, the reason of this maybe is its advantage : too many details. like this copy constructor.&lt;br /&gt;&lt;br /&gt;the class i'm working with is some basic data class representing IP concept. at first, only id and address, like IP(0, &lt;a href="http://192.168.1.1/"&gt;192.168.1.1&lt;/a&gt;), since i wanna use stl, for extension purpose, i override the default copy constructor. however, since the algorithm becomes complicated, some container sturcture added to the IP class, for example the history (map&amp;lt;int, vector&amp;lt;Site&amp;gt; &amp;gt; ). by forgetting modify the copy constructor, and my body reflection still in java and ruby something like that, the tricky happens:&lt;br /&gt;&lt;br /&gt;Ip aip = system.getAllIps.findById(1)&lt;br /&gt;aip.modify_history&lt;br /&gt;&lt;br /&gt;guess what, if you print system.getAllIps.findById(1).history, no modification happened!! the sin is that aip temporate variable. in java, it is just a reference, to the real place of that object. however, the assignment operation by default will call that copy constructor and generate one brand new object to you. as i forgot that, 1 hour spent on it. after reminding some memory back to five years ago, then this was fixed. T, T&lt;br /&gt;&lt;br /&gt;too many detail for a programming language to be industry wise used, is it a good idea or not ? maybe yes, maybe not. that's the powerness and productivity trade off in programming language design. most of application programmers who have not that much consideration on performance trend to be like those friendly. system programmer who has tough performance requirment tend to go to powerful first.&lt;br /&gt;&lt;br /&gt;anyway i still do not like it very much. too many detail but friendless is one reason, there're more.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-1071885718611912189?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/1071885718611912189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=1071885718611912189' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1071885718611912189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1071885718611912189'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/09/dont-generate-too-much-temperate.html' title='DON&apos;T generate too much temperate variables in c++'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7109680971296219256</id><published>2008-07-31T17:55:00.002+09:00</published><updated>2008-07-31T18:18:16.399+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>ubuntu, set resolution</title><content type='html'>&lt;div dir="ltr"&gt;the machine in the lab is weird. though the cpu is core due 2.8Ghz, the lab members use 2x256m memory, also one of the 256m memory is broken, the left memory only 248m. = =b i used this machine as a web server using some heavy j2ee servers. in the last few months, always experiencing out of memory exception. the good news is they gave me 1g memory today. sounds great. after i plug in the memory, something weird happended. the screen resolution is not correct. after checking xorg.conf and refer to several articles in the web, i realized that ubunt failed to recognize the monitor. so the resolution at most is 1280x1024, however, the monitor i used is a standard monitor, which means the highest resolution for the 17 inch screen would be 1024x768.&lt;br /&gt;&lt;br /&gt;the way to change the resolution is like this, modify the x configuration file, xorg.conf&lt;br /&gt;&lt;br /&gt;1. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup&lt;br /&gt;the reason the backup the xorg.conf is because X is famous for bad temper, when the configuration file is incorrect, we can not enter the gui. however, afterwards, we need to change this configuration file, we'd better backup it.&lt;br /&gt;&lt;br /&gt;2. sudo vim /etc/X11/xorg.conf&lt;br /&gt;found the Monitor section, change the monitor section according to the monitor model, the horizSync and vertRefresh should be contained somewhere in the monitor manual. if there's no manual or instruction, search the web using model number, it should be easy to find them. to define more resolution, change the Screen Section, Display sub section, add more resolution in the sub section. save the modifcation. restart X (ctrl + alt + backspace)&lt;br /&gt;&lt;br /&gt;Section "Monitor"&lt;br /&gt;    Identifier    "782LE"&lt;br /&gt;    Option        "DPMS"&lt;br /&gt;    HorizSync    30-80&lt;br /&gt;    VertRefresh    56-75&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section "Screen"&lt;br /&gt;    Identifier    "Default Screen"&lt;br /&gt;    Device        "Intel Corporation 82915G/GV/910GL Integrated Graphics Controller"&lt;br /&gt;    Monitor        "782LE"&lt;br /&gt;    DefaultDepth    24&lt;br /&gt;    SubSection "Display"&lt;br /&gt;        Modes        "1600x1200" "1280x960" "1280x1024" "1024x768" "800x600" "720x400" "640x480"&lt;br /&gt;    EndSubSection&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;3. change the resolution, from System --&amp;gt; Preferences --&amp;gt; Screen Resolution, there'll be more resolution to choose from.&lt;br /&gt;&lt;br /&gt;* If in the second step, the file fomrat is wrong, or the identifier is not right, the x will not be started properly, there'll be some configuration window pop out at low resolution, accept it temporaly. and copy the backup file to modified file, and restart x again, we'll back to the original state.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7109680971296219256?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7109680971296219256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7109680971296219256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7109680971296219256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7109680971296219256'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/ubuntu-set-resolution.html' title='ubuntu, set resolution'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7321102177351697188</id><published>2008-07-19T14:53:00.002+09:00</published><updated>2008-07-19T14:56:05.045+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ria'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='browser'/><title type='text'>firefox bookmarks and bookmak sync</title><content type='html'>&lt;div dir="ltr"&gt;i'm a big fan of &lt;a href="http://www.google.com/tools/firefox/browsersync/" target="_blank" class="l" onmousedown="return rwt(this,'','','res','1','AFQjCNGwdklORnRSO7e4Inov91iqmhizog','&amp;sig2=6slGTBgB-pM2-lRYeAWqnA')"&gt;&lt;em&gt;Google Browser&lt;/em&gt; Sync&lt;/a&gt; , however after firefox 3.0, google decided not keep supporting this product, since there're several other tools with the same functionality available. the key idea is to synchronize the browser metadatas with several computers. last year, i worked on more than 4 computers, thus this function is extremely useful.&lt;br /&gt;&lt;br /&gt;today, when i updated to firefox &lt;a href="http://2.0.0.16/"&gt;2.0.0.16&lt;/a&gt;, all my bookmarks lost. I think it was because, the google browser sync do not support this higher version or the dataset in the server was cleared to let people change to other tools. anyway, i've got the problem. here's the solution&lt;br /&gt;&lt;br /&gt;1. go to C:\Documents and Settings\[User Name]\Application Data\Mozilla\Firefox\Profiles\[A Dir Name]\bookmarkbackups&lt;br /&gt;    you can see lots of backups there. cool. pick some of them, for example a.html&lt;br /&gt;2. uninstall google browser sync, restart firefox&lt;br /&gt;3. Bookmarks =&amp;gt; Organize Bookmarks ... =&amp;gt; File ... =&amp;gt; Import ... =&amp;gt; a.html&lt;br /&gt;&lt;br /&gt;done. the problem is the cookie info maybe lost, i'm not sure.&lt;br /&gt;i'll install that firefox 3.0 and try molliza weaver.&lt;br /&gt;&lt;br /&gt;actually, these kinds of bookmarks service, like &lt;a href="http://del.us/"&gt;del.us&lt;/a&gt; can do lots of applications. with the dataset, we can do recommendation, not only new pages, also new people. we can also do search, usually the bookmark are selected by the users. these webpages are more valuable than some of others. it'll be another way to do better search. just not sure whether google stops supporting this product is right or not, however, the codes of google browser sync is available on google codes. good news.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7321102177351697188?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7321102177351697188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7321102177351697188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7321102177351697188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7321102177351697188'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/firefox-bookmarks-and-bookmak-sync.html' title='firefox bookmarks and bookmak sync'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-1432726311887158394</id><published>2008-07-17T18:10:00.002+09:00</published><updated>2008-07-17T18:12:59.886+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><title type='text'>another way to solve international encoding and decoding</title><content type='html'>&lt;div dir="ltr"&gt;from this site: &lt;a href="http://www.ruby-lang.org.cn/forums/viewthread.php?tid=601"&gt;http://www.ruby-lang.org.cn/forums/viewthread.php?tid=601&lt;/a&gt;&lt;br /&gt;there's another solution, other than the libcharguess one&lt;br /&gt;&lt;br /&gt;use rchardet instead, as said in the original post, this is a python char guess port.&lt;br /&gt;&lt;br /&gt;since the libcharguess, they do not provide any binary things in the sourceforge, and the compile file in based on linux environment.&lt;br /&gt;if we work on windows, install a cygwin for a quick demo program is too long. without compiling libcharguess, you can not use the ruby bind lib for libcharguess.&lt;br /&gt;&lt;br /&gt;so from this point of view, rchardet is good solution, of course, also combine using with iconv&lt;br /&gt;&lt;br /&gt;1. install rchardet, very trivial&lt;br /&gt;gem install rchardet&lt;br /&gt;&lt;br /&gt;that's it&lt;br /&gt;&lt;br /&gt;2. use it&lt;br /&gt;require 'rchardet'&lt;br /&gt;str = ...&lt;br /&gt;puts CharDet.detect(str).encoding&lt;br /&gt;&lt;br /&gt;then the encoding can be used in iconv, refer to the post &lt;a href="http://swimminginbits.blogspot.com/2008/06/use-iconv-libcharguess-solving.html"&gt;http://swimminginbits.blogspot.com/2008/06/use-iconv-libcharguess-solving.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-1432726311887158394?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/1432726311887158394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=1432726311887158394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1432726311887158394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/1432726311887158394'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/another-way-to-solve-international.html' title='another way to solve international encoding and decoding'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6095422496676313743</id><published>2008-07-14T20:51:00.002+09:00</published><updated>2008-07-14T20:54:50.253+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>ubuntu pure-ftpd add user</title><content type='html'>first time to add a user, log something here&lt;br /&gt;&lt;br /&gt;1. use apt-get to install pure-ftpd&lt;i&gt;&lt;br /&gt;sudo apt-get install pure-ftpd pure-ftpd-common&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;2. create ftpuser group&lt;br /&gt;&lt;i&gt;sudo groupadd ftpgroup&lt;/i&gt;&lt;i&gt;&lt;br /&gt;useradd -g ftpgroup -d /dev/null -s /etc ftpuser&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;3. create user&lt;i&gt;&lt;br /&gt;sudo &lt;/i&gt;&lt;i&gt;pure-pw useradd friends -u ftpuser -d /home/ftpusers/friends&lt;br /&gt;sudo pure-pw mkdb&lt;br /&gt;cd /etc/pure-ftpd/auth/&lt;br /&gt;sudo ln -s ../conf/PureDB 60pdb&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;4. restart server&lt;br /&gt;&lt;i&gt;sudo /etc/init.d/pure-ftpd restart&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;5. create the virtual user root directory&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo mkdir /home/ftpusers/friends&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo chmod 777 -R /home/ftpusers/friends&lt;br /&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;done&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6095422496676313743?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6095422496676313743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6095422496676313743' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6095422496676313743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6095422496676313743'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/ubuntu-pure-ftpd-add-user.html' title='ubuntu pure-ftpd add user'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-8166404927586518408</id><published>2008-07-09T00:12:00.003+09:00</published><updated>2008-07-09T00:15:18.807+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tomcat'/><category scheme='http://www.blogger.com/atom/ns#' term='opensource'/><title type='text'>enable access log in tomcat</title><content type='html'>wanna test some anonymity networking softwares, so set up a tomcat, the question is how to enable access log. after reading tomcat definitive guide, 2ed, here comes the answer. btw, that book is really good, also covers tomcat 6.&lt;br /&gt;&lt;br /&gt;uncomment these in server.xml of tomcat will enable the access log functionalities.&lt;br /&gt;&lt;br /&gt;&lt;Valve className="org.apache.catalina.valves.AccessLogValve"&lt;br /&gt;directory="logs" prefix="localhost_access_log."&lt;br /&gt;suffix=".txt" pattern="common" resolveHosts="false"/&gt;&lt;br /&gt;&lt;br /&gt;next step. try tor. one problem of tor is the limited tor node on the internet. what if all people who use tor can be a node, that'll be great.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-8166404927586518408?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/8166404927586518408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=8166404927586518408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8166404927586518408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8166404927586518408'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/enable-access-log-in-tomcat.html' title='enable access log in tomcat'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-8089683311201854230</id><published>2008-07-08T08:31:00.002+09:00</published><updated>2008-07-08T08:34:28.660+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>column store seems more and more popular</title><content type='html'>last year, did some survey about column store. mainly about vertica, however, the trail of vertica need human verification, it's hard to get that using a graduate student profile. the c-store paper seems charming, and vertica goes further. with column store other than row store, the compression techniques can be used more vastly and deeply, since usually lots of values in the same column have similar values or valuable rules, which is a good property for compression. the retrieve efficiency will be boosted also, since columns stored together, thus only needed column in the result will be returned, other columns will keep untouched. most olap apps are read dominant. so, column techniques are good for this case. though the insertion, modification and deletion will take more time in column. sybase iq used these technology long ago, however, no big influence in the industry.&lt;br /&gt;&lt;br /&gt;sofa, one size fit all, is a question or marketing strategy, proposed by mike stonebreaker to advertise his vertica in vldb last year, makes the industry looking that seriously again. sofa, key idea is nowadays the modern relational databases are becoming so huge, sql specification also hugs lots of rarely used, company specific features, these unnecessary features are not required by all kinds of applications. the db research fields are big fan to make any new data model be stored in the database, like store xml in relational database, store objects in relational database, even rdf and etc. the main reason is to reuse all the techniques in relational database. however, how much cost we payed for these kinds of one size fit all solutions. you can say, this sofa is a kind of marketing strategy by vertica, since business need stable and mature software.&lt;br /&gt;&lt;br /&gt;last year vldb, the best paper was using column store to store rdf format, by mit dna who is one key contributor in vertica and mit c-store. though idea is simple, pretty charming. most influence ideas are always simple. behind these kinds of facts, maybe we can learn something, how to choose the right time, how to use old ideas to develop new techniques when the environment changes. nod.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-8089683311201854230?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/8089683311201854230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=8089683311201854230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8089683311201854230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8089683311201854230'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/07/column-store-seems-more-and-more.html' title='column store seems more and more popular'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-3110382538833143210</id><published>2008-06-29T17:06:00.003+09:00</published><updated>2008-06-29T17:11:07.781+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='data mining'/><category scheme='http://www.blogger.com/atom/ns#' term='activerecord'/><category scheme='http://www.blogger.com/atom/ns#' term='data preprocess'/><title type='text'>Something frustrating in activerecord</title><content type='html'>yep, another data mining project started. during the last few months, i managed to work out the algorithm. the professor got me some real dataset in some company, now it's the time to try the new bees. as usual, try to dump the plain txt file into mysql and write ruby code to handle them, the main reason is ruby is pretty agile language. i mean you can modify it without lots of effort. just write the code and go. everything works well, like speak a language. pretty satisfied. data analysis work in my last few projects only use activerecord and did not use rails at all. the problem is activerecord 2.1.0 seems can only be a plain java bean like class, and can not have any self defined methods in it ?? i hope no. but why recently at least two times, my class which extends ActiveRecord::Base which i added some instances methods, the 'save' and 'create' in ActiveRecord just do not work at all. it always pops out some errors like this :&lt;br /&gt;&lt;br /&gt;transaction.rb line xxx, no delete method for NilClass&lt;br /&gt;&lt;br /&gt;I've no idea how to deal with this error yet. in my memory when i still work on web development, the activerecord did not have such errors. oops = - . my current solution is comment out all the self defined code only left activereocd specifed code there. like has_many, belongs_to, set_table_name. after the data import work, dump the database, and then add what code i want, and begin analysis. actually no solution in this case.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-3110382538833143210?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/3110382538833143210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=3110382538833143210' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3110382538833143210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/3110382538833143210'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/something-frustrating-in-activerecord.html' title='Something frustrating in activerecord'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-5802099586697136104</id><published>2008-06-25T21:08:00.003+09:00</published><updated>2008-06-25T21:14:57.136+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='standard'/><category scheme='http://www.blogger.com/atom/ns#' term='meta data'/><category scheme='http://www.blogger.com/atom/ns#' term='specification'/><title type='text'>Start working on XMP</title><content type='html'>Though I've some meta data experience since 2 years ago, these days are my first chance to work on something directly related to meta. XMP = Extensible Meta data Platform , which is an open source meta data standard and toolkit. With it, we can embed meta data in the file, and query, modify and delete them when the file created, updated, being operated and etc. This BSD based standard is published by Adobe lead group. W3C said that it is important standard on its semantic web stacks, however they wanna work out something newer than XPM. Adobe disagree that the community need another one. Still reading the specification about it, seems interesting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-5802099586697136104?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/5802099586697136104/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=5802099586697136104' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5802099586697136104'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/5802099586697136104'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/start-working-on-xmp.html' title='Start working on XMP'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-7592815229263683728</id><published>2008-06-19T02:26:00.002+09:00</published><updated>2008-06-19T02:38:34.221+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><title type='text'>use iconv &amp; libcharguess solving international encoding problem</title><content type='html'>though last post said that the ruby on ubuntu was frustrating. anyhow, there's a old saying that if it is gold, it will shine. using iconv and libcharguess really solved the problem. the steps are as follows&lt;br /&gt;&lt;br /&gt;1. get &lt;a href="http://libcharguess.sourceforge.net/"&gt;libcharguess &lt;/a&gt;at sourceforge&lt;br /&gt;2. go to the directory ./configure&lt;br /&gt;3. make install&lt;br /&gt;4. make check, if nothing outputs, you're done&lt;br /&gt;5. sudo make install,&lt;br /&gt;6. get &lt;a href="http://raa.ruby-lang.org/project/charguess/"&gt;charguess &lt;/a&gt;at ruby-lang&lt;br /&gt;7. go to the directory, cp libcharguess-dir/cpp/charguess.h to the ungzip directory&lt;br /&gt;8. ruby -r mkmf extconf.rb, if mkmf missing, refer to the last post&lt;br /&gt;9. ruby sample.rb, if something end with -JP print out, we've done&lt;br /&gt;&lt;br /&gt;by getting these two libraries. the 'charguess' can be required can used sweetly.&lt;br /&gt;require 'charguess'&lt;br /&gt;&lt;br /&gt;somestring_encoding = CharGuess::guess somestring&lt;br /&gt;&lt;br /&gt;if somestring is latin1 maybe, the somestring_encoding will be nil , otherwise it will be the guessing encoding. use the encoding and target encoding in the Iconv constructor:&lt;br /&gt;&lt;br /&gt;converted_string = Iconv.new(target_encoding, somestring_encoding).iconv(somestring)&lt;br /&gt;&lt;br /&gt;the string can be converted well. cool.  &lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-7592815229263683728?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/7592815229263683728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=7592815229263683728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7592815229263683728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/7592815229263683728'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/use-iconv-libcharguess-solving.html' title='use iconv &amp; libcharguess solving international encoding problem'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-8885419236680835268</id><published>2008-06-19T02:23:00.001+09:00</published><updated>2008-06-19T02:23:39.162+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>ruby on ubuntu really makes people frustrating, at least me</title><content type='html'>still working on that ftp search. the first task was crawl several ftp file information and make an index. however, the directory of some ftp including non latin1 encodings. when save that into mysql which i've already configure the table to be utf8, it always can not interpret correctly. so, i turn to ruby cookbook. the first section i've found asking me to add $KCODE='u' and require 'jcode' at the beginning of the source code. i did it, but did not work. i guess maybe the ftp site return the string, its encoding need to be changed to utf8. so i turned to the second section in ruby cookbook, it told me that use iconv lib. well sounds good. but i don't know the encoding which ftp site returned. well, well, well, the great book told me you can use libcharguess, which is an sourceforge hosted open source library. also to use that library you need to install the ruby extensions. these two things come from different sites.&lt;br /&gt;&lt;br /&gt;that's only the first part of the story. when i get both libraries, make install both of them. however the ruby extension gave me some extconf.rb file to use, since in ruby, make file sometimes is like that way. run it, = = require 'mkmf' error, that one is not found. - = how would that happen ... amazingly google gives me one harvard law school blog, which including some illustration, the mkmf is in the ubuntu ruby1.8-dev package. we need to install that first. - = . after that, the make file finally successfully created. - -&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-8885419236680835268?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/8885419236680835268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=8885419236680835268' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8885419236680835268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/8885419236680835268'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/ruby-on-ubuntu-really-makes-people.html' title='ruby on ubuntu really makes people frustrating, at least me'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-597783426578224722</id><published>2008-06-18T22:00:00.001+09:00</published><updated>2008-06-18T22:02:14.377+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='activerecord'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>Net::FTP of ruby on windows, and ubuntu: No such file or directory - /tmp/mysql.sock</title><content type='html'>I haven't used rails for a long time, since the major was slightly changed, from software engineering which is more practical to data mining. these days, i wanna build the community ftp search site for friends, so i turn to ruby again. i really like coding with it. the first thing was very strange that&lt;br /&gt;&lt;br /&gt;Net::FTP of ruby seems not working very well on windows, look at the code&lt;br /&gt;&lt;br /&gt;require 'net/ftp'&lt;br /&gt;Net::FTP.open('host', 'user', 'pass') do |ftp|&lt;br /&gt;  puts ftp.pwd    # this works&lt;br /&gt;   ftp.list do |file|   # list and its alias, 'ls', 'dir', does not work&lt;br /&gt;    puts file&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;the pwd works pretty well, then the 'list' or 'ls', 'dir' just stuck there, there's little resources about that online. surprisingly, the same code works prefect well on ubuntu. So, i think it's the problem of the windows distribution of ruby.&lt;br /&gt;&lt;br /&gt;since the piece of code works well on ubuntu, the next thing was making the rails run on the machine. the mysql.socket in ubuntu at default is not under /tmp/mysql.socket, the file is located at /var/run/mysqld/mysqld.socket. the location of this file can be get from /etc/mysql/my.cnf . by pointing this file at activerecord configure, everything should be all right.&lt;br /&gt;&lt;br /&gt;the last thing i wanna mention is, the activerecord 2.1.0 to me seems having some strange behavior on the ubuntu, the following code&lt;br /&gt;&lt;br /&gt;def Test&lt;br /&gt;   set_table_name 'test'&lt;br /&gt;   attri_reader :id, :text  # this line has problem&lt;br /&gt;&lt;br /&gt;    def initialize&lt;br /&gt;        @text = 'somevalue' # this value will not store&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;when i call&lt;br /&gt;&lt;br /&gt;Test.new.save&lt;br /&gt;&lt;br /&gt;the error will occur: activerecord transaction blablabla 'delete' is not defined&lt;br /&gt;&lt;br /&gt;but the same code runs perfectly on windows&lt;br /&gt;&lt;br /&gt;is there anything wrong with my linux ruby settings ? or the distribution itself has something wrong ?&lt;br /&gt;the activerecord i installed it by&lt;br /&gt;&lt;br /&gt;sudo apt-get rubygems&lt;br /&gt;gem install rails --include-dependencies&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-597783426578224722?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/597783426578224722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=597783426578224722' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/597783426578224722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/597783426578224722'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/netftp-of-ruby-on-windows-and-ubuntu-no.html' title='Net::FTP of ruby on windows, and ubuntu: No such file or directory - /tmp/mysql.sock'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-2418850300417164985</id><published>2008-06-18T18:00:00.003+09:00</published><updated>2008-06-18T18:04:24.572+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='persistent'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><title type='text'>mysql 5 create table attribute name can not be 'group' ?</title><content type='html'>it's pretty strange that the create table clause in mysql 5, can not use the 'group' as the attribute name. i tried that on ubuntu today. the way to fix the query was to change 'group' to other names.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-2418850300417164985?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/2418850300417164985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=2418850300417164985' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2418850300417164985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/2418850300417164985'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/mysql-5-create-table-attribute-name-can.html' title='mysql 5 create table attribute name can not be &apos;group&apos; ?'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-6365978313945513108</id><published>2008-06-16T21:28:00.001+09:00</published><updated>2008-06-16T22:04:28.781+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='persistent'/><category scheme='http://www.blogger.com/atom/ns#' term='javassist'/><title type='text'>maybe javassist will help the activerecord java implementation</title><content type='html'>The last course project in adb was a simple jdbc task. I wanna try something new. The first thing, i did was to read the JDBC 4.0 related new features. However, quite disappointed about that. The whole EoD (ease of development) chapter in JSR 221 was deleted at the final stage when it published the final version.&lt;br /&gt;&lt;blockquote style="color: rgb(153, 153, 153);"&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;Removed the EoD chapter, targeting for JDBC.next removing the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;remove the methods: Connection.createQueryObject, DataSource.createQueryObject, DatabaseMetaData.providesQueryObjectGenerator, CommonDatasource.getQueryObject Generator&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;remove the interfaces, enums and annotations: DataSet, BaseQuery, DataSetResolver, QueryObjectGenerator, ConflictingRow, DataSetSyncStatus, GeneratedKeys, AutogeneratedKeys,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;ResultColumn, Select, Update, SQLDataSetSyncException, SQLRuntimeException, QueryObjectFactory&lt;/span&gt;&lt;/blockquote&gt;This is really ironic, the JSR 221 objective is&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;This specification seeks to improve Java application access to SQL data stores by the provision of ease-of-development focused features and improvements at both the utility and API level.&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;I still don't understand why it happens. The original specification allowed us doing something like this. There's a student table in the db, the bean class is Student, the Controller class is StudentController which implements the BaseQuery interface. By provide the sql, without writing detailed JDBC code, we can have its implementation on the fly. Pretty cool, actually.&lt;br /&gt;&lt;table style="width: 438px; height: 426px; color: rgb(255, 255, 255);" bg="" border="0" cellpadding="3" cellspacing="0"&gt;   &lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;&lt;!-- start source code --&gt;&lt;br /&gt;&lt;td align="left" nowrap="nowrap" valign="top"&gt;&lt;code&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;class &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Student &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;int &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;id;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(100, 100, 100);"&gt;@ResultColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(42, 0, 255);"&gt;"last_name"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;String lastName;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(100, 100, 100);"&gt;@ResultColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(42, 0, 255);"&gt;"first_name"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;String firstName;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;interface &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;StudentController &lt;/span&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;extends &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;BaseQuery &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(100, 100, 100);"&gt;@Select&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(42, 0, 255);"&gt;"select * from student where id = ?1"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;DataSet&amp;lt;Student&amp;gt; getStudentById&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;int &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(100, 100, 100);"&gt;@Update&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(42, 0, 255);"&gt;"delete from student"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;boolean &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;deleteAllStudents&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;()&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;StudentController studentController = con.createQueryObject&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;StudentController.&lt;/span&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;DataSet students = studentController.getStudentById&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;b&gt;for &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Student student : students&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(63, 127, 95);"&gt;//operate student&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;/code&gt;   &lt;/td&gt;&lt;br /&gt;&lt;!-- end source code --&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;So, if this does not work, what about making it work ? I did it last week. The effort was to implement an active record design pattern in java. The current work has not support relations between entities yet. Maybe if there's some time, I'll try to refine this work. The objective to write this post was to say maybe javassit will help the implementation. By using it, the framework can add method to the object on the fly. The dynamic behavior will let the framework more ease of use.&lt;br /&gt;&lt;br /&gt;nod. The last thing is &lt;a href="http://www.csg.is.titech.ac.jp/projects/gluonj/"&gt;GluonJ &lt;/a&gt;seems an interesting aop framework released from the same lab who invented the javassit. Try to look at that if possible.&lt;br /&gt;&lt;h1&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-6365978313945513108?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/6365978313945513108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=6365978313945513108' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6365978313945513108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/6365978313945513108'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/maybe-javassist-will-help-activerecord.html' title='maybe javassist will help the activerecord java implementation'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4859738021814147401.post-4541676262584226557</id><published>2008-06-16T21:07:00.000+09:00</published><updated>2008-06-16T21:21:07.519+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='cluster'/><category scheme='http://www.blogger.com/atom/ns#' term='opensource'/><category scheme='http://www.blogger.com/atom/ns#' term='chart'/><title type='text'>Something about charts</title><content type='html'>After finishing implementing bide, i wanna draw some charts to present the log data. At first, try to use excel 03. However, the line chart drawn by that is hard to configure. I failed to let the x and y axes drawn dots according to their values. So, turn to some chart apis, which I planned to get familiar with at least two years ago. = =&lt;br /&gt;&lt;br /&gt;The first thing I dig into was &lt;a href="http://code.google.com/apis/chart/"&gt;Google Chart API&lt;/a&gt;. However too many http parameters to me. After half an hour, I decided to get something else. The next thing google search engine told me was &lt;a href="http://code.google.com/p/gchartrb/"&gt;gchartrb&lt;/a&gt;, which was a wrapper api of google chart written in ruby. Sounds good. The &lt;a href="http://gchartrb.googlecode.com/svn/trunk/lib/test.rb"&gt;example &lt;/a&gt;is worth reading.&lt;br /&gt;&lt;br /&gt;I also try to get to know &lt;a href="http://www.jfree.org/index.html"&gt;JFreeChart&lt;/a&gt;, which was another popular choice for java developers. There's one thing I wanna mention was this vector diagram. Maybe I will used it someday, since&lt;br /&gt;this seems a good data presentation style for some clustering algorithm. log it here.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_jtlrRChyG5U/SFZZxAqeEsI/AAAAAAAAAFY/r_Ocy-wffvc/s1600-h/vector_chart.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 351px; height: 236px;" src="http://bp2.blogger.com/_jtlrRChyG5U/SFZZxAqeEsI/AAAAAAAAAFY/r_Ocy-wffvc/s320/vector_chart.JPG" alt="" id="BLOGGER_PHOTO_ID_5212452317254521538" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4859738021814147401-4541676262584226557?l=swimminginbits.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://swimminginbits.blogspot.com/feeds/4541676262584226557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4859738021814147401&amp;postID=4541676262584226557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4541676262584226557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4859738021814147401/posts/default/4541676262584226557'/><link rel='alternate' type='text/html' href='http://swimminginbits.blogspot.com/2008/06/something-about-charts.html' title='Something about charts'/><author><name>imoldcat</name><uri>http://www.blogger.com/profile/01007573997438480107</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_jtlrRChyG5U/R-06JnkOKNI/AAAAAAAAAEY/kjgX3273lL8/S220/logo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_jtlrRChyG5U/SFZZxAqeEsI/AAAAAAAAAFY/r_Ocy-wffvc/s72-c/vector_chart.JPG' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
