<?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:blogger='http://schemas.google.com/blogger/2008' 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-6752719756197775967</id><updated>2025-12-01T03:47:32.572+00:00</updated><category term="howto"/><category term="linux"/><category term="life"/><category term="Blogged"/><category term="python"/><category term="java"/><category term="JavaScript"/><category term="bug"/><category term="Windows"/><category term="php"/><category term="software"/><category term="C/C++"/><category term="symbol"/><category term="unbelievable"/><category term="mac"/><category term="joomla"/><category term="gadget"/><category term="latex"/><category term="matlab"/><category term="server"/><category term="google"/><category term="mysql"/><category term="vmware"/><category term="css"/><category term="update"/><category term="zemax"/><category term="fedora"/><category term="xml"/><category term="tip"/><category term="hardware"/><category term="iphone"/><category term="my"/><category term="photography"/><category term="ukpodcast"/><category term="cook"/><category term="cooking"/><category term="drupal"/><category term="english"/><category term="excel"/><category term="generate"/><category term="php javascript"/><category term="ubuntu"/><title type='text'>Cross Logbook</title><subtitle type='html'>Supporting MAC is my way to support Linux</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>516</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-7178018247147000096</id><published>2010-03-19T04:57:00.001+00:00</published><updated>2012-09-19T11:46:18.094+01:00</updated><title type='text'>my Poisson simulation</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;note-header&quot; style=&quot;background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 19px; margin: 0px; padding: 0px;&quot;&gt;
&lt;h1 style=&quot;color: #006600; font-size: 14px; font-weight: normal; line-height: 21px; margin: 0px; padding: 0px; word-wrap: break-word;&quot;&gt;
my Poisson simulation&lt;/h1&gt;
&lt;div style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;span class=&quot;pl&quot; style=&quot;color: #666666; line-height: 18px;&quot;&gt;2010-03-19 12:21:02&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;clear&quot; style=&quot;background-color: white; clear: both; color: #111111; font-family: Arial, Helvetica, sans-serif; font-size: 0px; line-height: 0; margin: 0px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div id=&quot;note_64178266_full&quot; style=&quot;background-color: white; color: #111111; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 19px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div class=&quot;note&quot; id=&quot;link-report&quot; style=&quot;font-size: 13px; line-height: 1.62; margin: 10px 0px 0px; overflow: hidden; padding: 0px; white-space: pre-wrap; width: 590px; word-wrap: break-word;&quot;&gt;
# -*- coding:utf-8 -*-&lt;br /&gt;&quot;&quot;&quot;&lt;br /&gt;Created on 2010-3-18&lt;br /&gt;&lt;br /&gt;@author: Cross&lt;br /&gt;&quot;&quot;&quot;&lt;br /&gt;from scipy.stats import poisson&lt;br /&gt;&lt;br /&gt;p1 = poisson(1.725)&lt;br /&gt;p2 = poisson(0.935)&lt;br /&gt;margin_HAD = 1.12&lt;br /&gt;margin_HILO = 1.08&lt;br /&gt;&lt;br /&gt;psize = 100000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a1 = p1.rvs(psize)&lt;br /&gt;a2 = p2.rvs(psize)&lt;br /&gt;&lt;br /&gt;h=0&lt;br /&gt;d=0&lt;br /&gt;a=0&lt;br /&gt;HI = 0&lt;br /&gt;LO = 0&lt;br /&gt;&lt;br /&gt;for i in range(psize):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if a1[i]&amp;gt;a2[i]:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h = h + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif a1[i]&lt;a2 br=&quot;br&quot; i=&quot;i&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a = a + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d = d + 1&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if a1[i] + a2[i]&lt;2 .5:=&quot;.5:&quot; br=&quot;br&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LO = LO + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HI = HI + 1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;print &quot;=======================&quot;&lt;br /&gt;print &quot;HDA&quot;&lt;br /&gt;print 1/margin_HAD/(h/float(psize))&lt;br /&gt;print 1/margin_HAD/(d/float(psize))&lt;br /&gt;print 1/margin_HAD/(a/float(psize))&lt;br /&gt;print &quot;=======================&quot;&lt;br /&gt;print &quot;HILO 2.5&quot;&lt;br /&gt;print 1/margin_HILO/(LO/float(psize))&lt;br /&gt;print 1/margin_HILO/(HI/float(psize))&lt;/2&gt;&lt;/a2&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/7178018247147000096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/7178018247147000096' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7178018247147000096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7178018247147000096'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2010/03/my-poisson-simulation.html' title='my Poisson simulation'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-5992958555439561598</id><published>2010-03-08T17:58:00.001+00:00</published><updated>2010-03-08T17:58:55.505+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="generate"/><title type='text'>possion function example (from scipy)</title><content type='html'>&gt;&gt;&gt; from scipy.stats import poisson, lognorm &gt;&gt;&gt; myShape = 5;myMu=10 &gt;&gt;&gt; ln = lognorm(myShape) &gt;&gt;&gt; p = poisson(myMu) &gt;&gt;&gt; ln.rvs((10,)) generate 10 RVs from ln array([  2.09164812e+00,   3.29062874e-01,   1.22453941e-03,          3.80101527e+02,   7.67464...... &lt;a href=&#39;http://bit.ly/9MkbZC&#39;&gt;http://bit.ly/9MkbZC&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/5992958555439561598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/5992958555439561598' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/5992958555439561598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/5992958555439561598'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2010/03/possion-function-example-from-scipy.html' title='possion function example (from scipy)'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-8247820828982841255</id><published>2010-02-26T04:57:00.001+00:00</published><updated>2010-02-26T04:57:32.958+00:00</updated><title type='text'>导出 豆瓣 日记 到其他Blog和twitter</title><content type='html'>导出 日记 到其他blog：  豆瓣日记 -&amp;gt; twitterfeed -&amp;gt; ping.fm -&amp;gt; blogger/wordpress   导出 广播 到twitter：  豆瓣广播 -&amp;gt; feedburner -&amp;gt; twitter (-&amp;gt;facebook)   豆瓣广播 到 新浪微博：  豆瓣广播 -&amp;gt; google reader (add star) stared -&amp;gt; 新浪微博（关联博客） &lt;a href=&#39;http://bit.ly/dpOErL&#39;&gt;http://bit.ly/dpOErL&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/8247820828982841255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/8247820828982841255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8247820828982841255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8247820828982841255'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2010/02/blogtwitter.html' title='导出 豆瓣 日记 到其他Blog和twitter'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-81343173479893328</id><published>2010-01-11T01:12:00.001+00:00</published><updated>2010-01-11T01:12:51.419+00:00</updated><title type='text'>[Blog post] python reads excel</title><content type='html'>&lt;div class=&quot;post&quot; style=&quot;border: 1px solid #ccc; background-color: #f5f5f5; margin: 1.5em 2em 0.5em 2em; padding: 1em; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; min-width: 500px; max-width: 1024px; direction:ltr;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;&lt;a href=&quot;http://crossz.wordpress.com/author/crossz/&quot;&gt;&lt;img style=&quot;border: 1px solid #ddd; padding: 2px; background-color: white; margin-right: 0.5em; margin-bottom: 0.5em&quot; alt=&#39;&#39; src=&#39;http://1.gravatar.com/avatar/5d4aed1705748e663d151499264b72cd?s=48&amp;amp;d=wavatar&amp;amp;r=G&#39; class=&#39;avatar avatar-48&#39; height=&#39;48&#39; width=&#39;48&#39; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;h2 style=&quot;margin: 0 0 5px 0; font-size: 1.8em&quot;&gt;&lt;a href=&quot;http://crossz.wordpress.com/2010/01/11/python-reads-excel/&quot;&gt;python reads excel&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;meta&quot; style=&quot;color: #999; font-size: 0.9em&quot;&gt;&lt;strong&gt;&lt;a href=&quot;http://crossz.wordpress.com/author/crossz/&quot;&gt;crossz&lt;/a&gt;&lt;/strong&gt; | January 11, 2010 at 1:12 am | Tags: &lt;a href=&quot;http://crossz.wordpress.com/tag/python-tutorial-howto/&quot;&gt;python tutorial howto&lt;/a&gt;  | Categories: &lt;a href=&quot;http://crossz.wordpress.com/category/life/&quot;&gt;life&lt;/a&gt;  | URL: http://wp.me/pthU9-hH&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p style=&quot;line-height: 1.6&quot;&gt;Use the excellent &lt;a href=&quot;http://www.lexicon.net/sjmachin/xlrd.htm&quot;&gt;xlrd&lt;/a&gt; package, which works on any platform.  That means you can read Excel files from Python in Linux!  Example usage:&lt;/p&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;Open the workbook&lt;/p&gt; &lt;pre&gt;import xlrd wb = xlrd.open_workbook(&#39;myworkbook.xls&#39;)&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;Check the sheet names&lt;/p&gt; &lt;pre&gt;wb.sheet_names()&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;Get the first sheet either by index or by name&lt;/p&gt; &lt;pre&gt;sh = wb.sheet_by_index(0) sh = wb.sheet_by_name(u&#39;Sheet1&#39;)&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;Iterate through rows, returning each as a list that you can index:&lt;/p&gt; &lt;pre&gt;for rownum in range(sh.nrows):     print sh.row_values(rownum)&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;If you just want the first column:&lt;/p&gt; &lt;pre&gt;first_column = sh.col_values(0)&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;Index individual cells:&lt;/p&gt; &lt;pre&gt;cell_A1 = sh.cell(0,0).value cell_C4 = sh.cell(rowx=3,colx=2).value&lt;/pre&gt; &lt;p style=&quot;line-height: 1.6&quot;&gt;(Note Python indices start at zero but Excel starts at one)&lt;/p&gt; &lt;div style=&quot;clear: both&quot;&gt;&lt;/div&gt;&lt;p style=&quot;margin-bottom: 0.4em&quot;&gt;&lt;a href=&quot;http://crossz.wordpress.com/2010/01/11/python-reads-excel/#respond&quot;&gt;Add a comment to this post&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=crossz.wordpress.com&amp;blog=6980341&amp;post=1097&amp;subd=crossz&amp;ref=&amp;feed=1&quot; /&gt;&lt;div style=&quot;text-align: right; padding: 0 1em; max-width: 1024px;&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/crossz.wordpress.com/1097/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/crossz.wordpress.com/1097/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/crossz.wordpress.com/1097/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/crossz.wordpress.com/1097/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/crossz.wordpress.com/1097/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/crossz.wordpress.com/1097/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/crossz.wordpress.com/1097/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/crossz.wordpress.com/1097/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/crossz.wordpress.com/1097/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/crossz.wordpress.com/1097/&quot; /&gt;&lt;/a&gt; &lt;/div&gt;&lt;p style=&quot;display: none&quot;&gt;-- &lt;/p&gt;&lt;br/&gt;&lt;table&gt;&lt;tr&gt;&lt;td width=&quot;80&quot;&gt;&lt;img src=&quot;http://s.wordpress.org/about/images/logo-grey/grey-m.png&quot; alt=&quot;WordPress&quot; width=&quot;64&quot; height=&quot;64&quot; /&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;WordPress.com | Thanks for flying with WordPress!&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://subscribe.wordpress.com?key=445310e3a1d553499f95c99fd87612c4&amp;email=ukcross.publish%40blogger.com&quot;&gt;Manage your subscriptions&lt;/a&gt; | Publish text, photos, music, and videos by email using our &lt;a href=&quot;http://support.wordpress.com/post-by-email/&quot;&gt;Post by Email&lt;/a&gt; feature. | &lt;a href=&quot;http://wordpress.com/signup/?ref=email&quot;&gt;Signup with WordPress.com&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/81343173479893328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/81343173479893328' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/81343173479893328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/81343173479893328'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2010/01/blog-post-python-reads-excel.html' title='[Blog post] python reads excel'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-1159937050468913031</id><published>2009-12-05T08:12:00.002+00:00</published><updated>2009-12-05T08:26:29.701+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="drupal"/><category scheme="http://www.blogger.com/atom/ns#" term="mysql"/><title type='text'>HOWTO: backup / resotre mysql database for drupal</title><content type='html'>To Backup:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;select the database need backup in phpMyAdmin&lt;/li&gt;&lt;li&gt;select the tab of Export, and save as file in a sql format.&lt;/li&gt;&lt;/ol&gt;To resotre:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;upload the drupal installation files into the proper directory.&lt;/li&gt;&lt;li&gt;copy the old director of /site/all, in which are the modules and themes to the new site directory. Otherwise some functionalities will miss.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;create the database you want in phpMyAdmin with proper database name.&lt;/li&gt;&lt;li&gt;select the new database and Import.&lt;/li&gt;&lt;li&gt;Install the new drupal site.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/1159937050468913031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/1159937050468913031' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1159937050468913031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1159937050468913031'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/12/howto-backup-resotre-mysql-database-for.html' title='HOWTO: backup / resotre mysql database for drupal'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-676391682964960531</id><published>2009-10-14T20:52:00.002+01:00</published><updated>2009-10-14T20:57:11.997+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>HOWTO install egg file for python</title><content type='html'>Using easy_install, which is installed by setuptools (http://pypi.python.org/pypi/setuptools).&lt;br /&gt;&lt;br /&gt;~$ easy_install XXXXX.egg&lt;br /&gt;This is for binary egg file. While script egg file should be treated as normal shell script. To install:&lt;br /&gt;~$ sh XXXXXX.egg&lt;br /&gt;&lt;br /&gt;#######################&lt;br /&gt;Another popular way to install python &#39;modules&#39;, is:&lt;br /&gt;~$ python setup.py install&lt;br /&gt;This is from python source. Normally third parties will provide such kind of source.</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/676391682964960531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/676391682964960531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/676391682964960531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/676391682964960531'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/10/howto-install-egg-file-for-python.html' title='HOWTO install egg file for python'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-5303338558369654181</id><published>2009-09-10T19:32:00.003+01:00</published><updated>2009-09-11T02:20:26.439+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>HOWTO: screencast in Ubuntu</title><content type='html'>&lt;code&gt;&lt;/code&gt;With recordmydesktop, ffmpeg, mencoder, libavcodec-unstripped-52 ( for aac audio encoder), ubuntu-restricted-extras installed. Run the following command to record and convert it to mp4 format, in order to upload to youtube.&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;recordmydesktop&lt;br /&gt;&lt;code&gt;mencoder out.ogv -oac pcm -ovc lavc &lt;/code&gt;&lt;code&gt;-lavcopts vcodec=mpeg4&lt;/code&gt;&lt;code&gt; -o out.mp4&lt;/code&gt;&lt;/blockquote&gt;&lt;code&gt;&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/5303338558369654181/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/5303338558369654181' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/5303338558369654181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/5303338558369654181'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/09/howto-screencast-in-ubuntu.html' title='HOWTO: screencast in Ubuntu'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-6106113904402763051</id><published>2009-08-20T02:13:00.003+01:00</published><updated>2009-09-05T11:09:00.128+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C/C++"/><category scheme="http://www.blogger.com/atom/ns#" term="matlab"/><title type='text'>Matlab: Mex example in C way</title><content type='html'>There is a yprime.c for mex in Matlab. Here I translate to C, in order to understand mex better.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;blockquote&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/blockquote&gt;static void yprime(&lt;br /&gt;      double*    yp,&lt;br /&gt;       double*    y&lt;br /&gt;      )&lt;br /&gt;{&lt;br /&gt;double    r1,r2;&lt;br /&gt;&lt;br /&gt;double    mu = 1/82.45;&lt;br /&gt;double    mus = 1 - 1/82.45;&lt;br /&gt;&lt;br /&gt;r1 = sqrt((y[0]+mu)*(y[0]+mu) + y[2]*y[2]);&lt;br /&gt;r2 = sqrt((y[0]-mus)*(y[0]-mus) + y[2]*y[2]);&lt;br /&gt;&lt;br /&gt;yp[0] = y[1];&lt;br /&gt;yp[1] = 2*y[3]+y[0]-mus*(y[0]+mu)/(r1*r1*r1)-mu*(y[0]-mus)/(r2*r2*r2);&lt;br /&gt;yp[2] = y[3];&lt;br /&gt;yp[3] = -2*y[1] + y[2] - mus*y[2]/(r1*r1*r1) - mu*y[2]/(r2*r2*r2);&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(){&lt;br /&gt;double yo[4];&lt;br /&gt;double yi[4] = {100, 2, 3, 4};&lt;br /&gt;&lt;br /&gt;yprime(yo, yi);&lt;br /&gt;printf(&quot;print out %f&quot;,yo[0]);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// some conversion practice&lt;br /&gt;double a = yi[0];&lt;br /&gt;char t1[7],t2[8],t3[8];&lt;br /&gt;&lt;br /&gt;*t1= (char) a;&lt;br /&gt;strcpy(t2,t1);&lt;br /&gt;&lt;br /&gt;printf(strcat(t1, t2));&lt;br /&gt;&lt;br /&gt;gcvt(a,7,t3);&lt;br /&gt;puts(t3);&lt;br /&gt;&lt;br /&gt;//    i = sprintf(str, &quot;%d&quot;, 15); //for interger to string&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/6106113904402763051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/6106113904402763051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6106113904402763051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6106113904402763051'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/08/matlab-mex-example-in-c-way.html' title='Matlab: Mex example in C way'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-1932923749020363953</id><published>2009-08-16T18:24:00.003+01:00</published><updated>2009-08-16T18:31:47.837+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C/C++"/><title type='text'>HOWTO: compile objective-c using gcc in Linux</title><content type='html'>to compile these examples of objective-c (install libobjc first) from objective-c on wikipedia.org&lt;br /&gt;&lt;br /&gt;1) traditional:&lt;br /&gt;gcc -c XX.m XXX.m -Wno-import&lt;br /&gt;gcc -o prog XX.o XXX.o -lobjc -Wno-import&lt;br /&gt;&lt;br /&gt;2) gcc *.m -lojbc -Wno-import&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;-Wno-import is because the maintainer of gcc doesn&#39;t like &#39;import&#39;;&lt;br /&gt;&lt;p&gt;-lobjc: -l(library) -L(libaray directory) -lobjc(for GNU objective-c libraray)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For those examples using GNUstep, most of the header files need to be changed from &#39; #import &lt;foundation nsobject=&quot;&quot;&gt;&#39; to &#39;#import &lt;objc h=&quot;&quot;&gt;&#39; to suit the GNU objective-c library.&lt;/objc&gt;&lt;/foundation&gt;&lt;/p&gt;&lt;p&gt;More details: http://www.cs.indiana.edu/classes/c304/oop-intro.html&lt;br /&gt;&lt;foundation nsobject=&quot;&quot;&gt;&lt;objc h=&quot;&quot;&gt;&lt;/objc&gt;&lt;/foundation&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/1932923749020363953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/1932923749020363953' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1932923749020363953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1932923749020363953'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/08/howto-compile-objective-c-using-gcc-in.html' title='HOWTO: compile objective-c using gcc in Linux'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-2583110479540256334</id><published>2009-08-03T21:25:00.007+01:00</published><updated>2009-08-04T00:24:59.840+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: Version control using BZR vs RCS</title><content type='html'>No matter programming or documents editing, BZR will work for you to provide easier and better version control.&lt;br /&gt;&lt;br /&gt;Here are some simple steps for docs processing:&lt;br /&gt;======================&lt;br /&gt;&lt;ol&gt;&lt;li&gt;bzr init&lt;br /&gt;create a folder, &#39;text&#39;, then create a file, &#39;test1.txt&#39;, in which we type in a paragraph. Then &#39;bzr init&#39; to let bzr know this is the folder where bzr should monitor.&lt;/li&gt;&lt;li&gt;bzr add&lt;br /&gt;&#39;bzr add test1.txt&#39;. Now bzr knows where and what to monitor.&lt;/li&gt;&lt;li&gt;bzr diff&lt;br /&gt;add more text into the test1.txt, then run &#39;bzr diff&#39; to test whether there is any changes.&lt;/li&gt;&lt;li&gt;bzr commit -m &#39;description&#39;&lt;br /&gt;if there are some changes, and you want to create another version for that for the current version backup. run &#39;bzr commint -m &quot;some description&quot;&#39;.&lt;/li&gt;&lt;li&gt;bzr log&lt;br /&gt;to check verisons.&lt;br /&gt;...&lt;br /&gt;more changes and more commits here.&lt;br /&gt;...&lt;br /&gt;&lt;/li&gt;&lt;li&gt;bzr branch &lt;path&gt; -r &lt;version&gt;&lt;br /&gt;For example we just want to retrive the first version, run &#39;bzr branch `pwd` -r 1&#39;. A new folder with the name of current folder &#39;text&#39; will be created, in which our text1.txt 1st version is there.&lt;/version&gt;&lt;/path&gt;&lt;/li&gt;&lt;/ol&gt;RCS: (same procedure)&lt;br /&gt;===================&lt;br /&gt;&lt;ol&gt;&lt;li&gt;   create folder RCS&lt;br /&gt;this step can be ignored, the rcs information will be saved in the same folder with the file you are editing. Otherwise, the file info file will be saved in the RCS folder.&lt;/li&gt;&lt;li&gt;   ci -u test1.txt&lt;br /&gt;ver 1.1 is created. RCS uses the concept of &#39;lock&#39;. -l -r -u are similar, to keep the text file locked when new version is registered.&lt;/li&gt;&lt;li&gt;   co -l test1.txt&lt;br /&gt;(if without this step, new version can not be registered. because &#39;no lock&#39;, prompted by &#39;ci&#39;, is this for synchronization?) So to lock the text file to make it writable (very weird concept, locked == writable???). Then add more text in it.&lt;/li&gt;&lt;li&gt;   rcsdiff test1.txt&lt;br /&gt;To check what&#39;s different from the registered version.&lt;/li&gt;&lt;li&gt;ci -u test1.txt (same with step2)&lt;br /&gt;The version number increment with 0.1.&#39;ci -r2 -u test1.txt&#39; to make the version increment by 1.0.&lt;br /&gt;...&lt;br /&gt;more changes and more commits here.&lt;br /&gt;...&lt;/li&gt;&lt;li&gt;   co -l1.1 test1.txt&lt;br /&gt;Retrive version 1.1 to replace the current editing file. -l -r -u are similar, just -u makes the file non-writeable, while -l make the file writeable. Good practice is &#39;ci -u&#39; and &#39;co -l&#39;, so that when the new version is registered by ci, the file will become &#39;non-writable&#39;=&#39;can not modify&#39;=&#39;No lock&#39;. (weired)&lt;/li&gt;&lt;/ol&gt;Note: no space between &#39;-r2&#39; and &#39;-u1.1&#39;.&lt;br /&gt;&lt;br /&gt;Conclusion:&lt;br /&gt;==================&lt;br /&gt;BZR is more user friendly, and Ubuntu uses it on launchpad.net.&lt;br /&gt;RCS is quite mature (old), LYX uses it as version control. So even I don&#39;t like it, but I have to still use it, because I love Lyx.</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/2583110479540256334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/2583110479540256334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2583110479540256334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2583110479540256334'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/08/howto-version-control-using-bzr.html' title='HOWTO: Version control using BZR vs RCS'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-1203023710132759193</id><published>2009-08-02T20:43:00.006+01:00</published><updated>2009-08-02T22:32:06.024+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: autoconf &amp; automake HELLO WORLD</title><content type='html'>1) Create sources, “Makefile.am”&lt;br /&gt;2) `autoscan`：create configure.scan&lt;br /&gt;3) Rename “configure.scan” to “configure.ac”&lt;br /&gt;4) `autoheader`:create config.h.in for automake&lt;br /&gt;5) Add AM_INIT_AUTOMAKE to “configure.ac”, just after AC_INIT()&lt;br /&gt;6) `aclocal`:create necessary macros in aclocal.m4 for automake.&lt;br /&gt;7) `automake ­­--add-­missing --­­copy`: create Makefile.in from Makefile.am&lt;br /&gt;8) `autoconf`:create configure&lt;br /&gt;9) `./configure`:check and create Makefile&lt;br /&gt;10) `make`&lt;br /&gt;11) `make install`&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if you modify your source...&lt;br /&gt;1) Run `autoscan` again&lt;br /&gt;2) Compare configure.scan with configure.ac&lt;br /&gt;* Update configure.ac&lt;br /&gt;3) Run `autoreconf`&lt;br /&gt;&lt;br /&gt;***********************&lt;br /&gt;# Makefile.am for hello.c&lt;br /&gt;bin_PROGRAMS=hello&lt;br /&gt;hello_SOURCES=hello.c&lt;br /&gt;***********************&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To simplify it:&lt;br /&gt;===============&lt;br /&gt;1) c/cc files, Makefile.am&lt;br /&gt;2) autoscan =&gt; mv configure.scan configure.ac =&gt; add Add AM_INIT_AUTOMAKE after AC_INIT&lt;br /&gt;&lt;br /&gt;3) autoheader&lt;br /&gt;4) aclocal&lt;br /&gt;5) automake&lt;br /&gt;&lt;br /&gt;6) autoconf &lt;=&gt; autoscan,(compare configure.ac),autoreconf&lt;br /&gt;&lt;p&gt;7) ./configure &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;Simplest &#39;make&#39;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;=====================&lt;br /&gt;Hello.c:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;blockquote&gt;#include &lt;stdio.h&gt;&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;printf(&quot;Hello, world!\n&quot;);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/stdio.h&gt;&lt;/blockquote&gt;Makefile:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;blockquote&gt;# Makefile: A standard Makefile for hello.c&lt;br /&gt;all: hello&lt;br /&gt;clean:   rm -f hello&lt;/blockquote&gt;Run: make, to create executable bin file.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/1203023710132759193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/1203023710132759193' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1203023710132759193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1203023710132759193'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/08/howto-autoconf-automake-hello-world.html' title='HOWTO: autoconf &amp; automake HELLO WORLD'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-3787383871354907885</id><published>2009-08-02T16:21:00.002+01:00</published><updated>2009-08-02T17:27:35.024+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: autoconf &amp; automake</title><content type='html'>&lt;ol&gt;&lt;li&gt;Write makefile.am templates.&lt;/li&gt;&lt;li&gt;Write configure.in.&lt;br /&gt;2.1 Use autoscan to generate a template.&lt;br /&gt;2.2 Specialize the generated configure.scan to suit your project.&lt;br /&gt;2.3 Rename configure.scan to configure.in.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Run automake to generate Makefile.in from Makefile.am (automake scans configure.in to find out more about the project).&lt;/li&gt;&lt;li&gt;Run aclocal to make local copies of all autoconf macros. These macros are then included in the project.&lt;/li&gt;&lt;li&gt;Run autoconf to generate configure.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;=========================&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;automake&lt;/span&gt;&lt;br /&gt;automake, when used in conjunction with autoconf, makes creating Makefiles easy. automake operates on a Makefile.am to generate Makefile.in . Makefile.in is then processed by the configure script to generate Makefile. Makefile.am has macros that are processed by automake. A sample Makefile.am is shown below. Variables surrounded by @&#39;s are automatically propagated without change to Makefile.in. The configure script, when parsing Makefile.in into Makefile, makes the necessary substitutions (for example, @LDFLAGS@ may get expanded to &quot;-lm -lthread).&lt;br /&gt;        &lt;br /&gt;        bin_PROGRAMS = gpstat&lt;br /&gt;        gpstat_SOURCES = about.c interface.c multi-plot.c attach_process.c&lt;br /&gt;        gpstat_LDFLAGS = @LDFLAGS@ @GTK_LIBS@ -lgthread&lt;br /&gt;        INCLUDES = @GTK_CFLAGS@&lt;br /&gt;&lt;br /&gt;automake knows the rules to create object files and executables for the platform it is running on. The above sets of macros tell automake that:&lt;br /&gt;1. The final executable is to be named gpstat. &lt;br /&gt;2. The sources for gpstat are the value of gpstat_SOURCES. &lt;br /&gt;3. Add @LDFLAGS@, @GTK_LIBS@, and -lgthread to the link line. (The  configure script will replace LD_FLAGS and GTK_LIBS with their proper values.) &lt;br /&gt;4. Include the variable $INCLUDES in the compilation line.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;=========================&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;autoconf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The configure script is generated from configure.in using autoconf. configure.in is a normal text file that contains several autoconf macros. These macros specify what tests to carry out.  General uses of the configure script include:&lt;br /&gt;1. Find machine information (Hostname, version...). &lt;br /&gt;2. Find the path to a particular program (bison, lex, ...). &lt;br /&gt;3. Find out if a tool supports a feature (for example, if the compiler supports bool). &lt;br /&gt;4. Check if the required libraries are available on your system. &lt;br /&gt;5. Process Makefile.in to generate Makefile.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;=========================================&lt;/p&gt;&lt;p&gt;automake also provides autoscan, a utility script that will help you create a template configure.in. autoscan scans the program sources and adds suitable macros to configure.in. It creates configure.scan, which then should be renamed configure.in, after making suitable modifications.&lt;br /&gt;automake also provides a program called aclocal. aclocal makes local copies of all autoconf macros, so that other developers can modify the configure.in file.&lt;br /&gt;&lt;br /&gt;You can combine the invocation of automake, aclocal, and autoconf as follows:&lt;br /&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;foo@pastwatch$ aclocal&amp;amp;&amp;amp; automake &amp;amp;&amp;amp; autoconf&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;Sample:&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;Comments can either begin with dnl or a #. The following is a small, well-documented, self-explanatory configure.in file.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:78%;&quot;&gt;#============================start configure.in============================&lt;br /&gt;dnl Process this file with autoconf to produce a configure script.&lt;br /&gt;dnl notice how comments are preceded by &quot;dnl&quot;&lt;br /&gt;# comments can also begin with a #&lt;br /&gt;dnl This macro is a must, and this tests if the configure&lt;br /&gt;dnl script is running in the correct directory&lt;br /&gt;AC_INIT(src/about.c)&lt;br /&gt;dnl This macro tells the configure script to put&lt;br /&gt;dnl &quot;defines&quot; in a file rather than the command line.&lt;br /&gt;AM_CONFIG_HEADER(config.h)&lt;br /&gt;dnl get the flags&lt;br /&gt;CFLAGS=&quot;${CFLAGS=}&quot;&lt;br /&gt;dnl this macro is used to get the arguments supplied&lt;br /&gt;dnl to the configure script (./configure --enable-debug)&lt;br /&gt;dnl Check if we have enable debug support.&lt;br /&gt;AC_MSG_CHECKING(whether to enable debugging)&lt;br /&gt;debug_default=&quot;yes&quot;&lt;br /&gt;AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging&lt;br /&gt;                     [default=$debug_default]],, enable_debug=$debug_default)&lt;br /&gt;dnl Yes, shell scripts can be used&lt;br /&gt;if test &quot;x$enable_debug&quot; = &quot;xyes&quot;; then&lt;br /&gt;       CFLAGS=&quot;$CFLAGS -g -DDEBUG&quot;&lt;br /&gt;AC_MSG_RESULT(yes)&lt;br /&gt;else&lt;br /&gt;CFLAGS=&quot;$CFLAGS -O3 -ffast-math -mcpu=v8 -mtune=ultrasparc&quot;&lt;br /&gt;AC_MSG_RESULT(no)&lt;br /&gt;fi&lt;br /&gt;dnl tells us that we require autoconf with version greater than&lt;br /&gt;dnl 2.12 to generate configure&lt;br /&gt;AC_PREREQ(2.12)&lt;br /&gt;dnl get system information&lt;br /&gt;AC_CANONICAL_SYSTEM&lt;br /&gt;dnl Since foo is currently untested on any os other&lt;br /&gt;dnl than solaris, so check the os and quit if not solaris.&lt;br /&gt;UNSUPPORTED_OS=&quot;FOO is currently unsupported on your platform.&lt;br /&gt;If you are interested in making it work on your platform, you are&lt;br /&gt;more than *welcome*. Contact foo@bar.sun.com for details.&quot;&lt;br /&gt;case &quot;${target_os}&quot; in&lt;br /&gt;solaris*)&lt;br /&gt;  echo ===========================================================&lt;br /&gt;  echo Setting up build environment for ${target_cpu}${target_os}&lt;br /&gt;  echo ===========================================================&lt;br /&gt;  ;;&lt;br /&gt;*)&lt;br /&gt;  AC_MSG_ERROR($UNSUPPORTED_OS)&lt;br /&gt;esac&lt;br /&gt;&lt;br /&gt;# Build time sanity check...&lt;br /&gt;AM_SANITY_CHECK&lt;br /&gt;dnl get path to install program&lt;br /&gt;AC_PROG_INSTALL&lt;br /&gt;AC_ARG_PROGRAM&lt;br /&gt;VERSION=0.1&lt;br /&gt;PACKAGE=foo&lt;br /&gt;dnl initialize automake&lt;br /&gt;AM_INIT_AUTOMAKE($PACKAGE, $VERSION)&lt;br /&gt;dnl Checks for c compiler.&lt;br /&gt;AC_PROG_CC&lt;br /&gt;dnl check for standard c headers&lt;br /&gt;AC_HEADER_STDC&lt;br /&gt;dnl export these variable (so Makefile substitutions&lt;br /&gt;dnl can be made.&lt;br /&gt;AC_SUBST(CFLAGS)&lt;br /&gt;AC_SUBST(LDFLAGS)&lt;br /&gt;dnl Checks for libraries.&lt;br /&gt;dnl AC_CHECK_LIB(gthread, g_thread_init)&lt;br /&gt;dnl AC_CHECK_LIB(pthread, pthread_create)&lt;br /&gt;dnl Check for /proc&lt;br /&gt;   AC_CHECK_FILE(/proc,,AC_MSG_ERROR(Cannot&lt;br /&gt;     find /proc. See the file &#39;README&#39; for help.))&lt;br /&gt;dnl check for procfs.h&lt;br /&gt;AC_CHECK_HEADER(procfs.h,,&lt;br /&gt;              AC_MSG_ERROR(Cannot&lt;br /&gt;                find procfs.h. See the file &#39;README&#39; for help.))&lt;br /&gt;dnl Checks for header files.&lt;br /&gt;AC_CHECK_HEADERS(fcntl.h)&lt;br /&gt;AC_CHECK_HEADERS(time.h)&lt;br /&gt;dnl Checks for typedefs, structures, and compiler characteristics.&lt;br /&gt;AC_C_CONST&lt;br /&gt;AC_TYPE_PID_T&lt;br /&gt;dnl Create these files, making substitutions if necessary&lt;br /&gt;AC_OUTPUT([&lt;br /&gt;src/Makefile&lt;br /&gt;Makefile&lt;br /&gt;]&lt;br /&gt;)&lt;br /&gt;#============================end configure.in============================&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/3787383871354907885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/3787383871354907885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/3787383871354907885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/3787383871354907885'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/08/howto-autoconf-automake.html' title='HOWTO: autoconf &amp; automake'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-2259222225431068318</id><published>2009-07-28T00:56:00.005+01:00</published><updated>2009-07-28T23:26:06.688+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: get stdin from shell in Gedit External Tool</title><content type='html'>The following code can get the input from Gedit External Tool as you assigned for &#39;input&#39;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;#!/bin/bash&lt;br /&gt;search=`xargs`&lt;br /&gt;echo $search&lt;/blockquote&gt;The trick is the command of &lt;span style=&quot;font-size:180%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;xargs&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Also available Environment Variables in Gedit External Tool are:&lt;br /&gt;=====================&lt;br /&gt;GEDIT_CURRENT_DOCUMENT_URI&lt;br /&gt;GEDIT_CURRENT_DOCUMENT_NAME&lt;br /&gt;GEDIT_CURRENT_DOCUMENT_SCHEME&lt;br /&gt;GEDIT_CURRENT_DOCUMENT_PATH&lt;br /&gt;GEDIT_CURRENT_DOCUMENT_DIR&lt;br /&gt;GEDIT_DOCUMENTS_URI&lt;br /&gt;GEDIT_DOCUMENTS_PATH&lt;br /&gt;&lt;br /&gt;An example: compile java file and run it&lt;br /&gt;=========================&lt;br /&gt;javac $GEDIT_CURRENT_DOCUMENT_NAME &amp;amp;&amp;amp; java -cp . `echo $GEDIT_CURRENT_DOCUMENT_NAME | sed s/.java//`</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/2259222225431068318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/2259222225431068318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2259222225431068318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2259222225431068318'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/howto-get-stdin-from-shell-in-gedit.html' title='HOWTO: get stdin from shell in Gedit External Tool'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-8976983974784312034</id><published>2009-07-22T12:13:00.003+01:00</published><updated>2009-08-23T21:16:13.984+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="matlab"/><title type='text'>16-bit binary data interpreting difference between Java and Matlab</title><content type='html'>&lt;p&gt;The 16-bit data will be interpreted as different values in Java and Matlab. WHY??&lt;/p&gt;&lt;p&gt;Here are some experiments: save number 15 to 8-bit and 16-bit binary files, and another 259 in 16-bit binary files (refer to : &lt;a href=&quot;http://crossonline.blogspot.com/2009/07/java-read-and-write-16-bit-data-file.html&quot;&gt;this post&lt;/a&gt;).&lt;br /&gt;======================&lt;br /&gt;&lt;br /&gt;In Matlab (fread(fid1, &#39;uint8&#39;);): 15&lt;br /&gt;&lt;br /&gt;16 bit bin file containing 15:&lt;br /&gt;In WinHex: 0F 00&lt;br /&gt;In java (DataInputStream.readShort();): [3840, 0]&lt;br /&gt;=&gt; 3840/256=15;&lt;br /&gt;=&gt; so, it&#39;s a kind of [15 00]&lt;br /&gt;In Matlab (fread(fid1, &#39;uint16&#39;);): 15&lt;br /&gt;&lt;br /&gt;16 bit bin file containing 259:&lt;br /&gt;In WinHex: 03 01&lt;br /&gt;In java (DataInputStream.readShort();): [769, 0] //Note, for every byte, java can&lt;br /&gt;&lt;br /&gt;contain a value larger than 256, while other programming language will increment.&lt;br /&gt;=&gt; 769%256 = 1; 769/256=3.0039;&lt;br /&gt;=&gt; so, it&#39;s a kind of [03 01]&lt;br /&gt;In Matlab (fread(fid1, &#39;uint16&#39;);): 259&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Therefore:&lt;br /&gt;========================&lt;br /&gt;Therefore, a integer value in the range of 16-bit, for example 41837. In Matlab,&lt;br /&gt;&lt;br /&gt;it will be intepreted as 41837, mod(41837,256)=109, 41837/256=163.4. So 41837 can&lt;br /&gt;&lt;br /&gt;be displayed as [163 109] = 163*256+109; while java intepret [163 109] as&lt;br /&gt;&lt;br /&gt;163+109*256 = 28067;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Conclusion:&lt;br /&gt;========================&lt;br /&gt;This seems wrong inside Java, but Java know how to process such value and export&lt;br /&gt;&lt;br /&gt;it correctly to another bin file, which one can be understood by Matlab, WinHex or&lt;br /&gt;&lt;br /&gt;other programming languages or editor.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/8976983974784312034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/8976983974784312034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8976983974784312034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8976983974784312034'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/16-bit-binary-data-interpreting.html' title='16-bit binary data interpreting difference between Java and Matlab'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-6821454202065808807</id><published>2009-07-21T09:44:00.003+01:00</published><updated>2009-07-21T10:09:16.583+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><title type='text'>Simplest procedure to TRIPLE BOOT on Macbook</title><content type='html'>&lt;p&gt;The must:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Only ONE partition for Linux; Only ONE partition for Windows. (to satisfy Windows)&lt;/li&gt;&lt;li&gt;Windows must locates at the last partition. (to satisfy Macbook)&lt;/li&gt;&lt;li&gt;Before installing, ensure the partitions are ready and good! (Disk Utility normally can not do this, or do half of this task. Because it will create several &#39;spare spaces&#39; between each partitions made by it, these partitions always make the Windows installation fail due to more than 4 primary partitions existing. But Disk Utility can create one more partition from the original one whole partition, then split it using other ways, which includes &#39;diskutil&#39; in Mac, &#39;gparted&#39; from Linux Livecd or even the Windows installer during Windows setup). Any partitions modification will make Windows can not boot up even synced by rEfit.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;- If Windows has been installed by Boot Camp. Try to change boot.ini in my windows partition (disk util create a new partition between mac and windows and messed up my boot.ini, the partition it tried to boot (third) is now linux Hd instead of windows (become 4th. This might be your problem. It gave me BSoD right after splash screen)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So the procedure:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Partitioning (DO NOT USE BOOT CAMP ASSISTANT)&lt;/li&gt;&lt;li&gt;sync mbr/gpt using rEfit. (maybe can be ignored)&lt;/li&gt;&lt;li&gt;Install Winxp on the 4th (last) partition.&lt;/li&gt;&lt;li&gt;sync mbr/gpt using rEfit.(maybe can be ignored)&lt;/li&gt;&lt;li&gt;Install Linux.&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/6821454202065808807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/6821454202065808807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6821454202065808807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6821454202065808807'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/simplest-procedure-to-triple-boot-on.html' title='Simplest procedure to TRIPLE BOOT on Macbook'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-4045757492928268893</id><published>2009-07-21T00:32:00.006+01:00</published><updated>2009-08-23T21:15:19.942+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Java/Matlab read and write 16-bit data file</title><content type='html'>&lt;ul&gt;&lt;li&gt;Read 16 bit binary file:&lt;br /&gt;    &lt;blockquote&gt;File file = new File(&quot;FILENAME.bin&quot;);&lt;br /&gt;    FileInputStream fis = new FileInputStream(file);&lt;br /&gt;    BufferedInputStream bis = new BufferedInputStream(fis);&lt;br /&gt;    DataInputStream dis = new DataInputStream( bis );&lt;br /&gt;&lt;br /&gt;    short[] myarray = new short[256000];&lt;br /&gt;    int cnt;&lt;br /&gt;for (cnt = 0; cnt &amp;lt; 256000; cnt++) {&lt;br /&gt;&lt;br /&gt;       myarray[cnt] = dis.readShort();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;fis.close();&lt;/blockquote&gt;&lt;br /&gt;Alternatively:&lt;br /&gt;&lt;blockquote&gt;RandomAccessFile dis =  new RandomAccessFile(new File(&quot;FILENAME.bin&quot;), &quot;r&quot;); &lt;/blockquote&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Note: &lt;/span&gt;&lt;br /&gt;1) bufferedInputStream can be ignored, but it will improve the performance 90% for large file operation.&lt;br /&gt;2) RandomAccessFile works like a &#39;pointer&#39;, similar to fread in Matlab, offset or skip can be assign when data retrieving while not really load all the file. This class has both read and write methods, it is a convenience class, like filereader and filewriter, while the former method is kinda low level methods.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Write 16 bit binary file:&lt;br /&gt;&lt;blockquote&gt;FileOutputStream fos = new FileOutputStream(new File(&quot;OUTPUT.bin&quot;));&lt;br /&gt;BufferedOutputStream bos = new BufferedOutputStream(fos);&lt;br /&gt;DataOutputStream dos = new DataOutputStream(bos);&lt;br /&gt;&lt;br /&gt;for (cnt = 0; cnt &amp;lt; 256000; cnt++) {&lt;br /&gt;&lt;br /&gt;       myarray[cnt] = dis.readShort();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bos.flush();&lt;br /&gt;&lt;br /&gt;fos.close();&lt;/blockquote&gt;&lt;br /&gt;Alternatively:&lt;br /&gt;&lt;blockquote&gt;RandomAccessFile dos =  new RandomAccessFile(new File(&quot;OUTPUT.bin&quot;), &quot;rw&quot;); &lt;/blockquote&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Note: &lt;/span&gt;The following step is&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt; essential&lt;/span&gt;&lt;/span&gt;!!!! Otherwise, there will be some data lost.&lt;br /&gt;&lt;blockquote&gt;bos.flush();&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Matlab:&lt;br /&gt;&lt;br /&gt;fid1 = fopen(&#39;filename.bin&#39;, &#39;r&#39;);&lt;br /&gt;  A = fread(fid1, 100, &#39;uint16=&gt;float32&#39;);&lt;br /&gt;fclose(fid1);&lt;br /&gt;&lt;br /&gt;fid2 = fopen(&#39;output.bin&#39;, &#39;w&#39;);&lt;br /&gt;  fwrite(fid2, A, &#39;uint16&#39;);&lt;br /&gt;fclose(fid2);&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/4045757492928268893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/4045757492928268893' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/4045757492928268893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/4045757492928268893'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/java-read-and-write-16-bit-data-file.html' title='Java/Matlab read and write 16-bit data file'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-2438792346539056638</id><published>2009-07-19T18:50:00.009+01:00</published><updated>2009-07-22T01:11:53.832+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>BUG, HOWTO: how java read 8-bit and 16-bit</title><content type='html'>you have to use twice as much memory, but there really is no other solution:&lt;br /&gt;=======================&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt;use a short to hold an unsigned byte, use a long to hold an unsigned int. (And use a char to hold an unsigned short.)&lt;/p&gt;&lt;p&gt;This example create a 16-bit file, which only contain a value, 15 in 16-bit (000f), This file can be viewed by Gedit. From Matlab, it can retrieve and display correctly as 15, but in Java, using DataInputStream.readShort(), it&#39;s 3840, which equals to 15*256.&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Example 1: Using Matlab to generate a 16-bit data file.&lt;br /&gt;================&lt;br /&gt;clear;clc;%% create binA=15;fid = fopen(&#39;output.bin&#39;, &#39;w&#39;);    fwrite(fid, A, &#39;uint16&#39;);fclose(fid);%% read binfid1 = fopen(&#39;output.bin&#39;, &#39;r&#39;);    B = fread(fid1, 1, &#39;uint16&#39;)fclose(fid1);&lt;br /&gt;&lt;br /&gt;Example 2: Using Java to retrive the 16-bit data from the bin file.&lt;br /&gt;===========&lt;br /&gt;import java.io.*;public class convbin { public static void main(String args[]) throws IOException {  File file = new File(&quot;onev.bin&quot;);  FileInputStream fis = new FileInputStream(file);  BufferedInputStream bis = new BufferedInputStream(fis);  DataInputStream dis = new DataInputStream( bis );//  RandomAccessFile dis =  new RandomAccessFile(new File(&quot;fotech1.bin&quot;), &quot;r&quot;);     short[] myarray = new short[256000];  int cnt;  for (cnt = 0; cnt &lt; 1; cnt++) {      myarray[cnt] = dis.readShort();  }  fis.close();  System.out.println(&quot;Done.&quot;);        FileOutputStream fos = new FileOutputStream(new File(&quot;o22.bin&quot;));        BufferedOutputStream bos = new BufferedOutputStream(fos);        DataOutputStream dos = new DataOutputStream(bos);//  RandomAccessFile dos =  new RandomAccessFile(new File(&quot;o22.bin&quot;), &quot;rw&quot;);           for (cnt = 0; cnt &lt; 1; cnt++) {         dos.writeShort(myarray[cnt]);        }  System.out.println(&quot;Finish.&quot;);  bos.flush();  fos.close();   }}&lt;br /&gt;&lt;br /&gt;More details, except the example: http://www.darksleep.com/player/JavaAndUnsignedTypes.html</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/2438792346539056638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/2438792346539056638' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2438792346539056638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2438792346539056638'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/bug-howto-how-java-read-8-bit-and-16.html' title='BUG, HOWTO: how java read 8-bit and 16-bit'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-1184851218253353315</id><published>2009-07-17T17:33:00.005+01:00</published><updated>2009-07-17T18:02:41.354+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: run remote X11 applications</title><content type='html'>&lt;p&gt;The server is running on Linux. To run the remote server applications on my own machine:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;On Windows:&lt;br /&gt;=======================&lt;br /&gt;1. Install Xming as the X11 server.&lt;br /&gt;2. Run Putty, as ssh client, with the X11 forwarding arguments: &#39;localhost:0&#39; or &#39;:0&#39;, or even with blank only enable forwarding.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On Mac OSX&lt;br /&gt;=======================&lt;br /&gt;1. run: ssh -X -l username 192.168.1.XXX&lt;br /&gt;* using Putty: with the X11 forwarding arguments: &#39;:0&#39;!!!!!!!!&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On Linux&lt;br /&gt;=======================&lt;br /&gt;1. run: ssh -X -l username 192.168.1.XXX&lt;br /&gt;* using Putty: with the X11 forwarding arguments: &#39;:0&#39; or blank.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/1184851218253353315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/1184851218253353315' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1184851218253353315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/1184851218253353315'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/howto-run-remote-x11-applications.html' title='HOWTO: run remote X11 applications'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-6727687767347168650</id><published>2009-07-12T23:07:00.002+01:00</published><updated>2009-07-12T23:10:47.094+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="tip"/><title type='text'>HOWTO: install Adobe Air on Feodra 11</title><content type='html'>Just guest Redhat developers want to improve the boot speed, they make the fedora 11 without some &#39;useful&#39; packages by default. This makes some program can not installed properly, such as Adobe Air.&lt;br /&gt;&lt;br /&gt;The fix:&lt;br /&gt;================&lt;br /&gt;&lt;blockquote style=&quot;font-weight: bold;&quot;&gt;yum -y install xterm gtk2-devel gnome-keyring libxml2-devel libxslt rpm-devel nss&lt;/blockquote&gt;From: yum -y install xterm gtk2-devel gnome-keyring libxml2-devel libxslt rpm-devel nss</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/6727687767347168650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/6727687767347168650' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6727687767347168650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6727687767347168650'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/howto-install-adobe-air-on-feodra-11.html' title='HOWTO: install Adobe Air on Feodra 11'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-2749476595708748830</id><published>2009-07-12T11:26:00.002+01:00</published><updated>2009-07-12T11:45:10.310+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bug"/><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><category scheme="http://www.blogger.com/atom/ns#" term="tip"/><title type='text'>放弃在Mac 10.5.7 上安装GNUstep 0.23</title><content type='html'>经过大半个星期的下班时间调试，尝试在Mac osx 10.5.7 （darwin 9.7）上安装GNUstep 0.23，最终没有成功，还把Mac弄残一次，我猜可能是由于compiling的时候出现的segmentation fault致使Kernel Panic。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;总结失败教训如下：&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;make的时候，常常是需要 $LDFLAG 比用到 $DYLD_LIBRARY_PATH 的时候多。后者貌似更像是运行程序的时候使用，而不是configure和make时候用。&lt;/li&gt;&lt;li&gt;Mac作为操作系统，其界面无可争议，但是底层系统方面，我个人觉得还不如Linux。在最近的console下编译程序的时候，出现两次致使Mac不断重启的情况，而解决方法都是不得不重装系统后，第二次更离谱，连cmd＋s的single user mode都无法进入。Mac啊，现在给我的感觉是典型的外强中干。&lt;/li&gt;&lt;li&gt;GNUstep需要有gnu的objc runtime，如果用默认的设置，必然使得其调用mac自带的gcc和objc的库，这样肯定会带来些兼容性的问题。 我猜我弄出的两次mac无法开机不断重启，与此两种不兼容并冲突的objc有关系。因为GNUstep在ubuntu 9.04和fedora 11下编译运行的很好。如果想在Mac上安装，我觉得还得是要等macports提供，macports跟进的还算不错，对gnustep，和官方新版本放出的时间也就差2个星期左右。可是，macports下的objc目前还不能安装，等到这个出现后，可以再试编译gnustep源文件。&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;以下是我用到的env设置：&lt;/div&gt;&lt;div&gt;&lt;div&gt;#export LDFLAGS=&#39;-L/usr/local/lib -L/usr/lib -L/opt/local/lib -L/sw/lib&#39;&lt;/div&gt;&lt;div&gt;export LDFLAGS=&#39;-L/opt/local/lib -L/sw/lib -L/usr/GNUstep/Local/Library/Libraries&#39;&lt;/div&gt;&lt;div&gt;#export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/opt/local/lib:/sw/lib&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;export CPPFLAGS=&#39;-I/opt/local/include -I/sw/include&#39;&lt;/div&gt;&lt;div&gt;#export CFLAGS=&#39;-I/usr/local/include -I/usr/include -I/opt/local/include -I/sw/include&#39;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;export PATH=/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sb:/usr/bin:/bin:/usr/sbin:/sbin&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;注：个人认为，在编译gnu的程序时，最好避免用到mac自带的一些命令。而且，最好在编译之前，把/usr/bin/gcc改成是 /opt/local/bin/gcc-mp-4.2这样的，以防止避免gnu和mac的程序冲突。&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/2749476595708748830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/2749476595708748830' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2749476595708748830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/2749476595708748830'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/mac-1057-gnustep-023.html' title='放弃在Mac 10.5.7 上安装GNUstep 0.23'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-556398935819338468</id><published>2009-07-09T00:07:00.002+01:00</published><updated>2009-07-09T00:11:15.846+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="howto"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>HOWTO: remove files older than N days</title><content type='html'>Command Syntax&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;find /path/to/files* -mtime +5 -exec rm {} \;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Note that there are spaces between rm, {}, and \;&lt;br /&gt;&lt;p&gt;Usage:&lt;br /&gt;======================&lt;br /&gt;Extremely useful for Miro, because it doesn&#39;t delete files unwatched. So with this command added in /usr/bin/miro, the Miro library will keep only latest videos no matter you watch it or not.&lt;br /&gt;&lt;/p&gt;Explanation&lt;br /&gt;=======================&lt;br /&gt;The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.&lt;br /&gt;The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.&lt;br /&gt;&lt;p&gt;The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Command from: http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/556398935819338468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/556398935819338468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/556398935819338468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/556398935819338468'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/howto-remove-files-older-than-n-days.html' title='HOWTO: remove files older than N days'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-7849759674783220187</id><published>2009-07-07T22:33:00.006+01:00</published><updated>2009-07-08T23:17:21.249+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><category scheme="http://www.blogger.com/atom/ns#" term="tip"/><title type='text'>HOWTO: compile source code on MAC OS X</title><content type='html'>Conditions:&lt;div&gt;======================&lt;/div&gt;&lt;div&gt;Macport (recommended, can be found on apple.com, updated and organized well) and Fink are installed in default locations, /opt/local and /sw.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note: Fink is buggy, normally reinstallation on the previous version will not work, issues like path setup maybe occur, either bin files or libraries are not accessible. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To compile: &lt;/div&gt;&lt;div&gt;======================&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;For library invoking:&lt;br /&gt;export LDFLAGS=&#39;-L/usr/local/lib -L/usr/lib -L/opt/local/lib -L/sw/lib&#39;&lt;br /&gt;- &#39;-L/dir&#39; is the convention to setup gcc switch, while -L for make is --check-symlink-times, useless for me :)&lt;br /&gt;- Official way for invoking library is to setup $DYLD_LIBRARY_PATH (export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/opt/local/lib:/sw/lib), which in Linux is $LD_LIBRARY_PATH by default.&lt;br /&gt;- Normally lib path don&#39;t need specified, because the bin files (in /usr/bin or /opt/local/bin&#39; will know where to get appropriate libraries, no matter bin files from Macports or Fink.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;For header files invoking:&lt;br /&gt;export CPPFLAGS=&#39;-I/usr/local/include -I/usr/include -I/opt/local/include -I/sw/include&#39;&lt;br /&gt;- This is the way to setup both &#39;make&#39; and &#39;gcc&#39; switch, which is &#39;make -I/usr/local/include&#39;.&lt;div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example:&lt;/div&gt;&lt;div&gt;=====================&lt;/div&gt;&lt;div&gt;The following are what I typed in terminal with user root to compile GNUstep-0.22.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;export CPPFLAGS=&#39;-I/usr/local/include -I/opt/local/include&#39;&lt;/div&gt;&lt;div&gt;export LDFLAGS=&#39;-L/usr/local/lib -L/usr/lib -L/opt/local/lib -L/sw/lib&#39;&lt;/div&gt;&lt;div&gt;export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/opt/local/lib:/sw/lib:/usr/GNUstep/Local/Library/Libraries&lt;/div&gt;&lt;div&gt;. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/7849759674783220187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/7849759674783220187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7849759674783220187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7849759674783220187'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/howto-compile-source-code-on-mac-os-x.html' title='HOWTO: compile source code on MAC OS X'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-8266204631753129521</id><published>2009-07-05T21:22:00.002+01:00</published><updated>2009-07-05T22:26:41.476+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><title type='text'>MAC OS X: change the environment PATH</title><content type='html'>To add a new directory to the path, simply add it to the existing PATH line in .profile being careful to separate it from other directories there with colons and careful not to introduce unwanted spaces (everything after the space will be ignored). For example, to add the directory /mightyq/bin to the PATH shown above, the line could become any of the following examples: &lt;p&gt;&lt;code&gt;export PATH=/mightyq/bin:/opt/local/bin:/opt/local/sbin:$PATH&lt;br /&gt;export PATH=/opt/local/bin:/mightyq/bin:/opt/local/sbin:$PATH&lt;br /&gt;export PATH=/opt/local/bin:/opt/local/sbin:$PATH:/mightyq/bin&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Note that in the third example the new directory is added to the end of the PATH. You have the ability to optimize the searches your shell will do on your behalf each time you run a command by organizing your PATH logically. Putting less frequently used or really massive directories later in the path may give you a little performance boost (although these days things are pretty fast, so you have to be a little anal to really enjoy this).&lt;/p&gt; &lt;p&gt;If you don’t need a directory in your path, you can reverse the process by deleting the unwanted directory still taking care to preserve the no spaces, colon separation rules.&lt;/p&gt; &lt;p&gt;One last note, to test the change you made, you can use the echo command, but you need to make the shell reload the .profile first. Assuming you are in your home directory (if not, running ‘cd’ without any options will take you there), run these commands:&lt;/p&gt; &lt;p&gt;&lt;code&gt;. ./.profile&lt;br /&gt;echo $PATH&lt;/code&gt;&lt;/p&gt; &lt;p&gt;The first . is a shortcut to cause the shell to ’source’ or load the contents of the subsequent file as itself, in the manner that the shell uses when you login to a system or start a Terminal window. If you simply executed these commands like a shell script (bash .profile, for example) you would start a new shell, that shell would get the variable set, and at the end of running the .profile script, that new shell would cease to exist and the newly defined variables would be relegated to the missing sock universe.&lt;span style=&quot;font-weight: bold;&quot;&gt;While . makes the variables generated from new shell ( child shell ) return to the current shell (parent shell).&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/8266204631753129521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/8266204631753129521' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8266204631753129521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/8266204631753129521'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/mac-os-x-change-environment-path.html' title='MAC OS X: change the environment PATH'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-7859457843126859914</id><published>2009-07-04T18:12:00.002+01:00</published><updated>2009-07-04T18:15:44.130+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bug"/><title type='text'>BUG: GNUstep Project Center can not generate the conf for &#39;MAIN_MODEL_FILE&#39;</title><content type='html'>GNUstep Project Center (0.5.0) can not generate the conf for &#39;MAIN_MODEL_FILE&#39;, therefore, to make the GUI (gorm style) work, put corresponding configuration in the &#39;GNUmakefile&#39;. Like the following:&lt;br /&gt;&lt;br /&gt;#&lt;br /&gt;# Main application&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;PACKAGE_NAME=SimpleApp&lt;br /&gt;&lt;br /&gt;APP_NAME=SimpleApp&lt;br /&gt;SimpleApp_MAIN_MODEL_FILE=MainMenu.gorm</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/7859457843126859914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/7859457843126859914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7859457843126859914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/7859457843126859914'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/bug-gnustep-project-center-can-not.html' title='BUG: GNUstep Project Center can not generate the conf for &#39;MAIN_MODEL_FILE&#39;'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6752719756197775967.post-6293206366619205826</id><published>2009-07-04T15:12:00.002+01:00</published><updated>2009-07-04T15:15:29.812+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><title type='text'>The missing part in Gorm Manual on GNUstep, about &#39;NewClass&#39; controller</title><content type='html'>&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8 Creating an Application&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    If you have ProjectCenter, you need to open it and create an “Application” project.&lt;br /&gt;Create it with the name “FirstApp”. From there you can open the MainMenu.gorm by&lt;br /&gt;clicking on interfaces and selecting MainMenu.gorm. If Gorm.app is properly installed, you&lt;br /&gt;Gorm should start up.&lt;br /&gt;    If you don’t have ProjectCenter, you can create the Gorm file by hand. First you need&lt;br /&gt;to start Gorm. You can either do this by doing ‘gopen Gorm.app’ from a command line&lt;br /&gt;prompt, or you can invoke it from the Dock or from the workspace’s file viewer.&lt;br /&gt;    You then need to select the ‘Document’ menu, and then ‘New Application’. This should&lt;br /&gt;produce a new document window, with a menu and an empty window. This should be&lt;br /&gt;the same as with the ProjectCenter gorm file since this is the basic starting point for an&lt;br /&gt;application.&lt;br /&gt;    For the sections below... only do one or the other, not both.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.1 Creating A Class In Gorm&lt;/span&gt;&lt;br /&gt;    There are two ways to do this next operation. I will take you through each step by step.&lt;br /&gt;First click on the classes icon in the toolbar on the top of the Gorm document window.&lt;br /&gt;You should see the view below change to an outline view containing a list of class names.&lt;br /&gt;Once this happens we’re ready to create a class. Select the class you wish to subclass in&lt;br /&gt;the outline view. For our example we will use the simplest: NSObject. Select it by clicking&lt;br /&gt;on the class name once. Then go to the Classes menu in the main menu and select Create&lt;br /&gt;Subclass (you can also type Alt-Shift-c, which will do this as well. The new class will be&lt;br /&gt;created in the list with the name “NewClass”.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.2 Using The Outline View&lt;/span&gt;&lt;br /&gt;    From here double click on the subclass name to make it editable. Type the name of the&lt;br /&gt;class and hit enter. For our example, please use the class name MyController. When you&lt;br /&gt;hit enter an alert panel will appear and warn you about breaking connections, simply select&lt;br /&gt;OK and continue.&lt;br /&gt;    This method of inputting the classes was inspired by IB in OPENSTEP 4.2/Mach which&lt;br /&gt;had functionality very similar to this. For users of that the transition to Gorm will be&lt;br /&gt;seamless.&lt;br /&gt;8.2.1 Adding Outlets In The Outline View&lt;br /&gt;    Too add an outlet, select the round icon with the two horizontal lines in it (it sort of looks&lt;br /&gt;like a wall outlet. This should become depressed. Here you need to go to the Gorm Menu,&lt;br /&gt;under Classes select “Add Outlet/Action”. Each time you press this menu item another&lt;br /&gt;outlet will be added with a name similar to newOutlet, as you add more the number at the&lt;br /&gt;end will increase. For now add only one outlet.&lt;br /&gt;    To rename the outlet simply double click it and change it’s name like you did the class&lt;br /&gt;above to “value” for the sake of our example.&lt;br /&gt;Chapter 8: Creating an Application                                                         20&lt;br /&gt;8.2.2 Adding Actions In the Outline View&lt;br /&gt;    The procedure to add on action is precisely the same as adding an outlet, except you&lt;br /&gt;must click on the button which looks like a target (a circle with a + inside). Add an action&lt;br /&gt;and name it “buttonPressed:” for the sake of our example.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.3 Using The Class Edit Inspector&lt;/span&gt;&lt;br /&gt;    This way is much more inline with the “OPENSTEP/GNUstep” philosophy. For each&lt;br /&gt;object there is an inspector, even for Class objects.&lt;br /&gt;    Once you have created the class as described in the previous section “Creating a Class&lt;br /&gt;In Gorm”, you must skip to this section to use the inspector. In the Gorm main menu&lt;br /&gt;select Tools and then select “Inspectors”. This will make certain that the inspectors win-&lt;br /&gt;dow is being displayed. Once the inspectors window is up move the pulldown on the top&lt;br /&gt;to “Attributes” and select the class you created which should, at this point, have the name&lt;br /&gt;“NewClass”. You’ll notice that the “Class” field at the top which shows the name’s back-&lt;br /&gt;ground color has turned white, instead of grey. This indicates that this class name is&lt;br /&gt;editable. Erase “NewClass” from the text field and type “MyController”.&lt;br /&gt;8.3.1 Adding Outlets In The Inspector&lt;br /&gt;    Adding outlets is very intuitive in the inspector. Simply select the “Outlets” tab in the&lt;br /&gt;tab view and click “Add” to add more outlets, and “Remove” to remove them. For the sake&lt;br /&gt;of our example, add one outlet and name it “value”.&lt;br /&gt;8.3.2 Adding Actions In the Inspector&lt;br /&gt;    Very much like above only with the “Actions” tab, add an action called button pressed.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.4 Instantiating The Class&lt;/span&gt;&lt;br /&gt;    In the Classes outline view select the new class you’ve created, now called MyController&lt;br /&gt;and then go to the Gorm menu and select Classes, and then Instantiate. The document&lt;br /&gt;window should shift from the classes view to the objects view. Amoung the set of objects&lt;br /&gt;should be a new object called MyController.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.5 Adding Controls from the Palette&lt;/span&gt;&lt;br /&gt;    Go to the Gorm menu and select Tools, then Palettes. This will bring the palette window&lt;br /&gt;to the front. The second palette from the left is the “ControlsPalette”. Select that one and&lt;br /&gt;find the button object (it should have the word “Button” in it). Drag that to the window&lt;br /&gt;and drop it anywhere you like.&lt;br /&gt;    Repeat this operation with the text field. It’s the control with “Text” in it. We are now&lt;br /&gt;ready to start making connections between different objects in the document.&lt;br /&gt;Chapter 8: Creating an Application                                                       21&lt;br /&gt;8.5.1 Making Connections&lt;br /&gt;    The type of application we are creating is known as a “NSApplication delegate” this&lt;br /&gt;means that the MyController object will be set as the delegate of NSApplication.&lt;br /&gt;    To make this connection click on NSOwner and hold down the Control button, keep it&lt;br /&gt;pressed as you drag from the NSOwner object to the MyController object. The inspectors&lt;br /&gt;window should change to the Connections inspector and should show two outlets “delegate”&lt;br /&gt;and “menu”. Select the “delegate”, at this point you should see a green S and a purple T&lt;br /&gt;on the NSOwner and MyController objects respectively, and press the “Connect” button&lt;br /&gt;in the inspector. In the “Connections” section of the inspector you should see an entry&lt;br /&gt;which looks similar to “delegate (MyController)” this indicates that the connection has&lt;br /&gt;been made.&lt;br /&gt;    Now we need to make connections from the controller to the textfield and from the&lt;br /&gt;controller to the button. Select the MyController object and Control-Drag (as before)&lt;br /&gt;from the object to the text field, this will make an outlet connection. You should see the&lt;br /&gt;connections inspector again, this time select the “value” outlet and hit Connect.&lt;br /&gt;    Next, control-drag from the button to the controller, this will make an action connec-&lt;br /&gt;tion. The connections inspector should again appear. This time you need to select the&lt;br /&gt;“target” outlet, to get the list of actions. The list should have only one entry, which is&lt;br /&gt;“buttonPressed:” since this is the one we added earlier. Press Connect. You should see an&lt;br /&gt;entry like “buttonPressed: (MyController” in the Connections section of the inspector.&lt;br /&gt;    It is also possible to make this connection to NSFirst, but to keep things simple, make&lt;br /&gt;it directly to the object. If you make the connection to buttonPressed: on NSFirst the&lt;br /&gt;functionality of the application will be unchanged, but the invocation will take the path&lt;br /&gt;described above in the section which describes “The Responder Chain”.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.6 Saving the gorm file&lt;/span&gt;&lt;br /&gt;    At this point you must save the .gorm file. Go to the Gorm menu and click Documents&lt;br /&gt;and then select “Save”. If the document was opened from a pre-existing .gorm, it will save&lt;br /&gt;to that same file name. If it is an UNTITLED .gorm file a file dialog will appear and you&lt;br /&gt;will need to select the directory where you want to store the .gorm file and type the name&lt;br /&gt;of the .gorm file.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;8.7 Generating .h and .m files from the class.&lt;/span&gt;&lt;br /&gt;    This is different than saving, some people have gotten this confused with the idea of&lt;br /&gt;Gorm generating the code for the gui. Gorm does nothing of the sort (grin).&lt;br /&gt;    Go to the Classes section in the Document window and select the MyController class yet&lt;br /&gt;again. Now go to the Gorm menu and select Classes and the select “Create Class Files”.&lt;br /&gt;This will bring up a file panel and it allow you to select the directory in which to put the&lt;br /&gt;files. It will first create the MyController.m file and then the MyController.h file. Simply&lt;br /&gt;select the directory in which your app will reside and hit okay for both. You can change&lt;br /&gt;the names, but the default ones, which are based on the class name, should be sufficient.&lt;br /&gt;&lt;br /&gt;When you look at the .m for this class, you should see the ‘buttonPressed:’ method with&lt;br /&gt;the commecnt ‘/* insert your code here */’ in it. Delete this comment and add ‘[value&lt;br /&gt;setStringValue: @‘‘Hello’’];’. The class should look like this after you’re done:&lt;br /&gt;   /* All Rights reserved */&lt;br /&gt;   #include &lt;appkit/appkit.h&gt;&lt;br /&gt;   #include &quot;MyController.h&quot;&lt;br /&gt;   @implementation MyController&lt;br /&gt;   - (void) buttonPressed: (id)sender&lt;br /&gt;   {&lt;br /&gt;   [value setStringValue: @”Hello”];&lt;br /&gt;   }&lt;br /&gt;   @end&lt;br /&gt;   You recall, we connected the textfield to the “value” variable. The call above causes the&lt;br /&gt;method setStringValue to be invoked on the textfield you added to the window.&lt;br /&gt;   Also, note that the name of the method is “buttonPressed:”. This is the action which is&lt;br /&gt;bound to the button. When it is pressed the text in the textfield should change to “Hello”.&lt;br /&gt;   You now need to build the application either by copying in a GNUmakefile and making&lt;br /&gt;the appropriate changes or by using ProjectCenter’s build capability, depending on if you&lt;br /&gt;use it or not.&lt;br /&gt;   This app is available as “SimpleApp” in the Examples directory under the Documen-&lt;br /&gt;tation directory distributed with Gorm. Hopefully this has helped to demonstrate, albeit&lt;br /&gt;on a small scale, the capabilities of Gorm. In later chapters we will cover more advanced&lt;br /&gt;application architectures and topics.</content><link rel='replies' type='application/atom+xml' href='http://crossonline.blogspot.com/feeds/6293206366619205826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6752719756197775967/6293206366619205826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6293206366619205826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6752719756197775967/posts/default/6293206366619205826'/><link rel='alternate' type='text/html' href='http://crossonline.blogspot.com/2009/07/missing-part-in-gorm-manual-on-gnustep.html' title='The missing part in Gorm Manual on GNUstep, about &#39;NewClass&#39; controller'/><author><name>UK Cross</name><uri>http://www.blogger.com/profile/01752347149524960832</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XBqKtBn2QbS_EOKf2oPlQLEqSZf-tLF4KDE0nz2bsF2wzKarxHNsIwiuWa9qrdV6BzQPrR9mwwmsGCplV5iCcwJ2O2pDfl1bWcJItiW5H-rOHikEyzF3tJToZ0z37g/s220/pic.php.jpeg'/></author><thr:total>0</thr:total></entry></feed>