<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A0YBRH8zfip7ImA9WxBbEUs.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552</id><updated>2010-03-09T13:12:35.186-08:00</updated><title type="text">Vincent Liu - Coding Is An Art</title><subtitle type="html">Writing good software takes time, experience and dedication, in which I try to chronicle my thoughts as a software developer in my blog to share with you.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.vinceliu.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>146</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/VincentLiu" /><feedburner:info uri="vincentliu" /><geo:lat>37.766529</geo:lat><geo:long>-122.39577</geo:long><logo>http://www.vinceliu.com/vinceliu.ico</logo><feedburner:emailServiceId>VincentLiu</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/VincentLiu" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FVincentLiu" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:browserFriendly>Hi there, this is my personal blog about my personal thoughts in software, and other news that captures my attention. If you share the same interests as I do, do feel free to subscribe to my blog feed, or leave a comment!</feedburner:browserFriendly><entry gd:etag="W/&quot;C0AAQ3o_fip7ImA9WxBWEEg.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1908423124682726438</id><published>2010-01-31T08:22:00.000-08:00</published><updated>2010-02-01T11:15:42.446-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-01T11:15:42.446-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Health" /><title>Calorie Counting Dinner</title><content type="html">Calorie counting is a futile exercise. Can you imagine yourself to be meticulously noting down every single thing you put into your mouth throughout the day? Even if you are able to count Calories with the accuracy of an accounting auditor, you will still never get exact numbers. Our food just do not come in standard calibrated units that happily lend itself to exact, precise calculations. Therefore is there any merit in such an exercise at all?&lt;br /&gt;&lt;br /&gt;The science behind the Glycemic Index tells us that food is not digested at a uniform rate, and by similar reasoning, it is not unlikely that not all food is absorbed uniformly too. So even if 'a Calorie is a Calorie' seducively sounds like a single reducible truth, we are doing ourselves a disservice if we believe that food can be cut down to a single number alone. While I won't argue against having a rough ballpark number to work with, there should be some sensibility on not relying on it too specifically.&lt;br /&gt;&lt;br /&gt;To the avid hard-core Calorie counters out there, let me satisfy you a little with my own Calorie counting exercise. Here is a snapped picture of what I normally have for dinner:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/S2Wuq0t4HdI/AAAAAAAAAP8/kStZzt9WGvg/s1600-h/P1030903.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/S2Wuq0t4HdI/AAAAAAAAAP8/kStZzt9WGvg/s400/P1030903.JPG" alt="" id="BLOGGER_PHOTO_ID_5432940576221175250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;All the food is cooked in a steamer, seasoned with some salt, plus pepper on the trout that I was having. There are no cooking oil or any other added ingredients to what you are seeing, so what you see is what you get. I'll go through the breakdown of what was in my dinner:&lt;br /&gt;&lt;br /&gt;Onion, whole&lt;br /&gt;Beetroot, whole&lt;br /&gt;Carrot, 1 stick&lt;br /&gt;Sweet potato, 1/2&lt;br /&gt;Asparagus, 8 tips&lt;br /&gt;Coriander, 2 sprigs&lt;br /&gt;Leek, 5 slices (not visible, under trout)&lt;br /&gt;Rainbow Trout, 250gm&lt;br /&gt;&lt;br /&gt;Let's try to calculate the total Calorie intake. It will not be accurate, but I'll give higher numbers on all my estimates just for argument:&lt;br /&gt;&lt;br /&gt;Onion (94gm) - 41 Calories&lt;br /&gt;Beetroot (87gm) - 37 Calories&lt;br /&gt;Carrot (61gm) - 25 Calories&lt;br /&gt;Sweet Potato (84gm) - 72 Calories&lt;br /&gt;Aspragus (120gm) - 26 Calories&lt;br /&gt;Leek (26gm) - 15 Calories&lt;br /&gt;Rainbow Trout (250gm) - 387 Calories&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Total Calorie Intake:&lt;/span&gt; 603 Calories&lt;br /&gt;&lt;br /&gt;That's typical dinner, and sometimes with an additional fruit or cheese as dessert after. That is usually all for dinner, and I do not consume any more after I cleaned up my kitchen. If I make a simplistic projection of these numbers to a full day (x3 for breakfast, lunch and dinner), then I'm consuming less Calories than the standard daily requirement! So if the standard is to be believed, then by definition I must be starving!&lt;br /&gt;&lt;br /&gt;Our environment is a complex one, and our bodies are miraculous complex organisms that have to deal with this complexity. We have many bodily functions that regulate themselves autonomously without conscious thought or control, and our body constantly adjusts itself based on the feedback it receives; we feel sleepy when we are tired, our bodies ache and stop us from hurting ourselves when we over-tax it, we get thirsty when we are dehydrated. Shouldn't that mean it is naturally correct that we eat only when we are hungry?&lt;br /&gt;&lt;br /&gt;There is no reason not to trust our bodies to do the right thing. If I am not feeling hungry from my food intake, then my body is telling me that I am not in energy deficit. And I trust that my body is right. Who do you believe, your body or the standard conventional wisdom out there?&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1908423124682726438?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=4_3hAZBhroM:Z9WqGOyJYLo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=4_3hAZBhroM:Z9WqGOyJYLo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=4_3hAZBhroM:Z9WqGOyJYLo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=4_3hAZBhroM:Z9WqGOyJYLo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=4_3hAZBhroM:Z9WqGOyJYLo:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=4_3hAZBhroM:Z9WqGOyJYLo:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=4_3hAZBhroM:Z9WqGOyJYLo:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=4_3hAZBhroM:Z9WqGOyJYLo:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/4_3hAZBhroM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1908423124682726438/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2010/01/calorie-counting-dinner.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1908423124682726438?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1908423124682726438?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/4_3hAZBhroM/calorie-counting-dinner.html" title="Calorie Counting Dinner" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_lSk990LIlbk/S2Wuq0t4HdI/AAAAAAAAAP8/kStZzt9WGvg/s72-c/P1030903.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2010/01/calorie-counting-dinner.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIGQn0_eyp7ImA9WxBXEks.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-9023136570636165792</id><published>2010-01-23T07:47:00.000-08:00</published><updated>2010-01-23T08:18:43.343-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-23T08:18:43.343-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Philosophy" /><title>Food and the meaning in life</title><content type="html">I have not been writing for a while, you may have noted. What have I been doing with my free time?&lt;br /&gt;&lt;br /&gt;These days I have been researching on a number of quite arbitrary and seemingly unfocused things, but even with all that arbitrariness, it still has much to do with my philosophising on life. If there is one notable aspect that has consumed my more of time these days, it will have to do with researching about nutrition. So how is that to do with philosophy? If you think about how much food actually affects your quality of life, then the answer is &lt;span style="font-style:italic;"&gt;'a lot'&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Food has always been an on-and-off topic between colleagues and friends, and it is still surprisingly a subject area that I can't seem to be able to form an objective opinion upon. There is a bewildering number of conflicting literature on the science of food, and nobody, not even medical specialists, seem to be able to come to an agreement of what actually is good for you. What we have out there today is mainly unquestioned conventional wisdom, versus various splinter food cultures with their advocates and strong opinions to boot.&lt;br /&gt;&lt;br /&gt;One aspect of food nutrition that I am interested in has been the topic of weight loss. For those who know me, you will be challenging on why this would even be my subject of interest, given that I have no personal stake in dealing with any weight issues. True, but I have always been curious to why I'm a perpetual a non-gainer no matter what I eat, while others seem to put on weight on even the most minuscule of calorie intake.&lt;br /&gt;&lt;br /&gt;Sometimes people blame it on genetics. It makes sense from an evolutionary aspect since some people are more efficient at storing extra energy than others, given that food supply was inconsistent in the past. It would have been beneficial for humans to store surplus energy, but I have my doubts that this is the key reason, given that the obesity problem has only surfaced within the last century - I'm willing to bet my money that it's more likely that the problem comes from the composition of our food itself.&lt;br /&gt;&lt;br /&gt;Recently, one of my colleagues had completed his weight-loss regime. He had been going on a low carbohydrate diet, coupled with a sachet of weight loss formula, which he had good results in losing around 10lbs (4.5kg) within 3 months. The talk about a 'low carb' diet became a talking point as it reminded me of the Atkins diet that had been associated with a reputation of varying between effective and crazily faddish.&lt;br /&gt;&lt;br /&gt;Given my current interest in food nutrition, I decided to offer some interesting, counter-intuitive opinions on his diet. Basically, I told him that his 'low carb' diet was essentially a 'high fat' one! Obviously he didn't seem happy with my explanation, since it flies in the face of conventional wisdom - you gain weight consuming fat, not lose it. My explanation was relatively simple, if not immediately obvious.&lt;br /&gt;&lt;br /&gt;There are only 3 categories of energy sources we derive from food, carbohydrates, proteins and fats. It is not possible for someone to sustain himself purely from a protein only diet, as he would have suffered from a condition called 'rabbit starvation'. Proteins at high amounts is essentially toxic, aside one symptom that protein poisoning will have caused is ravenous, insatiable hunger. If that were the case, it would have been impossible for him to diet, since it is not an issue that can be subdued by willpower alone. Dieting in such condition is as futile as trying to stop yourself from breathing. Unless he's starving himself literally, his only viable energy replacement would have to be coming from fats.&lt;br /&gt;&lt;br /&gt;I have no idea what he was eating during the diet period (hardly anything from my observation), but it was obviously likely that in the absence of any energy input through food consumption, his body would naturally utilise its fat reserves, causing him to lose weight. But I believe that weight loss through dieting is orthogonal to the real problem of keeping it off permanently. You do get quick and good results during short dieting binges, but it is equally likely that you'll regain it back as quickly as you have taken it away.&lt;br /&gt;&lt;br /&gt;This is because the urge to over consume on your food has not decreased. It has been shown that &lt;a href="http://www.eurekalert.org/pub_releases/2009-09/mu-rda092409.php"&gt;willpower is a limited resource&lt;/a&gt;, and when you go on a diet, you are essentially pushing your willpower to overcome your urges given by your brain to consume (more) food. A diet is hardly anything natural or sustainable if you can only maintain it for a limited of time. Eventually your willpower will break down, and you'll go back to your normal eating habits again, so whatever loss you are seeing will be temporary.&lt;br /&gt;&lt;br /&gt;The impetus to tackle weight gain is really to be addressing the real issue behind the problem over-consumption. The current science of blaming fats as a bogeyman to tackling the real problem, like any dismayal science, really isn't helping. It willfully ignores that fact that any food you eat will cause you to become fat when consumed in excess - it is just restating the laws of thermodynamics. Not besides the fact that I've seen plenty chubby friends despite being on a low fat diet for perpetuity. &lt;br /&gt;&lt;br /&gt;I've recently watched this video titled, "Sugar: a bitter truth", by Professor Robert H. Lustig which has strengthened this belief. He labels sugar as the key cause of obesity, and presents a clear cut explanation of how sugar intake increases appetite:&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/dBnniua6-oM&amp;hl=en_US&amp;fs=1&amp;rel=0"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/dBnniua6-oM&amp;hl=en_US&amp;fs=1&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Generally when a doctor puts his neck out against conventional wisdom, he is either convinced he is right or a crackpot out for fame and notoriety. I can only suggest to do your own research and make your own conclusions. There are good literature out there to suggest that obesity isn't the result of a high fat diet, but a high sugar one. Some might nitpick that it's very specifically high fructose, I don't disagree, but do remember that sucrose (table sugar) is one part glucose and one part fructose.&lt;br /&gt;&lt;br /&gt;Sugar isn't categorically the culprit for obesity, but if it is a cause for driving your up brain signals to consume, then it stands to reason that an increased sugar intake will lead to over-consumption. And if willpower is expendable, the only sustainable way to ensure a permanent weight loss is to cut down on sugar intake.&lt;br /&gt;&lt;br /&gt;I suggested to my colleague that the easiest solution to weight loss is to simply stop consuming all forms of added sugar. He was aghast.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;"If I can't have my lollipops and cookies, what would be the meaning in life? I much rather be fat and lose a few years of my life than to stop eating sugar at all."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which means to say that sometimes the most obvious solutions aren't always the easiest.&lt;br /&gt;&lt;br /&gt;Isn't it remarkable that seemingly trivial things like food choices can be difficult when you have to make conscious, rational choices? Now isn't that worth philosophising about? Food for thought anyone? :)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-9023136570636165792?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=qd8_umLBTfk:lpTvGTXhxSY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=qd8_umLBTfk:lpTvGTXhxSY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=qd8_umLBTfk:lpTvGTXhxSY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=qd8_umLBTfk:lpTvGTXhxSY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=qd8_umLBTfk:lpTvGTXhxSY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=qd8_umLBTfk:lpTvGTXhxSY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=qd8_umLBTfk:lpTvGTXhxSY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=qd8_umLBTfk:lpTvGTXhxSY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/qd8_umLBTfk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/9023136570636165792/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2010/01/food-and-meaning-in-life.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/9023136570636165792?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/9023136570636165792?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/qd8_umLBTfk/food-and-meaning-in-life.html" title="Food and the meaning in life" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.vinceliu.com/2010/01/food-and-meaning-in-life.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MBRHY7fSp7ImA9WxNaFEQ.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-4092424210767523797</id><published>2009-11-28T09:19:00.001-08:00</published><updated>2009-11-29T02:44:15.805-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-29T02:44:15.805-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><title>Compiling Ruby 1.9 for Mac OSX 10.4</title><content type="html">This article contains specifics for installing Ruby on PowerPC MacOSX 10.4. Newer Intel Macs with &amp;gt; 10.4 OS has more updated dependencies and probably do not require the instructions described here; you shouldn't need to compile from source in that case as well - there are one-click installers for binaries for Ruby 1.9 on the Internet, look for it.&lt;br /&gt;&lt;br /&gt;On 10.4 PPC, the default version of Ruby is 1.8.2. This version is now old for some of the ruby plugins to be installed, specifically rubygems 1.3.5 in my case. I won't go into the reasons here on not going for older versions of rubygems (Read &lt;a href="http://blog.vinceliu.com/2009/01/ways-of-solving-slow-gem-install.html"&gt;here&lt;/a&gt; if you are really interested why), but since an upgrade of Ruby is warranted, instead of upgrading to the latest 1.8.x series, it might be worthwhile to try out the new features from the 1.9.x series instead.&lt;br /&gt;&lt;br /&gt;In order to recompile ruby, you'll need &lt;a href="http://developer.apple.com/technology/xcode.html"&gt;Xcode&lt;/a&gt; from Apple. That will install the SDK for developing on Apple's MacOS, but more importantly, it contains the &lt;code&gt;gcc&lt;/code&gt; part of the GNU toolchain required for compilation.&lt;br /&gt;&lt;br /&gt;However the GNU toolchain is incomplete at this stage; we'll require at the minimum GNU &lt;code&gt;m4&lt;/code&gt;, &lt;code&gt;autoconf&lt;/code&gt; and &lt;code&gt;automake&lt;/code&gt; to complete the chain of dependencies Ruby needs.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Not Using Darwin Port/Fink&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'm going to compile these things from source directly without any package management system, and for a good reason; 3rd party MacOS package management systems are usually more trouble than it's worth, either having longer compilation time from spurious dependencies, compilation breakages due to improperly configured parameters or missing specific compiler flags that you'll end up having to fix by hand anyway.&lt;br /&gt;&lt;br /&gt;That said, don't be put off by the exercise of compiling from scratch. It is not difficult, and you'll get to learn a thing or two about the internals of your OS. &lt;br /&gt;&lt;br /&gt;Open up your terminal, and &lt;code&gt;sudo&lt;/code&gt; into &lt;code&gt;root&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:~ vince$ sudo -i&lt;br /&gt;Password:&lt;br /&gt;Tigershark:~ root#&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In order to separate your newly compiled stuffs from your existing binaries, I recommend you create a separate directory under the &lt;code&gt;'/'&lt;/code&gt; directory so that they will be cleanly partitioned. I'm using the directory &lt;code&gt;'/lfs'&lt;/code&gt; in my example here, as a tribute to the &lt;a href="http://www.linuxfromscratch.org/"&gt;Linux from Scratch&lt;/a&gt; project, where I got my derivative knowledge from. Feel free to choose your own directory names though.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:~ root# export LFS=/lfs&lt;br /&gt;Tigershark:~ root# echo "export PATH=$LFS/bin:$PATH" &amp;gt;&amp;gt; /Users/YOURUSERNAME/.profile&lt;br /&gt;Tigershark:~ root# export PATH=$LFS/bin:$PATH&lt;br /&gt;Tigershark:~ root# mkdir -p $LFS/src&lt;br /&gt;Tigershark:~ root# cd $LFS/src&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The code above creates the &lt;code&gt;/lfs&lt;/code&gt; directory, and the &lt;code&gt;'/lfs/src'&lt;/code&gt; directory as well. It also sets up the PATH environment to firstly look in &lt;code&gt;'/lfs/bin'&lt;/code&gt; before it searches all other paths. This is necessary so that you'll be using your new binaries instead of the old system binaries. The same change is added into your user's &lt;code&gt;.profile&lt;/code&gt; file so that Terminal will know to look for the new binaries in the future when it starts up.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Installing m4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# cd $LFS/src&lt;br /&gt;Tigershark:/lfs/src root# curl http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz &amp;gt; m4-1.4.9.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# tar -zxvf m4-1.4.9.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# cd m4-1.4.9&lt;br /&gt;Tigershark:/lfs/src/m4-1.4.9 root# ./configure --prefix=$LFS&lt;br /&gt;Tigershark:/lfs/src/m4-1.4.9 root# make &amp;&amp; make check&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Make sure that the test results come up without any errors. When the test results are satisfied, install it.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/lfs/src/m4-1.4.9 root# make install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Installing autoconf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# cd $LFS/src&lt;br /&gt;Tigershark:/lfs/src root# curl http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz &amp;gt; autoconf-2.65.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# tar -zxvf autoconf-2.65.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# cd autoconf-2.65&lt;br /&gt;Tigershark:/lfs/src/autoconf-2.65 root# ./configure --prefix=$LFS&lt;br /&gt;Tigershark:/lfs/src/autoconf-2.65 root# make &amp;&amp; make check&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Make sure that the test results come up without any errors. When the test results are satisfied, install it.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/lfs/src/autoconf-2.65 root# make install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Installing automake&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# cd $LFS/src&lt;br /&gt;Tigershark:/lfs/src root# curl http://ftp.gnu.org/gnu/automake/automake-1.9.6 &amp;gt; automake-1.9.6.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# tar -zxvf automake-1.9.6.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# cd automake-1.9.6&lt;br /&gt;Tigershark:/lfs/src/automake-1.9.6 root# ./configure --prefix=$LFS&lt;br /&gt;Tigershark:/lfs/src/automake-1.9.6 root# make &amp;&amp; make check&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Make sure that the test results come up without any errors. When the test results are satisfied, install it.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/lfs/src/automake-1.9.6 root# make install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Additional Step: Upgrading libreadline&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Apple's implementation of the &lt;code&gt;readline&lt;/code&gt; library has missing symbols in which Ruby (or more accurately, &lt;code&gt;irb&lt;/code&gt;) requires in order to retrieve command line history. If you do not use &lt;code&gt;irb&lt;/code&gt; (which I doubt, unless you never require testing some code you're uncertain of), you may skip compiling this. But I recommend you do :)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# cd $LFS/src&lt;br /&gt;Tigershark:/lfs/src root# curl http://ftp.gnu.org/gnu/readline/readline-6.0.tar.gz &amp;gt; readline-6.0.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# tar -zxvf readline-6.0.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# cd readline-6.0&lt;br /&gt;&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# curl http://ftp.gnu.org/gnu/readline/readline-6.0-patches/readline60-001 &amp;gt; readline60-001&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# curl http://ftp.gnu.org/gnu/readline/readline-6.0-patches/readline60-002 &amp;gt; readline60-002&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# curl http://ftp.gnu.org/gnu/readline/readline-6.0-patches/readline60-003 &amp;gt; readline60-003&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# curl http://ftp.gnu.org/gnu/readline/readline-6.0-patches/readline60-004 &amp;gt; readline60-004&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# patch -p0 &lt; readline60-001&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# patch -p0 &lt; readline60-002&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# patch -p0 &lt; readline60-003&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# patch -p0 &lt; readline60-004&lt;br /&gt;&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# ./configure --libdir=/usr/local/lib&lt;br /&gt;Tigershark:/lfs/src/readline-6.0 root# make &amp;&amp; make check&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The instructions also contains the additional patches that was released since libreadline 6.0. Make sure you follow those additional instructions to apply the patches correspondingly. &lt;br /&gt;&lt;br /&gt;Also, note that the &lt;code&gt;./configure&lt;/code&gt; parameter has changed. In this case, we are installing a library, so the path to install to is different. We are installing it to &lt;code&gt;'/usr/local/lib'&lt;/code&gt;, which will make sure that we won't conflict with the original &lt;code&gt;libreadline&lt;/code&gt; in &lt;code&gt;'/usr/lib'&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Finally, make Ruby!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# cd $LFS/src&lt;br /&gt;Tigershark:/lfs/src root# curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz &amp;gt; ruby-1.9.1-p243.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# tar -zxvf ruby-1.9.1-p243.tar.gz&lt;br /&gt;Tigershark:/lfs/src root# cd ruby-1.9.1-p243&lt;br /&gt;Tigershark:/lfs/src/ruby-1.9.1-p243 root# ./configure --prefix=$LFS LDFLAGS=-L/usr/local/lib&lt;br /&gt;Tigershark:/lfs/src/ruby-1.9.1-p243 root# make &amp;&amp; make install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note the additional parameter &lt;code&gt;'LDFLAGS=-L/usr/local/lib'&lt;/code&gt; that we pass to &lt;code&gt;'./configure'&lt;/code&gt;. This is required so that when ruby gets compiled, it'll first search &lt;code&gt;'/usr/local/lib'&lt;/code&gt; for it's library dependencies before looking at its system default paths. Because we have our new &lt;code&gt;'libreadline'&lt;/code&gt; installed, this makes sure that Ruby is compiled with our newer library instead of the system one. &lt;br /&gt;&lt;br /&gt;Congratulations! Once you've reached here, you have your new shiny Ruby 1.9 interpreter to play with! To check:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Tigershark:/ root# which ruby&lt;br /&gt;/lfs/bin/ruby&lt;br /&gt;Tigershark:/ root# ruby --version&lt;br /&gt;ruby 1.9.1p243 (2009-07-16 revision 24175) [powerpc-darwin8.11.0]&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-4092424210767523797?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=TWB3A5Evl1c:t7MbNoqHvn8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=TWB3A5Evl1c:t7MbNoqHvn8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=TWB3A5Evl1c:t7MbNoqHvn8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=TWB3A5Evl1c:t7MbNoqHvn8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=TWB3A5Evl1c:t7MbNoqHvn8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=TWB3A5Evl1c:t7MbNoqHvn8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=TWB3A5Evl1c:t7MbNoqHvn8:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=TWB3A5Evl1c:t7MbNoqHvn8:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/TWB3A5Evl1c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/4092424210767523797/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/11/compiling-ruby-19-from-scratch-for-mac.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4092424210767523797?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4092424210767523797?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/TWB3A5Evl1c/compiling-ruby-19-from-scratch-for-mac.html" title="Compiling Ruby 1.9 for Mac OSX 10.4" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/11/compiling-ruby-19-from-scratch-for-mac.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8HRXwyeSp7ImA9WxNXFE4.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1416452307747350246</id><published>2009-10-01T15:57:00.000-07:00</published><updated>2009-10-01T15:57:14.291-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-01T15:57:14.291-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Development" /><title>Why you should Blame your Tools, sometimes.</title><content type="html">As software developers, we would all wish to have 3rd party libraries that works magically immediately after installation. While this is to be expected and holds true for popular and widely used libraries, people do tend to forget that it is still more of a rule of thumb than an iron-cast fact.&lt;br /&gt;
&lt;br /&gt;
Like the urban myth goes, "a good workman never blames his tools", this mindset is so ingrained in the software development culture, that it is always bad form to assume that bug may reside in a library rather than in your code. After all, it is more likely that you are the offending culprit, given it is less likely a widely used code base will make a mistake when compared to code just seen by you alone. But with everything statistical, there is always a chance that an outlier event can happen.&lt;br /&gt;
&lt;br /&gt;
And it did for me. &lt;br /&gt;
&lt;br /&gt;
Internally, we rely on log4cxx as our logging library, which a peculiar bug seems to only be triggered upon the termination of our application. After spending more than 2 days of debugging, the error seemed to have consistently been at the line where the logger object is being accessed. And like all true developers, I bit my lip and kept soldiering on, reading through my own code, checking the same lines over and over again, trying to see if I had missed defining a variable, or if I had forgotten to allocate memory for it. Naturally, after while of doing so, I began to start questioning my personal sanity rather than the lines of code I've written, amid this 'impossibility' that the error could actually be from the library.&lt;br /&gt;
&lt;br /&gt;
And then I popped.&lt;br /&gt;
&lt;br /&gt;
I turned over to my colleague and mentioned to him that the code kept failing on the logging line. The team had known that I've been stuck on this problem for the last day. Even as I started, I could see the mild derision on his face, "it can't be the library. Maybe gdb is not showing what actually is going on."&lt;br /&gt;
&lt;br /&gt;
So on and on the circle I went. Then someone else suggested using valgrind.&lt;br /&gt;
&lt;br /&gt;
Since I was running out of options, I didn't see any harm trying. At most I'll waste an hour more to the day I've already wasted, anyway.&lt;br /&gt;
&lt;br /&gt;
Valgrind didn't really show anything more different to what gdb was showing. Basically saying the same thing - that log4cxx is accessing an invalid memory location. Given I wasn't an expert on valgrind, I got someone else to come over and discussed what we were seeing on the stack trace.&lt;br /&gt;
&lt;br /&gt;
No luck still.&lt;br /&gt;
&lt;br /&gt;
It's gone past the point of frustration, into the point of desperation that I decided to just fucking comment out the offending statement and see if the problem goes away.&lt;br /&gt;
&lt;br /&gt;
After recompling and re-running the application 30+ times without the bug re-surfacing, I was very certain to point at the logger library being the culprit. But of course if I did, I couldn't definitively prove it, and worse, I had no workaround; the entire code base is reliant on it for logging, and to take it away would mean a major re-engineering exercise.&lt;br /&gt;
&lt;br /&gt;
Sometimes talking to others help. Sometimes they offer a difference in perspective, and other times, they may have caught something you hadn't.&lt;br /&gt;
&lt;br /&gt;
Given that we had multiple threads that were still operating when a shutdown signal is received, I thought maybe it'll be worth trying to stop those threads safely before the termination signal is processed - since it's likely that some portions or memory may be freed while the threads are still utilising them. But I was just shooting wildly - it was a very long shot, given how the threading interactions were designed, it was difficult to believe that it could have been the problem. But trying something is better than doing nothing.&lt;br /&gt;
&lt;br /&gt;
So I sat down with another colleague of mine, and talked him through what I wanted to do, and invariably the discussion lead to another where we talked about the valgrind backtrace that I had generated, which showed memory destruction caused by exit(). After a bit of theorising back and forth about the behaviour, and on how I'd would write a quick hack to test my hypothesis, my colleague decided to do a ubiquity search on '&lt;a href="http://www.google.ie/search?q=log4cxx+exit+crash"&gt;log4cxx exit crash&lt;/a&gt;^H^H^H^H', which then our eyes popped when we saw the preview result before it changed into something else that he was meaning to type.&lt;br /&gt;
&lt;br /&gt;
"Go back again", I said excitedly. He was already as excited as I was, so there wasn't really the need for any prompting.&lt;br /&gt;
&lt;br /&gt;
It turns out that there is a known problem in log4cxx found months ago, and someone had even posted a patch on it already. But here's the thing about software: unless you are willing to roll your own fixes, be prepared to wait for a long time before someone eventually fixes it. And even if someone did fix it, the upstream maintainer will still take a while before committing it into the main trunk. Or even worse, he may just choose to ignore it. And yes it does happen - ask &lt;a href="http://en.wikipedia.org/wiki/Ulrich_Drepper"&gt;Ulrich Drepper&lt;/a&gt;. :P&lt;br /&gt;
&lt;br /&gt;
On how to fix it, and package it up nicely for use, I'll write about that in a later post, for now I want to share an invaluable lesson when it comes to software development, which also equally applies in life: while established conventions are more often right than wrong, it never hurts to question them just in case they aren't. It may not be okay to blame your tools all the time, but it sometimes worth to know when to call a shoddy spade when you see one.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1416452307747350246?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=hXwkrO-kipc:au0tkDEkGdM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=hXwkrO-kipc:au0tkDEkGdM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=hXwkrO-kipc:au0tkDEkGdM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=hXwkrO-kipc:au0tkDEkGdM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=hXwkrO-kipc:au0tkDEkGdM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=hXwkrO-kipc:au0tkDEkGdM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=hXwkrO-kipc:au0tkDEkGdM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=hXwkrO-kipc:au0tkDEkGdM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/hXwkrO-kipc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1416452307747350246/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/10/why-you-should-blame-your-tools.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1416452307747350246?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1416452307747350246?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/hXwkrO-kipc/why-you-should-blame-your-tools.html" title="Why you should Blame your Tools, sometimes." /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/10/why-you-should-blame-your-tools.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMAQ3k5cCp7ImA9WxNQGU0.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-5811944451309347985</id><published>2009-09-22T15:14:00.000-07:00</published><updated>2009-09-25T11:47:22.728-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-25T11:47:22.728-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="Gdb" /><title>How to build a Debian Package for GDB</title><content type="html">I've resisted titling this post as 'building an Ubuntu package' even though I'm building it for Ubuntu - technically it's more proper to call it a Debian package given its lineage. Nevertheless the mechanism behind building your own packages is pretty much the same for the two.&lt;br /&gt;&lt;br /&gt;I'll use GDB as an example of how to build your own package - for a good reason, firstly because the stock version of GDB that is shipped with Ubuntu is &lt;span style="font-weight: bold;"&gt;terribly broken&lt;/span&gt;. Here's what I mean:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;% gdb --args java&lt;br /&gt;GNU gdb 6.8-debian&lt;br /&gt;Copyright (C) 2008 Free Software Foundation, Inc.&lt;br /&gt;License GPLv3+: GNU GPL version 3 or later &lt;span style="text-decoration: underline;"&gt;&amp;lt;&lt;/span&gt;&lt;a href="http://gnu.org/licenses/gpl.html"&gt;http://gnu.org/licenses/gpl.html&lt;/a&gt;&amp;gt;&lt;br /&gt;This is free software: you are free to change and redistribute it.&lt;br /&gt;There is NO WARRANTY, to the extent permitted by law.  Type "show copying"&lt;br /&gt;and "show warranty" for details.&lt;br /&gt;This GDB was configured as "i486-linux-gnu"...&lt;br /&gt;(no debugging symbols found)&lt;br /&gt;(gdb) r&lt;br /&gt;Starting program: /usr/bin/java Test&lt;br /&gt;(no debugging symbols found)&lt;br /&gt;(no debugging symbols found)&lt;br /&gt;(no debugging symbols found)&lt;br /&gt;(no debugging symbols found)&lt;br /&gt;[Thread debugging using libthread_db enabled]&lt;br /&gt;[New process 16487]&lt;br /&gt;Executing new program: /usr/lib/jvm/java-6-openjdk/jre/bin/java&lt;br /&gt;warning: Cannot initialize thread debugging library: generic error&lt;br /&gt;warning: Cannot initialize thread debugging library: generic error&lt;br /&gt;warning: Cannot initialize thread debugging library: generic error&lt;br /&gt;warning: Cannot initialize thread debugging library: generic error&lt;br /&gt;[New process 16487]&lt;br /&gt;[Thread debugging using libthread_db enabled]&lt;br /&gt;Segmentation fault&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The stock build of GDB doesn't handle multi-threaded applications properly, among other minor issue like not setting the path to point to the correct debug library paths, which makes it unusable for serious debugging tasks.&lt;br /&gt;&lt;br /&gt;Secondly, &lt;a href="http://blog.vinceliu.com/2009/09/gdb-70-is-out.html"&gt;GDB 7.0 has reversible debugging&lt;/a&gt;, which makes it doubly tempting to roll my own. Finally, GDB has minimal external and library dependencies, which is an easy example to build a package without going into the complexity of having to generate a &lt;code&gt;chroot&lt;/code&gt;ed environment.&lt;br /&gt;&lt;br /&gt;But why not just do the typical &lt;code&gt;'configure &amp;amp;&amp;amp; make install'&lt;/code&gt; combination?&lt;br /&gt;&lt;br /&gt;The drawback in doing so, is that the process is &lt;span style="font-style: italic;"&gt;one-way&lt;/span&gt;: once you've installed it like that, there is no easy way of uninstalling it, short of remembering the list of what's being installed and removing them manually. Do-able? Sure, but certainly cumbersome. The neater way to do this is to create a package and have the package manager deal with installation/uninstallation for you.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Building GDB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We need to perform the usual compiling and installing steps like we normally do; the only difference is that we want the installer to place all the resultant files into a separate directory for generating a package. Doing this is straightforward using the prefix flag provided by &lt;code&gt;configure&lt;/code&gt;. The steps are commented and reproduced below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# Assuming that you're in the current source directory /home/user/gdb-sources&lt;br /&gt;% mkdir -p custom-gdb-7.0-amd64/usr/&lt;br /&gt;% configure --prefix=/home/user/gdb-sources/custom-gdb-7.0-amd64/&lt;br /&gt;% make &amp;amp;&amp;amp; make install&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There are dependencies that GDB will need in order to compile properly (things like bison, lex as far as I remember), but I'll assume that you know how to resolve these dependencies yourself. Otherwise, the source should finish compiling and installing to the destination &lt;code&gt;/home/user/gdb-sources/custom-gdb-7.0-amd64/&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Generating the Control file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In order to generate a package, a Debian control file is required, which contains the information that the 'dpkg-deb' package generator will need. Here's how we write one:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;% mkdir custom-gdb-7.0-amd64/DEBIAN&lt;br /&gt;% cat &gt; custom-gdb-7.0-amd64/DEBIAN/control&lt;br /&gt;Package: customgdb&lt;br /&gt;Version: 7.0&lt;br /&gt;Section: base&lt;br /&gt;Priority: optional&lt;br /&gt;Architecture: amd64&lt;br /&gt;Depends: lex, bison&lt;br /&gt;Maintainer: Vincent Liu &lt;blog@vinceliu.com&gt;&amp;lt;blog@vinceliu.com&amp;gt;&lt;br /&gt;Description: Custom build of GDB&lt;br /&gt;This version of GDB provides cutting edge&lt;br /&gt;capabilities that the stock package does not provide.&lt;br /&gt;^D&lt;br /&gt;%&lt;br /&gt;# The control-D symbol above is to indicate the&lt;br /&gt;# file termination character&lt;br /&gt;&lt;/blog@vinceliu.com&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There are plenty of details I've omitted here, and you will have to read more to understand and tune your own control file configuration. Here's the &lt;a href="http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/"&gt;tutorial&lt;/a&gt; I referenced, and the &lt;a href="http://www.debian.org/doc/debian-policy/ch-controlfields.html"&gt;Debian manual&lt;/a&gt; to help you figure out the details of each control field.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Generating and Installing the Package&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once you've got the control file generated, building the package is just a single &lt;code&gt;dpkg-deb&lt;/code&gt; away:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;% fakeroot dpkg-deb --build custom-gdb-7.0-amd64&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You will get a resulting &lt;code&gt;custom-gdb-7.0-amd64.deb&lt;/code&gt; package generated for installation. To install it, you'll have to remove the existing GDB package, as it conflicts with your new installation. Do the following:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# remove the original gdb&lt;br /&gt;% dpkg -r gdb&lt;br /&gt;&lt;br /&gt;# install the new gdb&lt;br /&gt;% dpkg -i custom-gdb-7.0-amd64.deb&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you ever needed to revert back to the stock versions of GDB, you can now easily remove your custom version by &lt;code&gt;dpkg -r customgdb&lt;/code&gt;, and reinstalling it using &lt;code&gt;apt-get&lt;/code&gt; or your own favourite package manager.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-5811944451309347985?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UhPUtPA_yXk:GtRxpUBkR1M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UhPUtPA_yXk:GtRxpUBkR1M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UhPUtPA_yXk:GtRxpUBkR1M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UhPUtPA_yXk:GtRxpUBkR1M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UhPUtPA_yXk:GtRxpUBkR1M:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UhPUtPA_yXk:GtRxpUBkR1M:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UhPUtPA_yXk:GtRxpUBkR1M:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UhPUtPA_yXk:GtRxpUBkR1M:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/UhPUtPA_yXk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/5811944451309347985/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/09/how-to-build-debian-package-for-gdb.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/5811944451309347985?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/5811944451309347985?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/UhPUtPA_yXk/how-to-build-debian-package-for-gdb.html" title="How to build a Debian Package for GDB" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/09/how-to-build-debian-package-for-gdb.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08NRXk-fCp7ImA9WxNUFUU.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-2712905179839379877</id><published>2009-09-17T15:13:00.000-07:00</published><updated>2009-11-07T01:24:54.754-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-07T01:24:54.754-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Gdb" /><title>GDB 7.0 Is Out!</title><content type="html">Read the announcement &lt;a href="http://sourceware.org/ml/gdb-announce/2009/msg00000.html"&gt;here&lt;/a&gt;. It's actually the pre-release version, nevertheless it's quite stable.&lt;br /&gt;
&lt;br /&gt;
What makes this version interesting? It's got &lt;a href="http://www.gnu.org/software/gdb/news/reversible.html"&gt;reversible debugging&lt;/a&gt;, which means that it's the first time you can actually make your code go &lt;span style="font-style: italic;"&gt;back in time&lt;/span&gt; to find out what it did before it crashed.&lt;br /&gt;
&lt;br /&gt;
I've tried the new commands, but I'm haven't been successful in stepping backwards still - well more experimenting ahead!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update:&lt;/b&gt; The tutorial is available at &lt;br /&gt;
&lt;a href="http://www.sourceware.org/gdb/wiki/ProcessRecord/Tutorial"&gt;http://www.sourceware.org/gdb/wiki/ProcessRecord/Tutorial&lt;/a&gt;. (Thanks to Michael!)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-2712905179839379877?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=stkOSQLihJk:ddL4wtnLLxA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=stkOSQLihJk:ddL4wtnLLxA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=stkOSQLihJk:ddL4wtnLLxA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=stkOSQLihJk:ddL4wtnLLxA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=stkOSQLihJk:ddL4wtnLLxA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=stkOSQLihJk:ddL4wtnLLxA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=stkOSQLihJk:ddL4wtnLLxA:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=stkOSQLihJk:ddL4wtnLLxA:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/stkOSQLihJk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/2712905179839379877/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/09/gdb-70-is-out.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2712905179839379877?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2712905179839379877?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/stkOSQLihJk/gdb-70-is-out.html" title="GDB 7.0 Is Out!" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/09/gdb-70-is-out.html</feedburner:origLink></entry><entry><title type="text">Links for 2009-09-17 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/nN28rshjaCs/vincentliu79" /><updated>2009-09-18T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-09-17</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.appscout.com/2009/09/bing_snags_10-percent_of_us_se.php"&gt;Bing Snags 10-Percent of U.S. Search - AppScout&lt;/a&gt;&lt;br/&gt;
People may hate Microsoft, but I actually admire the company for its tenacious competitive spirit. Don&amp;#039;t bash me, my Microsoft hating lemmings, erm I meant friends - learn to recognise a good thing when you see one ;)&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/nN28rshjaCs" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-09-17</feedburner:origLink></entry><entry><title type="text">Links for 2009-09-12 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/NALkbee_lx0/vincentliu79" /><updated>2009-09-13T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-09-12</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blogs.law.harvard.edu/philg/2009/09/12/obama-will-not-rest/"&gt;Obama will not rest&amp;hellip;&lt;/a&gt;&lt;br/&gt;
… until Americans are paying more for a set of tires than Indians pay for an entire car. Is America foolhardy enough to engage in a trade war with China?&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/NALkbee_lx0" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-09-12</feedburner:origLink></entry><entry><title type="text">Links for 2009-08-31 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/6L6JPIUiGyA/vincentliu79" /><updated>2009-09-01T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-08-31</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://lbrandy.com/blog/2009/08/the-programmers-wife/"&gt;The Programmer's Wife&lt;/a&gt;&lt;br/&gt;
Be weary the next time some woman comes up to you and starts sprouting about Linux, Python, C++ and The Penguin. ;)&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/6L6JPIUiGyA" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-08-31</feedburner:origLink></entry><entry><title type="text">Links for 2009-08-23 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/S86yRFFv3k8/vincentliu79" /><updated>2009-08-24T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-08-23</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.rollingstone.com/news/story/29787673/the_boy_who_heard_too_much/print"&gt;The Boy Who Heard Too Much&lt;/a&gt;&lt;br/&gt;
He was a 14-year-old blind kid, angry and alone. Then he discovered that he possessed a strange and fearsome superpower — one that put him in the cross hairs of the FBI.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/S86yRFFv3k8" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-08-23</feedburner:origLink></entry><entry><title type="text">Links for 2009-08-20 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/CUDOIOTVElc/vincentliu79" /><updated>2009-08-21T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-08-20</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.cisco.com/web/about/security/intelligence/bots.html"&gt;Infiltrating a Botnet - Cisco Systems&lt;/a&gt;&lt;br/&gt;
Fascinating read into the mind of a botmaster.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/CUDOIOTVElc" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-08-20</feedburner:origLink></entry><entry><title type="text">Links for 2009-08-19 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/jfbJZG646Vw/vincentliu79" /><updated>2009-08-20T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-08-19</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://taxidiary.blogspot.com/"&gt;A Singapore Taxi Driver's Diary&lt;/a&gt;&lt;br/&gt;
Probably the only taxi driver in this world with a PhD from Stanford and a proven track record of scientific accomplishments, I have been forced out of my research job at the height of my scientific career, and unable to find another one, for reasons I can only describe as something &amp;quot;uniquely Singapore&amp;quot;. As a result, I am driving taxi to make a living and writing these real life stories just to make the dull job a little more interesting. I hope that these stories are interesting to you too.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/jfbJZG646Vw" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-08-19</feedburner:origLink></entry><entry><title type="text">Links for 2009-08-18 [del.icio.us]</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/swfTL-yOMDY/vincentliu79" /><updated>2009-08-19T00:00:00-07:00</updated><id>http://del.icio.us/vincentliu79#2009-08-18</id><content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href="http://bash.org/?213586"&gt;Is there any way I can set the compiler in strict C++ mode, I don't want to learn C/C++ mix mode&lt;/a&gt;&lt;br/&gt;
How to become a Code-Nazi ;)&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/swfTL-yOMDY" height="1" width="1"/&gt;</content><feedburner:origLink>http://del.icio.us/vincentliu79#2009-08-18</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUMRHo_fyp7ImA9WxNTEk0.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-5151588950787752548</id><published>2009-08-13T13:52:00.000-07:00</published><updated>2009-08-13T15:58:05.447-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-13T15:58:05.447-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Development" /><category scheme="http://www.blogger.com/atom/ns#" term="Mercurial" /><title>Bug Hunting with Revision Control using Mercurial</title><content type="html">My impression through reading other software developers' blogs is that, when presented a choice of distributed revision control, there seem to be a majority preference for Git over Mercurial. This popularity does not come as surprising, since it is the brainchild of the most prominent icon of open source software today, the famed Linux kernel hacker Linus Torvalds.&lt;br /&gt;&lt;br /&gt;It feels like the Mercurial camp is a little bit unrepresented, but today's post isn't about a blow-by-blow account between the two software revision control systems; you will probably be more informed by experts out there who have better qualifications in critiquing the pros and cons among the two. More importantly, I feel these differences are mostly nitpicking to general laypeople - when the demands of our projects do not scale to a level where the performance differences are visible, &lt;span style="font-style: italic;"&gt;it really doesn't matter&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;People will have their biases, and the git-vs-mercurial battle will probably be not too different from the perennial ideological battles between the emacs-vs-&lt;a href="http://blog.vinceliu.com/search/label/Vim"&gt;vim&lt;/a&gt; crowds. And obviously, you should have detected my bias in this case already :)&lt;br /&gt;&lt;br /&gt;Anyway, back to our original discussion.&lt;br /&gt;&lt;br /&gt;I have only used git briefly, and I'll not comment much on it given my limited impression. I'd agree with most people that it is a remarkable software revision control tool and leave it as that. It must strike you as curious to why I am using Mercurial then - it's largely of based on pragmatism, given I've acquired much familiarity through constant use at work. Besides, if I haven't been complaining enough to be tempted to try out git again, it must have not been that bad, right?&lt;br /&gt;&lt;br /&gt;I'll share with you the best thing I love about using these revision control tools, namely, for their amazing ability to find out where the sources of your bugs are. It's not uncommon for software to break between the revisions you've check in; and sometimes these breakages fail to be noticed until you've checked it in after a bunch of some other code, making your original error even harder to find.&lt;br /&gt;&lt;br /&gt;Well, not anymore.&lt;br /&gt;&lt;br /&gt;Mercurial has this ability called 'bisect' which allows you to toggle between revisions until you're able to zone down to the exact patch where your code first breaks. Given that most code check-ins tend to be of small increments, knowing which patch that causes the break helps you narrow down the error to a very small subset where you can focus your efforts on finding the bug.&lt;br /&gt;&lt;br /&gt;How does this work? Let me show you a real life session of how bisect works in finding an erroneous commit:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code"&gt;&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -g 1614&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -b 1671&lt;br /&gt;Testing changeset 1666:ee86f6717c42 (57 changesets remaining, ~5 tests)&lt;br /&gt;36 files updated, 0 files merged, 8 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -b 1666&lt;br /&gt;Testing changeset 1630:6e221cda7176 (28 changesets remaining, ~4 tests)&lt;br /&gt;28 files updated, 0 files merged, 2 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -b 1630&lt;br /&gt;Testing changeset 1623:f7b12d17a79b (14 changesets remaining, ~3 tests)&lt;br /&gt;10 files updated, 0 files merged, 0 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -b 1623&lt;br /&gt;Testing changeset 1618:ac9135ec8e99 (9 changesets remaining, ~3 tests)&lt;br /&gt;17 files updated, 0 files merged, 0 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -g 1618&lt;br /&gt;Testing changeset 1620:032f83fb6b8c (5 changesets remaining, ~2 tests)&lt;br /&gt;26 files updated, 0 files merged, 1 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -g 1620&lt;br /&gt;Testing changeset 1621:1d8191199d0d (3 changesets remaining, ~1 tests)&lt;br /&gt;5 files updated, 0 files merged, 0 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -g 1621&lt;br /&gt;Testing changeset 1622:65b4f19e8941 (2 changesets remaining, ~1 tests)&lt;br /&gt;9 files updated, 0 files merged, 0 files removed, 0 files unresolved&lt;br /&gt;vincentliu@vm1:~/replicode$ hg bisect -g 1622&lt;br /&gt;The first bad revision is:&lt;br /&gt;changeset:   1623:f7b12d17a79b&lt;br /&gt;parent:      1618:ac9135ec8e99&lt;br /&gt;parent:      1622:65b4f19e8941&lt;br /&gt;user:        Anonymous Person &amp;lt;xxx@xxx.xxx&amp;gt;&lt;br /&gt;date:        Fri Aug 07 14:13:56 2009 +0100&lt;br /&gt;summary:     Automated merge with http://xxx&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Some of the output has been slightly modified to protect the innocent[&lt;a href="http://blog.vinceliu.com/2009/08/bug-hunting-with-revision-control-using.html#sub1"&gt;1&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;The first two bisect commands, with the &lt;code&gt;-g&lt;/code&gt; and &lt;code&gt;-b&lt;/code&gt; arguments indicate the two changesets that you know for certain which are good and bad respectively. With the boundaries set, Mercurial goes on its way and starts checking out changesets that are committed in between.&lt;br /&gt;&lt;br /&gt;For each checked out changeset, you'll have the opportunity of testing it out; once you are done, you can indicate whether if the changeset is good or bad by using the same commands with the checked out changeset number. Mercurial then checks out the next changeset for you to test.&lt;br /&gt;&lt;br /&gt;Here's where there is some serious voodoo at work; notice that I had 57 changesets in between. It's going to be a nightmare if I had to test out every single one of them - instead, Mercurial tries to subdivide through the changeset smartly to isolate the problem (hence the term 'bisect') and gives you a general estimate of how many more tests you have to do before Mercurial can definitively point out the problematic changeset. In my case, it took me 8 tries. Pretty impressive eh?&lt;br /&gt;&lt;br /&gt;I certainly have my few criticisms about Mercurial, like my initial incredulity of how the developers came up with the command of &lt;code&gt;hg&lt;/code&gt; when their software system is called 'Mercurial'; but past those kinks and initial gag-reflexes, I have to admit that my experiences using has largely remained satisfactory. And if you're one of those who are still at two minds about using a distributed revision control system, I urge you to give it a try. You just might like it!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;[&lt;a name="sub1"&gt;1&lt;/a&gt;] It's not nice to put the names of the people I work with on my blog without their consent.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-5151588950787752548?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=vweIV8WLu7U:mgFYeeHzEIE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=vweIV8WLu7U:mgFYeeHzEIE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=vweIV8WLu7U:mgFYeeHzEIE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=vweIV8WLu7U:mgFYeeHzEIE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=vweIV8WLu7U:mgFYeeHzEIE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=vweIV8WLu7U:mgFYeeHzEIE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=vweIV8WLu7U:mgFYeeHzEIE:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=vweIV8WLu7U:mgFYeeHzEIE:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/vweIV8WLu7U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/5151588950787752548/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/08/bug-hunting-with-revision-control-using.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/5151588950787752548?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/5151588950787752548?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/vweIV8WLu7U/bug-hunting-with-revision-control-using.html" title="Bug Hunting with Revision Control using Mercurial" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/08/bug-hunting-with-revision-control-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0AGRHk4eSp7ImA9WxJaEkQ.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-4502754948766199967</id><published>2009-08-03T04:11:00.000-07:00</published><updated>2009-08-03T04:42:05.731-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-03T04:42:05.731-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Humour" /><title>The Recession is Over</title><content type="html">I'm no economist and I certainly did no research. I have neither volumes of literature, nor data or statistics to back me up. But rather than listening to the talking heads on CNBC and Bloomsberg, why not try one of my observations for a change?&lt;br /&gt;&lt;br /&gt;I got reminded that we are in a recession by a French flutist at a gig I attended last night. If news has reached as far as to a band of travelling hippie-musicians, surely we must have lived through the worst of it all already?&lt;br /&gt;&lt;br /&gt;You know the adage that it is time to get out of the markets when cab drivers are tipping you on stocks? Well, maybe this is just the same, only in reverse.&lt;br /&gt;&lt;br /&gt;Eat your heart out &lt;a href="http://www.rgemonitor.com/"&gt;Roubini&lt;/a&gt;, it's time for a celebration, Champagne anyone?&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-4502754948766199967?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=I3G4gOMuwkk:HGlBGTrjdOQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=I3G4gOMuwkk:HGlBGTrjdOQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=I3G4gOMuwkk:HGlBGTrjdOQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=I3G4gOMuwkk:HGlBGTrjdOQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=I3G4gOMuwkk:HGlBGTrjdOQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=I3G4gOMuwkk:HGlBGTrjdOQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=I3G4gOMuwkk:HGlBGTrjdOQ:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=I3G4gOMuwkk:HGlBGTrjdOQ:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/I3G4gOMuwkk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/4502754948766199967/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/08/recession-is-over.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4502754948766199967?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4502754948766199967?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/I3G4gOMuwkk/recession-is-over.html" title="The Recession is Over" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/08/recession-is-over.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AARHg8fyp7ImA9WxJbE0g.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-321272178163245766</id><published>2009-07-22T15:14:00.000-07:00</published><updated>2009-07-23T06:29:05.677-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-23T06:29:05.677-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Java is not the JVM</title><content type="html">For many IT people, it sounds funny to assert that the Java language has nothing to with the JVM itself. But as incredulous as it sounds, this is actually true. Let me explain, using some code as a shallow illustration how this is the case.&lt;br /&gt;&lt;br /&gt;When I was hacking at the Java bytecode level, one of the things that I do is to optimise for memory efficiency. There is a need for storing an array of booleans, and the most obvious way of saving memory is to store it at a bitwise level, by stashing 8 boolean values within a byte.&lt;br /&gt;&lt;br /&gt;Within the JVM, &lt;code&gt;booleans&lt;/code&gt; are stored as bytes (&lt;span style="font-style: italic;"&gt;executionally, they are worse&lt;/span&gt;: the VM treats &lt;code&gt;booleans&lt;/code&gt; as &lt;code&gt;int&lt;/code&gt;s!). Furthermore, in Java, there isn't a low-level means of utilising booleans as integral types like C can. If you had to write code in pure Java, at best you'll end up writing code like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;// assume z == boolean[8]&lt;br /&gt;byte b = 0;&lt;br /&gt;for ( int i=0; i &amp;lt; 8; i++ ) {&lt;br /&gt;&lt;z.length;i++) int="" j="z[0]" 1="" b=""&gt;  if  ( z[i] == true ) {&lt;br /&gt;  b |= ( 1 &lt;/z.length;i++)&gt;&amp;lt;&amp;lt;&lt;z.length;i++) int="" j="z[0]" 1="" b=""&gt; i );&lt;br /&gt;}&lt;br /&gt;} &lt;/z.length;i++)&gt;&lt;/pre&gt;&lt;br /&gt;Unlike C, the code is clunky, as you are having to perform a conditional check on a boolean, before you can perform bitwise operations on the values, because Java considers booleans as a non-integral type. How annoying!&lt;br /&gt;&lt;br /&gt;But this constrain only affects the Java language - the same rules do not apply when it comes to the JVM. On the VM, it is perfectly legit for you to express code like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;// assume z == boolean[8]&lt;br /&gt;byte b = 0;&lt;br /&gt;for ( int i=0; i &amp;lt; 8; i++ ) {&lt;br /&gt;&lt;z.length;i++) int="" j="z[0]" 1="" b=""&gt;  b |= z[i] &amp;lt;&amp;lt; i;&lt;br /&gt;} &lt;/z.length;i++)&gt;&lt;/pre&gt;&lt;z.length;i++) b=""&gt;&lt;br /&gt;However, just about any Java compiler disallows this code to compile - the operations on the boolean violates type-safety. But don't blame the compilers, they are just conforming to the language specifications. But since the JVM has nothing to do with the Java language, there is nothing illegal in doing so outside the Java language, let say by using bytecode assembly. Here's an equivalent, using jasmin assembly code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;.source BooleanToByte.j&lt;br /&gt;.class BooleanToByte&lt;br /&gt;.super java/lang/Object&lt;br /&gt;&lt;br /&gt;&lt;init&gt;&lt;init&gt;.method public static main([Ljava/lang/String;)V&lt;br /&gt;.limit stack 4&lt;br /&gt;.limit locals 3&lt;br /&gt;&lt;br /&gt;iconst_0&lt;br /&gt;istore_1      ; byte b = 0;&lt;br /&gt;&lt;br /&gt;iconst_0&lt;br /&gt;istore_2      ; int i = 0;&lt;br /&gt;&lt;br /&gt;LOOP:&lt;br /&gt;&lt;br /&gt;iload_2&lt;br /&gt;bipush 8&lt;br /&gt;if_icmpge EXIT_LOOP:       ; if i&gt;=z.length exit loop&lt;br /&gt;&lt;br /&gt;; here's the magic code that allows you to do direct&lt;br /&gt;; bitwise &lt;/init&gt;&lt;/init&gt;b |= z[i] &lt;&lt; b=""&gt;&lt;init&gt;&lt;init&gt;&lt;br /&gt;iload_1&lt;br /&gt;aload_0&lt;br /&gt;iload_2&lt;br /&gt;baload&lt;br /&gt;iload_2&lt;br /&gt;ishl&lt;br /&gt;ior&lt;br /&gt;istore_1&lt;br /&gt;&lt;br /&gt;iinc 2 1&lt;br /&gt;goto LOOP:&lt;br /&gt;&lt;br /&gt;LOOP_EXIT:&lt;br /&gt;&lt;br /&gt;return&lt;br /&gt;&lt;br /&gt;.end method&lt;br /&gt;&lt;/init&gt;&lt;/init&gt;&lt;/pre&gt;&lt;br /&gt;The jasmin code will probably assemble, but don't expect the JVM to execute it; it serves only as an example, and lacks a few things (I'm missing the constructor block and other nitty gritty little things that's needed to satisfy the bytecode verifier). It is but a case study to separate the JVM from the Java language as people typically assume.&lt;br /&gt;&lt;br /&gt;There has been a number of other languages that has since mushroomed which relies on the JVM as its core; these languages include Groovy, Scala, Jython and JRuby, many of which are rather interesting, although they are more of a curiosity at this stage - I've yet to see any of these implementations deployed in a production environment, although I don't say that as a criticism of any of these languages. In fact, I am actually quite impressed with the &lt;a href="http://www.jruby.org/"&gt;JRuby&lt;/a&gt;, and I recommend you give it a try. It's very faithful to the actual Ruby implementation and allows you to use Java directly. Good fun, I'd say, especially when it combines the expressive of the former with the features of the latter. It's quite impressive that the JVM has been able to be so versatile in allowing other languages to plug into it directly.&lt;br /&gt;&lt;/z.length;i++)&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-321272178163245766?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=GiF27H-_Zpo:4sAGkNL5fXI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=GiF27H-_Zpo:4sAGkNL5fXI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=GiF27H-_Zpo:4sAGkNL5fXI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=GiF27H-_Zpo:4sAGkNL5fXI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=GiF27H-_Zpo:4sAGkNL5fXI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=GiF27H-_Zpo:4sAGkNL5fXI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=GiF27H-_Zpo:4sAGkNL5fXI:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=GiF27H-_Zpo:4sAGkNL5fXI:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/GiF27H-_Zpo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/321272178163245766/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/07/java-is-not-jvm.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/321272178163245766?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/321272178163245766?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/GiF27H-_Zpo/java-is-not-jvm.html" title="Java is not the JVM" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/07/java-is-not-jvm.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYAQ387fCp7ImA9WxNTGUo.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-3730402457646178256</id><published>2009-07-22T12:47:00.000-07:00</published><updated>2009-08-22T14:55:42.104-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-22T14:55:42.104-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Development" /><category scheme="http://www.blogger.com/atom/ns#" term="Gdb" /><title>GDB: Relaying Trapped OS Signals</title><content type="html">By chance, I have managed to land myself in a situation where the bug occurs only at a signal handler. In my situation, this means that it happens only when I try to kill the program using a &lt;code&gt;SIGINT&lt;/code&gt;, or more commonly known as the '&lt;code&gt;ctrl-c&lt;/code&gt;' keystroke.&lt;br /&gt;&lt;br /&gt;GDB usually traps this signal, and other signals such as &lt;code&gt;SIGSEGV&lt;/code&gt; (Segmentation Fault), so that you can trace buggy behaviour that is causing your application to fail. But once in a while, the error may occur after the signal is sent, when the code failure resides within the signal handler.&lt;br /&gt;&lt;br /&gt;However the default behaviour of GDB is to trap these signals and subsequently consume them, in effect preventing the bug from occurring. To prevent unwanted behaviour in rare cases such as mine, you need to issue the following command:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(gdb) handle SIGINT pass&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Given that GDB utilises this signal internally, it will ask you for a confirmation to change it. Say '&lt;code&gt;y&lt;/code&gt;' to it, and GDB will correspondingly pass the signal to the application after trapping, which will give you a chance to debug the handler code that is causing the bug.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-3730402457646178256?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=uYACHmNWjqU:DyzHlXg8Fg0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=uYACHmNWjqU:DyzHlXg8Fg0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=uYACHmNWjqU:DyzHlXg8Fg0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=uYACHmNWjqU:DyzHlXg8Fg0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=uYACHmNWjqU:DyzHlXg8Fg0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=uYACHmNWjqU:DyzHlXg8Fg0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=uYACHmNWjqU:DyzHlXg8Fg0:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=uYACHmNWjqU:DyzHlXg8Fg0:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/uYACHmNWjqU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/3730402457646178256/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/07/gdb-relaying-trapped-os-signals.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3730402457646178256?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3730402457646178256?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/uYACHmNWjqU/gdb-relaying-trapped-os-signals.html" title="GDB: Relaying Trapped OS Signals" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/07/gdb-relaying-trapped-os-signals.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUAR385fSp7ImA9WxNTGUo.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1741433672376369247</id><published>2009-07-19T03:14:00.000-07:00</published><updated>2009-08-22T14:57:26.125-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-22T14:57:26.125-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Software Development" /><category scheme="http://www.blogger.com/atom/ns#" term="Gdb" /><title>GDB's Conditional Breakpoints</title><content type="html">&lt;span style="font-weight: bold;"&gt;Conditional Breakpoints for Scalar Types&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let's assume that you, the brilliant hacker, has coded up some really uber-cool stuffs, like this piece of code below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;1: for ( int i = 0; i &amp;lt; gazillion; i++ ) {&lt;br /&gt;2:   doSlightlyBuggyButUberCoolStuffs(i)&lt;br /&gt;3: }&lt;br /&gt;4:&lt;br /&gt;5: void doSlightlyBuggyButUberCoolStuffs(int i) {&lt;br /&gt;6:   // your code here that needs some&lt;br /&gt;7:   // fixing before it becomes uber-cool&lt;br /&gt;8: }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It is doing all the cool stuffs as intended, but somehow something always goes wrong when the code executes up to 2147483648, which is kind of puzzling.&lt;br /&gt;&lt;br /&gt;So what to do?&lt;br /&gt;&lt;br /&gt;You may be tempted to breakpoint at line 5, at the start of the &lt;code&gt;doSlightlyBuggyButUberCoolStuffs()&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(gdb) br doSlightlyBuggyButUberCoolStuffs&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And &lt;code&gt;gdb&lt;/code&gt; dutifully does what it's told; every single time &lt;code&gt;doSlightlyBuggyButUberCoolStuffs()&lt;/code&gt; gets executed, it stops and waits for you to act on it:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Breakpoint 1, doBuggyButUberCoolStuffs (i=1) at test.cpp:6&lt;br /&gt;6:        // start of your uber-cool code&lt;br /&gt;(gdb) c&lt;br /&gt;&lt;br /&gt;Breakpoint 1, doBuggyButUberCoolStuffs (i=2) at test.cpp:6&lt;br /&gt;6:        // start of your uber-cool code&lt;br /&gt;(gdb) c&lt;br /&gt;&lt;br /&gt;.....&lt;br /&gt;&lt;br /&gt;Breakpoint 1, doBuggyButUberCoolStuffs (i=100) at test.cpp:6&lt;br /&gt;6:        // start of your uber-cool code&lt;br /&gt;(gdb) c&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After 100 iterations, you think you've had enough! So it's time to do it the smart way, by setting a conditional:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(gdb) br test.cpp:2&lt;br /&gt;Breakpoint 1 at 0x1234: file test.cpp, line 2.&lt;br /&gt;(gdb) cond 1 i==2147483648&lt;br /&gt;(gdb) run&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After the breakpoint is set, gdb only notifies you when the loop is at its 2147483648th iteration:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Breakpoint 1 at 0x5678: file test.cpp:2&lt;br /&gt;2:   doBuggyButUberCoolStuffs(i)&lt;br /&gt;(gdb) s&lt;br /&gt;6:         // start of your uber-cool code&lt;br /&gt;(gdb) p i&lt;br /&gt;$1 = 2147483648&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Jackpot! You're now at the 2147483648th iteration! And very soon after, you found the offending piece of code, caused by a numerical overflow of a signed integer. Another bug trampled, and peace returns to your realm once more.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conditional Breakpoints for char* Strings&lt;/span&gt;&lt;br /&gt;But very soon after, you run into another irritating problem which is happening within another section of your uber-cool code. This time, the conditional depends on parsing a huge portion of text that comes from,  &lt;span style="font-style: italic;"&gt;um...&lt;/span&gt;, &lt;code&gt;/dev/random&lt;/code&gt; :P&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;1: while ( true ) {&lt;br /&gt;2:   char* c = getStringFromDevRandom();&lt;br /&gt;3:   launchNuclearMissileIfCodeMatch(c);&lt;br /&gt;4:}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Somehow, you are absolutely convinced that &lt;code&gt;/dev/random&lt;/code&gt; will eventually provide correct codes to launch the nuclear missile, but given that &lt;code&gt;launchNuclearMissileIfCodeMatch()&lt;/code&gt; is a really top-secret and highly obfuscated code residing in an external library called &lt;code&gt;libtopsecret.so&lt;/code&gt;, it isn't such a good idea to debug into the call unless you want the &lt;a href="http://www.nsa.gov/"&gt;NSA&lt;/a&gt; bursting through your front doors...&lt;br /&gt;&lt;br /&gt;But since you &lt;span style="font-style: italic;"&gt;do know the launch code&lt;/span&gt; (it's one of &lt;span style="font-style: italic;"&gt;those&lt;/span&gt; things that you'll have to kill your friends if you ever told them), you can perform a conditional check on the string, and breakpoint at it to tell you if the secret code is ever generated by &lt;code&gt;/dev/random&lt;/code&gt; to find out if &lt;code&gt;launchNuclearMissileIfCodeMatch()&lt;/code&gt; is really a hoax:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(gdb) br test.cpp:3&lt;br /&gt;Breakpoint 1 at 0xdeadbabe: file test.cpp, line 3.&lt;br /&gt;(gdb) set $secret_code = "MyUberSecretivePassword"&lt;br /&gt;(gdb) cond 1 strcmp ( $secret_code, c ) == 0&lt;br /&gt;(gdb) run&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And then, you let your code run... &lt;span style="font-style: italic;"&gt;(!)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well, unfortunately, you get sick of sitting around and waiting for it to happen after a whole day. It seems like &lt;code&gt;/dev/random&lt;/code&gt; doesn't really generate your uber-secret nuclear launch codes as frequently as you would like to think. In the meantime, the world thanks their lucky stars that you haven't caused a nuclear winter to materialise just yet... :)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1741433672376369247?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ZdAdxmEjpJM:jc7P1M5OcKw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ZdAdxmEjpJM:jc7P1M5OcKw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ZdAdxmEjpJM:jc7P1M5OcKw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ZdAdxmEjpJM:jc7P1M5OcKw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ZdAdxmEjpJM:jc7P1M5OcKw:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ZdAdxmEjpJM:jc7P1M5OcKw:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ZdAdxmEjpJM:jc7P1M5OcKw:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ZdAdxmEjpJM:jc7P1M5OcKw:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/ZdAdxmEjpJM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1741433672376369247/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/07/gdbs-conditional-breakpoints.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1741433672376369247?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1741433672376369247?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/ZdAdxmEjpJM/gdbs-conditional-breakpoints.html" title="GDB's Conditional Breakpoints" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/07/gdbs-conditional-breakpoints.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEMR3Y-eip7ImA9WxJUE04.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1769330106941128853</id><published>2009-07-11T09:50:00.000-07:00</published><updated>2009-07-11T11:58:06.852-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-11T11:58:06.852-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Health" /><category scheme="http://www.blogger.com/atom/ns#" term="Philosophy" /><title>How to lose weight and be healthy</title><content type="html">I have little patience with people who complain about their weight problems, and for a good reason - I have a really simple way for losing weight which does not involve going on a crazy exercise binge or starving yourself silly. Sounds miraculous? Well, read on.&lt;br /&gt;&lt;br /&gt;The easy part that you already know, is to make some wise choices about your diet, exercise moderately, and be consistent at both. Yes, it is both sensible and achievable.&lt;br /&gt;&lt;br /&gt;The second part is usually what squeezes the life out of one, when I say:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"Stop eating chocolates, cake and ice-cream!"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My advice makes me sound like I'm a Nazi Dictator violating their &lt;a href="http://en.wikipedia.org/wiki/Eighth_Amendment_to_the_United_States_Constitution"&gt;8th Amendment rights&lt;/a&gt;. But no, and let me reassert this again, it is that&lt;span style="font-style: italic;"&gt; &lt;/span&gt;simple.&lt;br /&gt;&lt;br /&gt;I'm &lt;span style="font-style: italic;"&gt;deadly serious&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Chocolates, cake and Ice-cream belong to a broader category I classify as &lt;span style="font-style: italic;"&gt;'leisure food'. &lt;/span&gt;It's leisure because people eat these food for their own enjoyment, not for sustenance. This applies to all other snacks (cookies, biscuits, sweets, chips and flavoured drinks) - if that is what you are usually consuming when you're not hungry, then you shouldn't be having it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"But, but... that's impossible!"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'll tell you a story about a friend of mine. Let's call him 'Bryan'. (Oh, &lt;span style="font-style: italic;"&gt;that is your real name&lt;/span&gt;! Let's see how long before someone points you to read this entry :P) Bryan has a minor weight issue, and he once told me about this amazing story that his household fridge was like &lt;a href="http://en.wikipedia.org/wiki/Bag_of_holding"&gt;The Bag of Holding&lt;/a&gt;; each time he opens it, there will be a slice of chocolate cake or other sweet delights waiting for him. No surprises to why he isn't able to keep his hands off the sugary stuffs.&lt;br /&gt;&lt;br /&gt;Now let me tell you another story of another friend of mine. Let's call him 'Vincent'. (Oh hey, that's me!) Vincent grew up in a poor household where there's no cake awaiting for him in the fridge any time he opens it. In fact, there's nothing there for him whenever he opens it. Poor Vincent! You might even begin think that his childhood is real deprived!&lt;br /&gt;&lt;br /&gt;On the contrary, Vincent had never been hungry in his life; there is always food on the table, and the meals involve a simple serving of rice, vegetables, and either eggs, chicken, fish or other protein sources. Given the tight budget Vincent's mum had, there wasn't enough money to buy chocolates, snacks and fizzy drinks anyway. 20 years later, Vincent do not have much cravings for these &lt;span style="font-style: italic;"&gt;'leisure foods' &lt;/span&gt;. To others, he just seems to have an incredible self-control.&lt;br /&gt;&lt;br /&gt;No, this isn't a &lt;span style="font-style: italic;"&gt;tit-for-tat&lt;/span&gt; competition here, all I'm saying is that good moderate choices makes harder things easier in the long run.&lt;br /&gt;&lt;br /&gt;So what do you do if you grew up in the life of Bryan?&lt;br /&gt;&lt;br /&gt;Start small, and be consistent. &lt;span style="font-style: italic;"&gt;Consistency&lt;/span&gt; is the key, my friend. In the long run, it will get easier for you. Just don't get into the delusion of wanting instant results&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is this one other issue, like what if:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"I get hungry really easily!"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That is why you should stop eating chocolates, cake and ice-cream! And eat &lt;span style="font-style: italic;"&gt;more &lt;/span&gt;meat!&lt;br /&gt;&lt;br /&gt;Some of you might be puzzled. &lt;span style="font-style: italic;"&gt;More meat&lt;/span&gt;? Let me explain why in my own personal, anecdotal example. If you ever read food labels, you'll find that a 40g bar of Cadbury's chocolate contains 205 Calories of energy. In comparison, 125g of chicken breast contains only 133 Calories of energy!&lt;br /&gt;&lt;br /&gt;I'll answer how these number translate to in human terms. If I have more than a good portion of chicken for lunch, say 250g, I'll have consumed 266 Calories and it will keep me from being hungry till dinner. In comparison, if I had two chocolate bars for lunch, I would have consumed 410 Calories of energy &lt;span style="font-weight: bold;"&gt;AND&lt;/span&gt; I'll be hungry again 2 hours later!&lt;br /&gt;&lt;br /&gt;I'm aware that there are some scientific studies out there that supports my claim, but what's more important, is that I know &lt;span style="font-style: italic;"&gt;it works for me&lt;/span&gt;. This I want you to keep in mind. I certainly can tell that something within meat (or protein, I suspect) keeps one from feeling hungry sooner. Carbohydrates just don't do the same thing. It's no wonder some people swear by faddish regimes like the &lt;a href="http://en.wikipedia.org/wiki/Atkins_diet"&gt;Atkin's Diet&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;But I do not recommend anybody from trying funny diet plans, or simply going on diets &lt;span style="font-weight: bold;"&gt;at all&lt;/span&gt;. Firstly, if you are starving yourself, you are doing it &lt;span style="font-style: italic;"&gt;wrong. &lt;/span&gt;Because it'll never work - primal instinct will &lt;span style="font-style: italic;"&gt;always &lt;/span&gt;override any artificial discipline that you try inflicting on yourself. Secondly, diets promote deprivation, and the deprivation of essential nutrients to your body is certainly always &lt;span style="font-style: italic;"&gt;harmful&lt;/span&gt;. All I'm saying, is to cut down on unnecessary leisure food carbohydrates, and have more meat &lt;span style="font-weight: bold;"&gt;if your body reacts to hunger the same way as I do&lt;/span&gt;. In addition, do stick to what the doctors recommend with regards to healthy servings of fruits and vegetables.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Eating less is good for you&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Recently, it's been proven that caloric restriction will improve health and extend longevity. And this includes us &lt;a href="http://www.newscientist.com/article/dn17439"&gt;primates&lt;/a&gt;, and not just in &lt;a href="http://www.newscientist.com/article/dn8950-cutting-calories-may-boost-your-lifespan.html"&gt;lab mice&lt;/a&gt;. If you're too lazy to read the links, here's a visual difference between two monkeys where one is on caloric restriction and the other isn't. Guess which one is which?&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.newscientist.com/data/images/ns/cms/dn17439/dn17439-2_300.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 210px;" src="http://www.newscientist.com/data/images/ns/cms/dn17439/dn17439-2_300.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;If you're cringing in horror about how miserable the rest of your life will be starving yourself, think again. You'll be surprised how it does not involve starving. There's no contradiction, and I'll use myself as an example. For the numbers to make sense, we need to know how much Calories I need -  and there are plenty of calculators out there that will help to figure this out, Google it.&lt;br /&gt;&lt;br /&gt;Now, for a 30 year-old, 1.75m, 65kg guy, my Caloric requirement is about +/- 2500 Calories, depending on which calculators used. A 25% Caloric reduction is what they've used in the scientific studies, so that brings my figure to 1875 Calories. Now, lets calculate what I eat on a given day, which includes breakfast, lunch and dinner with no snacks.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Breakfast&lt;/span&gt;&lt;br /&gt;4 slices of bread, 68g - 200 Calories&lt;br /&gt;Nutella, 18g spread! - 98 Calories&lt;br /&gt;Tea - 2 Calories&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Lunch&lt;/span&gt;&lt;br /&gt;200g Chicken - 212 Calories&lt;br /&gt;250g Rice - 867 Calories&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Dinner&lt;/span&gt;&lt;br /&gt;300g Salmon - 447 Calories&lt;br /&gt;100g Broccoli - 35 Calories&lt;br /&gt;133g Apple - 65 Calories&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Total Calorie Count : &lt;/span&gt;1926 Calories&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;It's slightly more than 1875, but it's not too far off range. And I'm not rationing myself either - I've given generous estimates for the spreads (18g spreads to 67g of bread!), and dinner is 2 portions of Salmon (supermarkets estimate of portion sizes are ridiculous!). Give and take, that is what I normally have without having to feel hungry at all, it's quite amazing to know that I'm still within their bounds of 'Caloric Reduction'!&lt;br /&gt;&lt;br /&gt;If you've noticed, it is the carbohydrate foods that are giving an amazingly high Caloric count - look at rice at 867 Calories at 250g! And I never knew this until I looked this up myself!&lt;br /&gt;&lt;br /&gt;More chicken from now on, please!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Supersized Nations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Being fat is a peculiar problem that exists only in industralised nations. No surprises, since that  is where all the money is. Indulgence is an economic problem if you actually think about it - it only afflicts people who &lt;span style="font-style: italic;"&gt;can&lt;/span&gt; afford it. I'm just 'lucky' I grew up in a circumstance where I do not have a luxury to indulge in leisure foods, although this doesn't make the make me the model case study for solving the fat nations problem.&lt;br /&gt;&lt;br /&gt;It is really not a problem if you understand this is how capitalism works. Businesses are incentivised to create things you want, and for food companies, to create foods that are tasty, so that you'll buy them. Tasty foods means that you'll want to have more. People often cite the reasons of growing fat on the an abundance of food and the general lack of exercise in the modern world - it is &lt;span style="font-style: italic;"&gt;true&lt;/span&gt;, but it's no more correct to blame it on the companies who make tasty foods, than to attribute blame on themselves. If food companies are predatory to the addiction of your taste buds, should we go after them like we do on hard drugs?&lt;br /&gt;&lt;br /&gt;I like capitalism - it is your prerogative to see how best to spend your money, so it is within your rights to eat yourself silly, and then spend a fortune on treatment - that is a personal choice.&lt;br /&gt;&lt;br /&gt;But it irks me to see how governments are socialising these costs at the expense of sensible people - it's just one of the things in our society I like to describe as 'mad'. If it's 'too big to fail', nobody should have allowed it to grow that big in the first place. So far, governments are just plain inept at dealing with both supersized companies and supersized people.&lt;br /&gt;&lt;br /&gt;So, do not bring weight loss problems as a conversation to my dinner table. And if anybody does have the temerity to raise it, be prepared for a session of  ridicule - and if he or she takes it in good humour, maybe I'll refer them to what I have to say on this subject matter.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1769330106941128853?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=VXa0GJ23UDc:XDVzBp9phHQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=VXa0GJ23UDc:XDVzBp9phHQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=VXa0GJ23UDc:XDVzBp9phHQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=VXa0GJ23UDc:XDVzBp9phHQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=VXa0GJ23UDc:XDVzBp9phHQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=VXa0GJ23UDc:XDVzBp9phHQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=VXa0GJ23UDc:XDVzBp9phHQ:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=VXa0GJ23UDc:XDVzBp9phHQ:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/VXa0GJ23UDc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1769330106941128853/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/07/how-to-lose-weight-and-be-healthy.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1769330106941128853?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1769330106941128853?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/VXa0GJ23UDc/how-to-lose-weight-and-be-healthy.html" title="How to lose weight and be healthy" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/07/how-to-lose-weight-and-be-healthy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcMQ3c5eyp7ImA9WxJVFks.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1337885701200353649</id><published>2009-07-03T15:25:00.001-07:00</published><updated>2009-07-03T15:28:02.923-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-03T15:28:02.923-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Personal Life" /><title>Scottish Whisky</title><content type="html">&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/Sk6FggP3jjI/AAAAAAAAAOk/gnQAk8hjBlw/s1600-h/P1030132.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/Sk6FggP3jjI/AAAAAAAAAOk/gnQAk8hjBlw/s400/P1030132.JPG" alt="" id="BLOGGER_PHOTO_ID_5354363800448896562" border="0" /&gt;&lt;/a&gt;Feels like you've drunk a cigar.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1337885701200353649?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=990ugq3AXRs:S1UA27ZjUZY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=990ugq3AXRs:S1UA27ZjUZY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=990ugq3AXRs:S1UA27ZjUZY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=990ugq3AXRs:S1UA27ZjUZY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=990ugq3AXRs:S1UA27ZjUZY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=990ugq3AXRs:S1UA27ZjUZY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=990ugq3AXRs:S1UA27ZjUZY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=990ugq3AXRs:S1UA27ZjUZY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/990ugq3AXRs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1337885701200353649/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/07/scottish-whisky.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1337885701200353649?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1337885701200353649?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/990ugq3AXRs/scottish-whisky.html" title="Scottish Whisky" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_lSk990LIlbk/Sk6FggP3jjI/AAAAAAAAAOk/gnQAk8hjBlw/s72-c/P1030132.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/07/scottish-whisky.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EDRHk8cSp7ImA9WxJWGUg.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-3112327022508402045</id><published>2009-06-24T03:14:00.000-07:00</published><updated>2009-06-25T10:41:15.779-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-25T10:41:15.779-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Personal Life" /><category scheme="http://www.blogger.com/atom/ns#" term="Travel" /><title>I ♥ Amsterdam!</title><content type="html">First Stop, Brussels. Ok, you must be scratching your head now, and asking "&lt;span style="font-style: italic;"&gt;Brussels&lt;/span&gt;? Like did you read your maps upside-down and got lost?" Well, the truth can't be any simpler: it is cheaper if I fly into Charleroi and drove to Amsterdam! Seeing two cities for the price of one, nice!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SkKJCzuDs-I/AAAAAAAAANM/wRq2-DhmNYM/s1600-h/P1020781.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SkKJCzuDs-I/AAAAAAAAANM/wRq2-DhmNYM/s400/P1020781.JPG" alt="" id="BLOGGER_PHOTO_ID_5350989988605703138" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;That's the town centre of Brussels, &lt;span style="font-style: italic;"&gt;gorgeous&lt;/span&gt;!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_lSk990LIlbk/SkKJgoCZgBI/AAAAAAAAANU/jcK0-xYx8mI/s1600-h/P1020791.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_lSk990LIlbk/SkKJgoCZgBI/AAAAAAAAANU/jcK0-xYx8mI/s400/P1020791.JPG" alt="" id="BLOGGER_PHOTO_ID_5350990500865867794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In one part of the city, there's a wall with the mural of &lt;a href="http://en.wikipedia.org/wiki/The_Adventures_of_Tintin"&gt;&lt;span style="font-style: italic;"&gt;Tin Tin&lt;/span&gt;&lt;/a&gt;. There's quite a bit of Tin Tin stuffs here, no surprises, given this the birthplace of its author, Herge.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_lSk990LIlbk/SkKJ2fY--fI/AAAAAAAAANc/CcU1628lgg0/s1600-h/P1020797.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_lSk990LIlbk/SkKJ2fY--fI/AAAAAAAAANc/CcU1628lgg0/s400/P1020797.JPG" alt="" id="BLOGGER_PHOTO_ID_5350990876501801458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Belgium waffles! Quite delectable, I had the one covered with strawberries and laced with chocolate, mmmmh! And it was &lt;span style="font-style: italic;"&gt;free&lt;/span&gt;! Not from the shop, but from a new friend of mine that I've met while travelling out from Dublin airport, a fellow Singaporean traveller, which is as rare as hen's teeth! Surprisingly, he was from Singapore's Ministry of Foreign Affairs, and remarked that I'm quite possibly the &lt;span style="font-style: italic;"&gt;only&lt;/span&gt; Singaporean living here! &lt;span style="font-style: italic;"&gt;I feel so special already&lt;/span&gt;! :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SkKKO02iKuI/AAAAAAAAANk/ka6NSZm0llQ/s1600-h/P1020802.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SkKKO02iKuI/AAAAAAAAANk/ka6NSZm0llQ/s400/P1020802.JPG" alt="" id="BLOGGER_PHOTO_ID_5350991294579747554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The architecture in the town centre is just incredible. Look at all the life-like statutes that are part of the walls of the buildings. For the lack of time, since I had a long drive ahead, that's all from Brussels. After which I had to take off and drive down to my newest favourite city, Amsterdam!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_lSk990LIlbk/SkKKmvoyYlI/AAAAAAAAANs/ErTTZ-4oCvM/s1600-h/P1020831.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_lSk990LIlbk/SkKKmvoyYlI/AAAAAAAAANs/ErTTZ-4oCvM/s400/P1020831.JPG" alt="" id="BLOGGER_PHOTO_ID_5350991705496773202" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;My new friend had actually spent a few days in Amsterdam already, so essentially I've gotten a free guide to show me around, which was really cool. It's really a quirk of fate, given that most Singaporeans may gladly give Ireland a pass, but not him - being an avid reader, and a fan of &lt;a href="http://en.wikipedia.org/wiki/James_Joyce"&gt;James Joyce&lt;/a&gt;, which was the main reason why we got to cross paths.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_lSk990LIlbk/SkKLTgQhGYI/AAAAAAAAAN0/_-yLlIypCg4/s1600-h/P1020833.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 400px;" src="http://4.bp.blogspot.com/_lSk990LIlbk/SkKLTgQhGYI/AAAAAAAAAN0/_-yLlIypCg4/s400/P1020833.JPG" alt="" id="BLOGGER_PHOTO_ID_5350992474462558594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Weed&lt;/span&gt;! You can now understand why I find this place so charming - not the soft drugs if that's what you're thinking about! It's the &lt;span style="font-style: italic;"&gt;liberalism&lt;/span&gt;, dammit! People are free to do whatever they want here, but take the responsibility for their actions, of course. Still can't believe that I'm travelling with a ranked civil servant here - hopefully he picks up a few lessons and report to his political masters that it is fine to have more liberalism! There aren't any major law and order problems here just because soft drugs are available - proves that we certainly &lt;a href="http://blog.vinceliu.com/2007/08/on.html"&gt;don't need to hang people just because they have a bit of grass in their pockets&lt;/a&gt;. Well, even &lt;a href="http://politicalticker.blogs.cnn.com/2007/11/26/obama-yes-i-inhaled%E2%80%94that-was-the-point/"&gt;Barack Obama has inhaled it&lt;/a&gt; ... had he been living in Singapore rather than America, they would have snuffed the life out of him before he can ever live up his potential to become the 44th President of the United States.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SkKLeV945eI/AAAAAAAAAN8/aHJeCh9Wo7c/s1600-h/P1020837.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SkKLeV945eI/AAAAAAAAAN8/aHJeCh9Wo7c/s400/P1020837.JPG" alt="" id="BLOGGER_PHOTO_ID_5350992660678632930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Sorry guys, if you are looking for &lt;a href="http://en.wikipedia.org/wiki/Not_safe_for_work"&gt;NSFW&lt;/a&gt; pictures - for consolation, you can see that I'm in the 'red light district' of Amsterdam. There's an Erotic Museum where I was told you'll be able to learn all you need to know about the history of sex. Fortunately, or unfortunately, Amsterdam has cleaned up quite a fair bit the last couple of years - I was told that half the city centre used to be areas where you can see skimpily dressed women behind glass boxes. Today, it's reduced to a only small section within &lt;span style="font-style: italic;"&gt;one&lt;/span&gt; alley - and there isn't much to see as well. Hell, there's probably more naked bodies lying on &lt;a href="http://www.youtube.com/watch?v=i7_6MhRp91c"&gt;Bondi Beach&lt;/a&gt; (NSFW!) any given summer day than in Amsterdam!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SkKLwDZdyPI/AAAAAAAAAOE/JzFAjZoE8q4/s1600-h/P1020843.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 400px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SkKLwDZdyPI/AAAAAAAAAOE/JzFAjZoE8q4/s400/P1020843.JPG" alt="" id="BLOGGER_PHOTO_ID_5350992964931668210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The only nakedness I've witnessed was from a drunken Englishman who had decided that his penis was probably a better show than all the ladies there. The crowd were wild, clapping, cheering and cat-whistling while he's twirling his thing out of his pants and flashing it to the crowd. On a related note, the booth you see up there is a peeing booth - yes, you go in and pee on the side of the streets, pretty visible to everybody else. No prizes for guessing what that dark patch on the floor is. ;)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SkKMB_gGbjI/AAAAAAAAAOM/wD2e8ipiFMY/s1600-h/P1020885.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SkKMB_gGbjI/AAAAAAAAAOM/wD2e8ipiFMY/s400/P1020885.JPG" alt="" id="BLOGGER_PHOTO_ID_5350993273123401266" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Amsterdam is full of canals and quaint little houses, some tilted with age, as you can see up there. Quite charming, although I wouldn't want to be living in there if there's a serious risk of it toppling over.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_lSk990LIlbk/SkKMVWa6e7I/AAAAAAAAAOU/AERfsK88tJ8/s1600-h/P1020892.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_lSk990LIlbk/SkKMVWa6e7I/AAAAAAAAAOU/AERfsK88tJ8/s400/P1020892.JPG" alt="" id="BLOGGER_PHOTO_ID_5350993605693176754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;That's how beautiful Amsterdam is. Oh, yeah you can see that it's devoid of people in the picture, which is kind of cool - that's because I woke up at 5am on a Sunday morning to take a wander about. The only people left on the streets were the few revellers who were probably too drunk to know how to go home.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SkKMmkyAGKI/AAAAAAAAAOc/HJfokI70r_E/s1600-h/P1020903.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SkKMmkyAGKI/AAAAAAAAAOc/HJfokI70r_E/s400/P1020903.JPG" alt="" id="BLOGGER_PHOTO_ID_5350993901605886114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I'll leave you with a final picture of one of the canals of Amsterdam. It's absolutely gorgeous for a place, and certainly one of the best cities I've been to in my life, and if you ever have the opportunity to visit it, &lt;span style="font-style: italic;"&gt;go&lt;/span&gt; - I assure you won't regret it!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-3112327022508402045?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=fEDepB8qm-g:dqvfAtp-H-k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=fEDepB8qm-g:dqvfAtp-H-k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=fEDepB8qm-g:dqvfAtp-H-k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=fEDepB8qm-g:dqvfAtp-H-k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=fEDepB8qm-g:dqvfAtp-H-k:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=fEDepB8qm-g:dqvfAtp-H-k:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=fEDepB8qm-g:dqvfAtp-H-k:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=fEDepB8qm-g:dqvfAtp-H-k:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/fEDepB8qm-g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/3112327022508402045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/i-amsterdam.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3112327022508402045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3112327022508402045?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/fEDepB8qm-g/i-amsterdam.html" title="I ♥ Amsterdam!" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_lSk990LIlbk/SkKJCzuDs-I/AAAAAAAAANM/wRq2-DhmNYM/s72-c/P1020781.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/i-amsterdam.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4DQ38_eSp7ImA9WxJWFk8.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-7403887654964120263</id><published>2009-06-21T03:14:00.000-07:00</published><updated>2009-06-21T15:39:32.141-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-21T15:39:32.141-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Security" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Configuring your Linux Firewall using iptables</title><content type="html">When I first started out using Linux, I was quite daunted by 'iptables', the built-in firewall that is bundled with the Linux kernel. Given there is a general misconception from a lot of people's that configuring it is anything but easy has also compounded towards my reluctance to try to learn it in detail initially - but no surprises here, as the &lt;a href="http://iptables-tutorial.frozentux.net/iptables-tutorial.html"&gt;good tutorial I've referenced has 16 chapters and 10 appendices&lt;/a&gt;! It's little wonder why some people might be scared away by that.&lt;br /&gt;&lt;br /&gt;But there is a good reason why a tutorial about iptables is that big - computer security is all about the details, most of the time you know all the details on the different aspects of network security to understand the whole picture before you can design a comprehensive firewall that provides all features you want without letting malicious traffic through.&lt;br /&gt;&lt;br /&gt;Still, if you're just setting up a simple home network + firewall, it shouldn't be that difficult. And it isn't really. I'll show you a few recipes you can use to set things up properly without having too much &lt;a href="http://blog.vinceliu.com/2007/09/do-not-rtfm.html"&gt;RTFM&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For illustration, I'll use the following setup that I'm running at home as an example:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SjkSPdvWGRI/AAAAAAAAANE/W68yDQQ0KTs/s1600-h/firewall.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 113px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SjkSPdvWGRI/AAAAAAAAANE/W68yDQQ0KTs/s400/firewall.png" alt="" id="BLOGGER_PHOTO_ID_5348326089369721106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;My server&lt;/span&gt; is an old Celeron PC which acts as the firewall. It has an ethernet card which connects to a wireless switch where the Internet connection gets shared by all my laptops connected to &lt;span style="font-style: italic;"&gt;My LAN&lt;/span&gt;. How the server connects to the Internet is via my &lt;a href="http://blog.vinceliu.com/2009/05/huawei-e220-modem-on-linux.html"&gt;Huawei E220 broadband modem&lt;/a&gt;. It just convenient to have my configuration this way as well, since my old iBookG4 has no suitable drivers. The broadband device is recognized as ppp0 as shown in the diagram above. Let me now show you a few interesting things you can do with your 'iptables' firewall.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Recipe #1 Forward Internet Connections using IP Masquerading&lt;/span&gt;&lt;br /&gt;You want to let your LAN make connections from the Internet. This is one of the cool features that iptables provide that makes it more than just a firewall. Before you make changes to your firewall entries, you'll need to make some changes to your kernel's configuration to enable it to forward IP traffic. To do this dynamically, run the following command:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The changes you've made above will be lost the next time you reset your computer. To make this change permanent, you have to make changes to &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; to include the following line:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;net.ipv4.ip_forward=1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once that's set up, we can issue the commands to &lt;code&gt;iptables&lt;/code&gt; to start forwarding traffic from the LAN to the Internet:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE&lt;br /&gt;iptables -A FORWARD -i eth0 -o ppp0 -j ACCEPT&lt;br /&gt;iptables -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The formal name for forwarding network traffic is called 'Network Address Translation', or NAT for short. This explains why the first &lt;code&gt;iptables&lt;/code&gt; command has &lt;code&gt;nat&lt;/code&gt; in it. It basically instructs the firewall to remember the connection that gets forwarded out the Internet. It needs to do this do multiplex different connections from the LAN into a single connection out to the Internet, and then smartly demultiplexes the received data back to the requesters. The next two iptables directives tell the firewall to allow forwarding of packets to the Internet from the LAN, and only allow data packets from the Internet to be sent back to the LAN only if there previously are connections requesting for it. This effectively denies any illegal traffic from coming into the LAN unless computers within it explicitly allows it to.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Recipe #2 Differentiating Traffic between LAN and the Internet&lt;/span&gt;&lt;br /&gt;Often, you'll want to assign different rights to traffic from your LAN vs. the Internet. Traffic from your LAN is usually trusted, and hence is within the &lt;span style="font-style: italic;"&gt;safe&lt;/span&gt; boundary, while Internet traffic is regarded as hostile, hence classified as &lt;span style="font-style: italic;"&gt;unsafe&lt;/span&gt;. Like the diagram shown in my example above, data from the Internet via device ppp0 is the &lt;span style="font-style: italic;"&gt;unsafe&lt;/span&gt; network which I'll want to have differentiating rules from my &lt;span style="font-style: italic;"&gt;safe&lt;/span&gt; LAN network originating from eth0.&lt;br /&gt;&lt;br /&gt;Firstly we want to create the two different chains to represent traffic from eth0 and ppp0:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables -N ETH0_FILTER&lt;br /&gt;iptables -N PPP0_FILTER&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once the chains are created, we have to tell the main INPUT traffic chain to segregate the traffic between the two networks:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables -A INPUT -i eth0 -j ETH0_FILTER&lt;br /&gt;iptables -A INPUT -i ppp0 -j PPP0_FILTER&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once the different changes are linked to the main input, we can now provide rules to treat the different networks separately. For example, if we want to let our LAN network access everything, and only allow SSH traffic from the Internet, we can put rules like these:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables -A ETH0_FILTER -j ACCEPT&lt;br /&gt;iptables -A PPP0_FILTER -p tcp -m tcp --dport 22 -j ACCEPT&lt;br /&gt;iptables -A PPPo_FILTER -j DROP&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will drop all other traffic except SSH on &lt;code&gt;ppp0&lt;/code&gt;. For other interesting ways of configuring how you want to filter your traffic between the different chains keep reading the remaining tips.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Recipe #3 Logging Suspicious Traffic&lt;br /&gt;&lt;/span&gt;&lt;span&gt;How&lt;/span&gt;&lt;span&gt; would&lt;/span&gt;&lt;span&gt; you know if you are under attack by malicious Internet traffic? Simple, by logging these intrusions. Here's one way of logging these intrusions:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables -A PPP0_FILTER -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 2 --name DEFAULT --rsource -j LOG --log-prefix "DROPPED:"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;The example above says that if there are more than 2 consecutive connections from the Internet to my SSH port (22) within the last 60 seconds, then LOG the message with the prefix &lt;span style="font-style: italic;"&gt;"DROPPED:"&lt;/span&gt;&lt;/span&gt;&lt;span&gt;. Obviously, this line only logs the connection, what I've omitted is to drop the connection (see Recipe #4 below).&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Recipe #4 Rate Limit Spam Traffic&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Bots and spammers usually rely on software that repeatedly scan and access your server to try to bruteforce their way in. On machines with a noisy harddisk like mine, the repeated clicking sound is a dead-giveaway (not to mention the annoyance!) So to stop from them from repeatedly doing so, we enact a rule that drops packets if too many incoming new connections are attempted within a short period of time&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;pre&gt;&lt;br /&gt;iptables -A PPP0_FILTER -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 2 --name DEFAULT --rsource -j DROP&lt;br /&gt;iptables -A PPP0_FILTER -p tcp -m tcp --dport 22 -j ACCEPT&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The first line tells the firewall to log all new incoming connections - if more than 2 new connections are attempted within 60 seconds, then all the remaining connections will be dropped until the 60 second period times out. Given my default policy of my firewall is to drop connections, the second line is included to explicitly ACCEPT the connection, if the first rule does not match (ie, no more than 2 connections are seen within the last 60 seconds).&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Recipe #5 Fight Back Spammers By Tarpitting&lt;br /&gt;&lt;/span&gt;&lt;span&gt;A tarpit connection is one that delays incoming network connections as long as possible. This technique causes spam connections to slow down, limiting the amount of computers that it can spam. However the iptables version of tarpit is a slightly more advanced variant: it sets the TCP acknowledgement window of the network packet to 1, forcing the sender to generate a full TCP packet per 1 byte of data it tries to send, making it computationally costly for spammers as it saps the computer's CPU resources. If you like to fight back against spammers, then this tip is for you.&lt;br /&gt;&lt;br /&gt;To enable tarpitting, this requires you to patch and recompile your kernel, which is an entire post itself, so read my more detailed post on &lt;a href="http://blog.vinceliu.com/2009/06/setting-up-tarpit-on-ubuntu-linux.html"&gt;how to enable tarpitting.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Recipe #6 Making Your Firewall Changes Permanent&lt;br /&gt;&lt;/span&gt;After making all those nifty changes, it would be a shame if they got lost the next time your computer rebooted. So here's how you can make these firewall settings permanent. Once you are satisfied with all the changes you are making to your firewall, save it by invoking &lt;code&gt;iptables-save&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables-save &gt; /etc/iptables.rules&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above command pipes all the configuration into /etc/iptables.rules file. Once you have that, you'll want to restore the configuration every single time your computer starts up. There are quite a few places where you can start restoring the firewall, I do it in my &lt;code&gt;/etc/rc.local&lt;/code&gt; file, after my ppp connection is started, where I insert the following line:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;iptables-restore &lt; /etc/iptables.rules &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And you're all done. Now you can sit back, relax and enjoy the security features of your firewall!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-7403887654964120263?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=-BMRrRG4tmU:XJYcZ68zr4k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=-BMRrRG4tmU:XJYcZ68zr4k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=-BMRrRG4tmU:XJYcZ68zr4k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=-BMRrRG4tmU:XJYcZ68zr4k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=-BMRrRG4tmU:XJYcZ68zr4k:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=-BMRrRG4tmU:XJYcZ68zr4k:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=-BMRrRG4tmU:XJYcZ68zr4k:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=-BMRrRG4tmU:XJYcZ68zr4k:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/-BMRrRG4tmU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/7403887654964120263/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/configuring-your-linux-firewall-using.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/7403887654964120263?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/7403887654964120263?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/-BMRrRG4tmU/configuring-your-linux-firewall-using.html" title="Configuring your Linux Firewall using iptables" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_lSk990LIlbk/SjkSPdvWGRI/AAAAAAAAANE/W68yDQQ0KTs/s72-c/firewall.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/configuring-your-linux-firewall-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8AQXs9eCp7ImA9WxJWEko.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-661807898364696016</id><published>2009-06-17T15:14:00.000-07:00</published><updated>2009-06-17T15:14:00.560-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-17T15:14:00.560-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Getting System Information from Linux</title><content type="html">Here are some commands that I commonly use to find information about my system. The amount of information you can get on your computer can be vast and varied - it depends on how detailed you want to go into each of the subsystem on your computer. I'll try to group them in order that is most sensible, and also, note that these commands may be Ubuntu/Debian specific.&lt;br /&gt;&lt;br /&gt;Listing devices on your mainboard:&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;biosdecode                 # information about your BIOS&lt;br /&gt;lshw                       # gets quite a bit of information on everything about your CPU&lt;br /&gt;lspci                      # get devices on your PCI bus&lt;br /&gt;lsusb                      # list devices on your USB&lt;br /&gt;dmidecode                  # get device information via BIOS&lt;br /&gt;fdisk -l                   # get partition info on your harddisk&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Getting information on your OS:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cat /proc/cpuinfo          # get information about your processor &lt;br /&gt;cat /proc/meminfo          # shows memory usage&lt;br /&gt;free                       # show available free memory&lt;br /&gt;top                        # detailed memory usage by process&lt;br /&gt;htop                       # a better version of top&lt;br /&gt;lsof                       # shows which file handle is opened by processes&lt;br /&gt;lsmod                      # shows loaded kernel modules&lt;br /&gt;dmesg                      # output bootup information&lt;br /&gt;lsb_release -a             # see which distro of OS you're using&lt;br /&gt;ps -e aux                  # list all running processes&lt;br /&gt;df --si                    # show amount of free disk space&lt;br /&gt;hdparm -t harddisk_device  # show performance of harddisk&lt;br /&gt;ifconfig                   # show network configuration&lt;br /&gt;route                      # show network routing configuration&lt;br /&gt;iwconfig                   # show wireless network information&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-661807898364696016?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=V6f_WCsRxFE:UQy3His893M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=V6f_WCsRxFE:UQy3His893M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=V6f_WCsRxFE:UQy3His893M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=V6f_WCsRxFE:UQy3His893M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=V6f_WCsRxFE:UQy3His893M:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=V6f_WCsRxFE:UQy3His893M:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=V6f_WCsRxFE:UQy3His893M:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=V6f_WCsRxFE:UQy3His893M:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/V6f_WCsRxFE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/661807898364696016/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/getting-system-information-from-linux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/661807898364696016?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/661807898364696016?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/V6f_WCsRxFE/getting-system-information-from-linux.html" title="Getting System Information from Linux" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/getting-system-information-from-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAMQXwzeip7ImA9WxJXGUs.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-1736579185060779139</id><published>2009-06-14T01:23:00.000-07:00</published><updated>2009-06-14T01:23:00.282-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-14T01:23:00.282-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Ubuntu on iBook G4</title><content type="html">People must think I am going gaga; I have installed Ubuntu on every different CPU architecture I have laid my hands on, and now on my Macbook G4!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SjOEEmD_yhI/AAAAAAAAAM0/Wiu_aD1tuIg/s1600-h/P1020767.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SjOEEmD_yhI/AAAAAAAAAM0/Wiu_aD1tuIg/s400/P1020767.JPG" alt="" id="BLOGGER_PHOTO_ID_5346762397090564626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Mac Zealots won't be pleased. But, don't you worry - the Mac OSX image is still living somewhere in the system. Unfortunately Ubuntu isn't as efficient in power utilisation as the Mac OSX is on the iBook G4: the machine gets hotter much quicker and you can hear the fan whirring at a much more regular interval.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_lSk990LIlbk/SjOEOc5VQxI/AAAAAAAAAM8/adQ9fxrSAfY/s1600-h/P1020768.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_lSk990LIlbk/SjOEOc5VQxI/AAAAAAAAAM8/adQ9fxrSAfY/s400/P1020768.JPG" alt="" id="BLOGGER_PHOTO_ID_5346762566428607250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;So I've got Ubuntu/Xubuntu living in various incarnations now; on an UltraSparc, PowerPC, x86 and AMD64 (ok, I've double counted if you consider 64-bit as a variant of the x86 architecture ;)&lt;br /&gt;&lt;br /&gt;Before I get labelled an Ubuntu zealot, I need to clear the air a little. I've installed Linux because it has plenty of development tools that a software developer needs; and Ubuntu because it's an easy distro for installation. Still I'm no less impressed by the vast amount of hardware Linux supports.&lt;br /&gt;&lt;br /&gt;I certainly think Linux takes the crown for being an ubiquitous OS, in spite of being driven by a purely free software development movement - remember that nobody gets paid to do this, and yet people are generous enough to donate code and effort to make this all happen. The irony in this, is that it is exactly of Linux's free nature that makes supporting so many different hardware possible in the first place.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;Related Posts:&lt;/span&gt; &lt;a href="http://www.blogger.com/2009/02/its-alive.html"&gt;It's Alive!&lt;/a&gt; (Linux on UltraSparc)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-1736579185060779139?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q6pKXJnchUc:bStxxoyLAVE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q6pKXJnchUc:bStxxoyLAVE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q6pKXJnchUc:bStxxoyLAVE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q6pKXJnchUc:bStxxoyLAVE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q6pKXJnchUc:bStxxoyLAVE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q6pKXJnchUc:bStxxoyLAVE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q6pKXJnchUc:bStxxoyLAVE:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q6pKXJnchUc:bStxxoyLAVE:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/Q6pKXJnchUc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/1736579185060779139/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/ubuntu-on-ibook-g4.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1736579185060779139?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/1736579185060779139?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/Q6pKXJnchUc/ubuntu-on-ibook-g4.html" title="Ubuntu on iBook G4" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_lSk990LIlbk/SjOEEmD_yhI/AAAAAAAAAM0/Wiu_aD1tuIg/s72-c/P1020767.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/ubuntu-on-ibook-g4.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMGR305eip7ImA9WxJVFUg.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-7797261324317876259</id><published>2009-06-11T07:57:00.000-07:00</published><updated>2009-07-02T09:00:26.322-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-02T09:00:26.322-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Security" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Setting up a tarpit on Ubuntu Linux</title><content type="html">It's amazing to see how big botnets can grow up till these days, and they really have plenty of computing power to spare. So what do botnet owners do with these unused free computing power after looting all valuable information from the poor victim? They waste it on scanning on any potential possibilities no matter how minute a chance of finding an opening is.&lt;br /&gt;&lt;br /&gt;In the days when computer resources are scarce, computer bots don't bother port scanning addresses when ping requests doesn't provide a response. But not anymore. They know that there are people out there who are slightly more tech-savvy and do not want to be annoyed - so today's bots have no qualms in trying to scan every single port on a network address, even if ping does not respond.&lt;br /&gt;&lt;br /&gt;Well, my computer security philosophy is simple: scanning the ports on my computer constitutes as aggression - if you engage in such activity, then it means I am free to retaliate in response to it.&lt;br /&gt;&lt;br /&gt;Even so, I do not mean launching an attack on the infected computer; but I'll make your bots waste it's resources by making connections that leads to a dead end. On the flip side, in the process of doing that, this scheme will not waste my own resources by doing it. Typically, an activity like this is termed as 'tarpitting'. So let's see how we can set up a tarpit to fight these bots.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Patching the Kernel&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;In order to perform tarpitting, we need to rely on Linux's firewall, iptables and the 'tarpit' module. But since the 'tarpit' module on iptables isn't supported on default on Debian/Ubuntu anymore, the only way to enable it is to patch the kernel and recompile it. This may sound daunting to a novice user, but there really isn't a need to; all you need is just some basic knowledge and patience to set things up.&lt;br /&gt;&lt;br /&gt;Firstly, a patch to the kernel becomes necessary. It's currently unofficially maintained at http://enterprise.bih.harvard.edu/pub/tarpit-updates/, and marked as being 'unsupported' or 'obsolete' by netfilter team themselves, which essentially means &lt;span style="font-style: italic;"&gt;use at your own risk&lt;/span&gt;! I'm usually a risk-taker (only when it comes to computer software ;) so it's not a big issue. You should work out if this is right for you.&lt;br /&gt;&lt;br /&gt;You'll first need to download the kernel sources, and set up the corresponding environment for recompiling your kernel. A detailed step-by-step procedure is provided in the &lt;a href="https://help.ubuntu.com/community/Kernel/Compile"&gt;Ubuntu Wiki&lt;/a&gt;. I'm just going to skim through the details from the wiki, and show you the commands that is relevant for version Ubuntu Intrepid:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% apt-get install linux-kernel-devel fakeroot build-essential makedumpfile&lt;br /&gt;% apt-get install build-dep linux&lt;br /&gt;% apt-get source linux-source&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you need to find out what version of the kernel you're running before you can download and apply the corresponding patch. The version is shown as the directory name of the source you've downloaded, eg:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% ls -l /usr/src/&lt;br /&gt;linux-source-&lt;span style="font-weight: bold;"&gt;2.6.27&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;What we are interested is the number indicated in bold. In my case, it's 2.6.27. We need to do a few things here: firstly we want to inherit all the old configuration that came with your currently working kernel, so that the newly compiled kernel will be the same as the original. Then we can download the patch and apply it to the linux source, so that only change is the addition of the tarpit feature:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% cd /usr/src/linux-source-2.6.27&lt;br /&gt;% make oldconfig&lt;br /&gt;% wget http://enterprise.bih.harvard.edu/pub/tarpit-updates/tarpit-2.6.27.patch&lt;br /&gt;% patch -p1 &amp;lt; tarpit-2.6.27.patch&lt;/pre&gt;&lt;br /&gt;The patch should apply cleanly, which means now you have the tarpit feature in the kernel. But that's not enough, you need to make sure tarpit is compiled, as a module generally. To do this run:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% make menuconfig&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And select &lt;code&gt;'M'&lt;/code&gt; from the menu options &lt;code&gt;Networking Support -&gt; Network packet filtering framework (Netfilter) -&gt;Core Netfilter Configuration -&gt; "TARPIT" target support&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Compile Time!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is when you need to sit back, go make yourself a cup of coffee, and be patient. On my 500Mhz Celeron box, it took about 6-8 hours of compilation time on a Saturday morning. Essentially, I just left it compiling while I went out to enjoy a bit of the sunshine - you should too, especially if you are compiling on a slow computer like me.&lt;br /&gt;&lt;br /&gt;There really isn't anything too exciting watching a computer churn out code, kind of like watching grass grow. :)&lt;br /&gt;&lt;br /&gt;Issue the following commands to start the compiling process, and then wait:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;make-kpkg clean # only needed if you want to do a "clean" build&lt;br /&gt;fakeroot make-kpkg --initrd --append-to-version=-tarpit kernel-image kernel-headers&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If Ubuntu complains about not finding make-kpkg, then you may have to install 'kernel-package' (&lt;code&gt;apt-get install kernel-package&lt;/code&gt;). This will start off the compilation. Once you've completed there should be 2 Debian packages resulting from the compilation. All that's left to do is to install them:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% ls *.deb&lt;br /&gt;linux-headers-2.6.27.18-tarpit_2.6.27.18-tarpit-10.00.Custom_i386.deb&lt;br /&gt;linux-image-2.6.27.18-tarpit_2.6.27.18-tarpit-10.00.Custom_i386.deb&lt;br /&gt;&lt;br /&gt;% dpkg -i linux-image-2.6.27.18-tarpit_2.6.27.18-tarpit-10.00.Custom_i386.deb&lt;br /&gt;% dpkg -i linux-headers-2.6.27.18-tarpit_2.6.27.18-tarpit-10.00.Custom_i386.deb&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The installer will make modifications to the boot loader (usually GRUB these days), and adds two new entries into your boot menu. If you haven't made any customised changes to it, usually the installation process will not require any intervention and should complete automatically.&lt;br /&gt;&lt;br /&gt;Reboot your computer and you're set for setting a tarpit up!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Configuring 'iptables' for Tarpitting&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To utilise tarpit, you need to configure the rules on your firewall (iptables) to tarpit on incoming connections. There are plenty of excellent tutorials out there explaining how to use iptables to achieve what you want to do with your firewall, and it's beyond the scope of my entry to cover it all here. I'll just give a few simple examples on how you can use it to waste the resources of bots and spammers.&lt;br /&gt;&lt;br /&gt;To tarpit SMTP connections (assuming that you are not running an SMTP server):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;iptables -A INPUT -p tcp -m tcp --dport 25 -j TARPIT&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To tarpit incoming botnet bruteforce attacks on SSH:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --rsource&lt;br /&gt;iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 2 --rsource -j TARPIT&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The example limits SSH attempts to 2 connections in 60 seconds. And if any connection tries to connect at a rate higher than that, then the connection is sent to the tarpit immediately. My actual configuration is even more stringent than that; given that my SSH connections are verified by keys and not by password, there is never a chance that I could have sent a wrong password and hence tarpitting myself. For an average user who accidentally connects to my server, it isn't really too much of a problem - the connection will eventually time out.&lt;br /&gt;&lt;br /&gt;But lets see what happens when a spambot tries to connect repeatedly. I'll simulate this by using nc to act as a spammer. Let see what happens when I set the rule to just DROP:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;# iptables -I INPUT 1 -p tcp -m tcp --dport 25 -j DROP&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# netstat -apn&lt;br /&gt;Active Internet connections (servers and established)&lt;br /&gt;Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name&lt;br /&gt;tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4227/sshd      &lt;span style="font-family:Georgia,serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;DROP just does what it's told; that is to drop the packet, and that's the end of the story. The spambot will just shrug its shoulders and move on to find another spamming target. But see what happens when when we turn tarpitting on:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;# iptables -D INPUT 1&lt;br /&gt;# iptables -I INPUT 1 -p tcp -m tcp --dport 25 -j TARPIT&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# nc localhost 25&lt;br /&gt;^C&lt;br /&gt;# netstat -apn&lt;br /&gt;Active Internet connections (servers and established)&lt;br /&gt;Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name&lt;br /&gt;tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4227/sshd   &lt;br /&gt;tcp        0      1 127.0.0.1:36183         127.0.0.1:25            &lt;span style="font-weight: bold;"&gt;FIN_WAIT1&lt;/span&gt;   -           &lt;br /&gt;tcp        0      1 127.0.0.1:36185         127.0.0.1:25            &lt;span style="font-weight: bold;"&gt;FIN_WAIT1&lt;/span&gt;   -           &lt;br /&gt;tcp        0      1 127.0.0.1:36184         127.0.0.1:25            &lt;span style="font-weight: bold;"&gt;FIN_WAIT1&lt;/span&gt;   -           &lt;br /&gt;tcp        0      1 127.0.0.1:36181         127.0.0.1:25            &lt;span style="font-weight: bold;"&gt;FIN_WAIT1&lt;/span&gt;   -           &lt;br /&gt;tcp        0      1 127.0.0.1:36182         127.0.0.1:25            &lt;span style="font-weight: bold;"&gt;FIN_WAIT1&lt;/span&gt;   -           &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, the connections are stuck in the FIN_WAIT1 state, waiting for socket time outs to occur. So tarpitting works like a reverse syn-flood attack, but in this case the 'damage' is self-inflicted - the more aggressive a spambot is in trying to make a connection to us, the more it gets its resources exhausted. This helps to use up the computing resources of the spam computer, and engaging it in unproductive activities, thus preventing it from spamming more targets.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What if the 90% of the world Tarpits?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, most spambot code writers have wisen up to these techniques, and correspondingly have adapted their system to make their socket timeouts relatively short, thereby minimising the impact of such a defensive system. However, if most of the computer systems in the world utilises such a system, it will make it prohibitively expensive for spammers to engage in such activities.&lt;br /&gt;&lt;br /&gt;But the reality is, the majority of computer users do not understand the implications of this philosophy for it to work out. In fact, tarpitting will have been a good way of deterring most spam without adding more costs to paying customers like us. Imagine if 90% of all the computers are adversarial like this; then spam bots will have been wasting their resources 90% of the time. That should make the economics of spam a bad proposition to spammers, rather than the reverse situation we are having today - the majority of spam is handled by ISP's filtering, wasting 90% of the Internet's email traffic  on spam, annoying email users, and charging consumers money to take away the problem.&lt;br /&gt;&lt;br /&gt;If you haven't noticed it yet, in essence, we are indirectly paying for the costs these spammers incur. And that pisses me off.&lt;br /&gt;&lt;br /&gt;As a parting note to my post, I hate all spammers with a passion, so let this be a warning to all link-spammers on my blog - as much as I dislike spammers that I'll tarpit their connections, I do not take kindly to your link spam on my blog. Don't even bother do try, they are screened, and if your comments are just superficial irrelevant stuffs, you can bet your ass that it's never going to see the light of the day! And don't ever let me get my hands on your IP address ... :P&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-7797261324317876259?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q0s2v_pV60g:yYNm9RWBQUc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q0s2v_pV60g:yYNm9RWBQUc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q0s2v_pV60g:yYNm9RWBQUc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q0s2v_pV60g:yYNm9RWBQUc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q0s2v_pV60g:yYNm9RWBQUc:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q0s2v_pV60g:yYNm9RWBQUc:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=Q0s2v_pV60g:yYNm9RWBQUc:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=Q0s2v_pV60g:yYNm9RWBQUc:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/Q0s2v_pV60g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/7797261324317876259/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/setting-up-tarpit-on-ubuntu-linux.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/7797261324317876259?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/7797261324317876259?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/Q0s2v_pV60g/setting-up-tarpit-on-ubuntu-linux.html" title="Setting up a tarpit on Ubuntu Linux" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/setting-up-tarpit-on-ubuntu-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYDQnszeyp7ImA9WxJXEk4.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-2706494744838229684</id><published>2009-06-03T18:42:00.000-07:00</published><updated>2009-06-05T13:36:13.583-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-05T13:36:13.583-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Examining binary files in Linux</title><content type="html">A few different tips assembled together for one to find out information about an executable binary in Linux.&lt;br /&gt;&lt;br /&gt;To assert that the file is a binary executable (or some other file types):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;file file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To see what the legible strings within the binary file is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;strings file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To do a hexdump of the file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;od -tx1 file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To disassemble a compiled binary:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;readelf -b file.bin -m i8086&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To disassemble an binary object file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;objdump -DaflSx -b file.bin -m i8086&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To list the symbols in an object file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;nm file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To see what shared library it's being linked with:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;ldd file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To see a trace of what libraries it calls / files open dynamically:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;dtrace file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To debug through it's execution:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;gdb file.bin&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To unmangle function names if code is compiled with C++:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;echo "&amp;lt;mangled_symbol_name&amp;gt;" | c++filt&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-2706494744838229684?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=T6zFVeoou0g:BSEa-gKph-A:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=T6zFVeoou0g:BSEa-gKph-A:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=T6zFVeoou0g:BSEa-gKph-A:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=T6zFVeoou0g:BSEa-gKph-A:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=T6zFVeoou0g:BSEa-gKph-A:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=T6zFVeoou0g:BSEa-gKph-A:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=T6zFVeoou0g:BSEa-gKph-A:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=T6zFVeoou0g:BSEa-gKph-A:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/T6zFVeoou0g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/2706494744838229684/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/examining-binary-files-in-linux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2706494744838229684?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2706494744838229684?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/T6zFVeoou0g/examining-binary-files-in-linux.html" title="Examining binary files in Linux" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/examining-binary-files-in-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcHR388fyp7ImA9WxJXEk4.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-4051771998887246176</id><published>2009-06-01T13:21:00.000-07:00</published><updated>2009-06-05T13:33:56.177-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-05T13:33:56.177-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>How to 'make' a Euro / Sterling Key In Linux</title><content type="html">I never had to deal with the problem of handling foreign currency symbols, given that the countries I've lived in the past use the same terminology, where the only difference is the prefixing of their respective country name to the word 'dollar'.&lt;br /&gt;&lt;br /&gt;But living in the Eurozone and for being so near to the UK, the idea of expressing money in dollars is relatively quaint experience to them as much 'a quid' is to me. This difference is visibly noticed when it comes to computer keyboards.&lt;br /&gt;&lt;br /&gt;Keyboards for Europe with the exception of the UK have their default currency symbols mapped to the '€/£' symbol by default - there are key other layout quirks which make these keyboards infuriating to use but I'll leave them for another day.&lt;br /&gt;&lt;br /&gt;Even though I still reflexively swap Euros for Dollars in my daily conversations, at least my 'foreign' accent helps people to contextually frame what I meant, but typing '$' signs when you mean '€' certainly confuses people. My workaround in the past was to type 'Euros' at every instance when I mean currency, which is really becoming tiresome.&lt;br /&gt;&lt;br /&gt;So, the impetus aside, here's a quick tutorial to show you how to generate a Euro sign.&lt;br /&gt;&lt;br /&gt;First, we need to find out the keycodes of the keys that we want to remap. We do this by invoking 'xev', which traps all keystrokes and mouse movements. The keys we want to trap are the currency symbol, which is usually the same key as the numerical key '4' on the alphabetical side of the keyboard, and the right 'alt' key, which I will use as the special shift key to get € and £ without losing the $ symbol. A capture of xev looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% xev&lt;br /&gt;KeyPress event, serial 31, synthetic NO, window 0x2800001,&lt;br /&gt;  root 0x6b, subw 0x0, time 2804155, (256,85), root:(807,409),&lt;br /&gt;  state 0x0, keycode 13 (keysym 0x34, 4), same_screen YES,&lt;br /&gt;  XLookupString gives 1 bytes: (34) "4"&lt;br /&gt;  XmbLookupString gives 1 bytes: (34) "4"&lt;br /&gt;  XFilterEvent returns: False&lt;br /&gt;&lt;br /&gt;KeyRelease event, serial 34, synthetic NO, window 0x2800001,&lt;br /&gt;  root 0x6b, subw 0x0, time 2804251, (256,85), root:(807,409),&lt;br /&gt;  state 0x0, keycode 13 (keysym 0x34, 4), same_screen YES,&lt;br /&gt;  XLookupString gives 1 bytes: (34) "4"&lt;br /&gt;  XFilterEvent returns: False&lt;br /&gt;&lt;br /&gt;KeyPress event, serial 34, synthetic NO, window 0x2800001,&lt;br /&gt;  root 0x6b, subw 0x0, time 2807796, (256,85), root:(807,409),&lt;br /&gt;  state 0x0, keycode 108 (keysym 0xff7e, Alt_R), same_screen YES,&lt;br /&gt;  XLookupString gives 0 bytes:&lt;br /&gt;  XmbLookupString gives 0 bytes:&lt;br /&gt;  XFilterEvent returns: False&lt;br /&gt;&lt;br /&gt;KeyRelease event, serial 34, synthetic NO, window 0x2800001,&lt;br /&gt;  root 0x6b, subw 0x0, time 2807933, (256,85), root:(807,409),&lt;br /&gt;  state 0x2000, keycode 108 (keysym 0xff7e, Alt_R), same_screen YES,&lt;br /&gt;  XLookupString gives 0 bytes:&lt;br /&gt;  XFilterEvent returns: False&lt;br /&gt;&lt;br /&gt;ClientMessage event, serial 34, synthetic YES, window 0x2800001,&lt;br /&gt;  message_type 0x11a (WM_PROTOCOLS), format 32, message 0x118 (WM_DELETE_WINDOW)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There's a number of other events being truncated so that I'm only showing the relevant portions. The first two keypress/keyrelease set shows the keycode for '4' as 13 and the second set shows that my right 'alt' key has the keycode of 108.&lt;br /&gt;&lt;br /&gt;Armed with these numbers, let's create a &lt;code&gt;.xmodmaprc&lt;/code&gt; file in your home directory:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;keycode 108 = Mode_switch&lt;br /&gt;keycode 13 = 4 dollar EuroSign sterling&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Once the file is created, to activate the change immediate, simply issue xmodmap:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% xmodmap ~/.xmodmaprc&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And viola*, by pressing 'right alt' + '4' gives me '€' and 'shift' + 'right alt' + '4' gives me '£'!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-size:85%;"&gt;* Don't even get me started on umlauts and accents ;P&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-4051771998887246176?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UvXDhT0s16U:kmNfETKqo3I:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UvXDhT0s16U:kmNfETKqo3I:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UvXDhT0s16U:kmNfETKqo3I:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UvXDhT0s16U:kmNfETKqo3I:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UvXDhT0s16U:kmNfETKqo3I:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UvXDhT0s16U:kmNfETKqo3I:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=UvXDhT0s16U:kmNfETKqo3I:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=UvXDhT0s16U:kmNfETKqo3I:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/UvXDhT0s16U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/4051771998887246176/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/06/how-to-make-euro-sterling-key-in-linux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4051771998887246176?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/4051771998887246176?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/UvXDhT0s16U/how-to-make-euro-sterling-key-in-linux.html" title="How to 'make' a Euro / Sterling Key In Linux" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/06/how-to-make-euro-sterling-key-in-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUACSXo8fyp7ImA9WxJXEk4.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-8440811204550962908</id><published>2009-05-29T11:00:00.000-07:00</published><updated>2009-06-05T13:29:28.477-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-05T13:29:28.477-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Huawei E220 Modem on Linux</title><content type="html">Unfortunately for mobile broadband Internet connections, network setups are usually difficult and inconsistent experiences between the different network providers. Getting the modem to work can be a rather frustrating experience if things don't work straight out of the box.&lt;br /&gt;&lt;br /&gt;Before I start, I'll let you know that some of the settings here may be specific only to my provider, O2 Ireland, which you may have to do your own specific tweaks, and as the saying goes, "your mileage may vary".&lt;br /&gt;&lt;br /&gt;On the good side, the Huawei E220 modem seems to be a rather popular and well supported device, and it did on one instance worked straight out of the box on one of my friend's computer running Ubuntu 9.04 with Network Manager. It doesn't seem to work on 8.10, not on my machine (Ubuntu) or my laptop (Xubuntu), which may just boil down to configuration issues, or not. On the funny side, when I tried to get the settings off my friend's computer by right-clicking on it, it simply froze the machine entirely. (Windows users, insert your jibes here ;p)&lt;br /&gt;&lt;br /&gt;This problem is probably specific to O2, since I had a Vodafone modem dongle that I had borrowed before, which worked flawlessly on when plugged into my laptop, which I had assumed will be the case when I got O2, but it turned out not to be so.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Update:&lt;/span&gt; Found the reason why &lt;a href="https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/290177"&gt;Network Manager will work in 9.04 but not 8.10&lt;/a&gt;, the newer release had included Modem Manager which had specific setup that will request for a PIN which the O2 card was set up in default. By comparison, the Vodafone dongle did not require a PIN, hence network manager worked without a hitch.&lt;br /&gt;&lt;br /&gt;Anyhow, maybe these information I've gleaned from will help you find out what you need to get things to work.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What the lights on the modem really means.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ignore what the documentation says (partially) that came with the subscription. From my personal observation, if the light is green and flashing, it means that the modem is active, just that it's not authenticated to the provider. That should be a sign that your modem is working.&lt;br /&gt;&lt;br /&gt;The modem is also capable of flashing in blue colour (which is nowhere explained in the booklet). This means that your connection is authenticated with the provider, but currently is not having ppp connection established.&lt;br /&gt;&lt;br /&gt;If the lights are in solid green, blue, or light blue, it means that your connection is active, and in various different operating speeds (GPRS, 3G, HSDPA respectively) as explained in the booklet. From my observations, it seems like the connection typically reside in the 3G mode (dark blue colour) when it's passive, and only switches to HSDPA mode whenever you start sending or receiving data from the network.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Modem doesn't work with Network Manager&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;A number of sources suggests that the E220 modem works straight with Linux via Network Manager, but it certainly didn't work for me straight off. So I had do some reading on the wireless broadband forums to try to find answers. Most of them are geared towards solving problems for Vodafone, and the information is really spotty when it comes to O2. Given that I had no idea where to look to find out what's actually happening inside Network Manager, I had to try some other alternatives.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Update: &lt;/span&gt;I didn't know where to look before, but I've since found that Network Manager logs to /var/log/daemon.log - still the messages are not too helpful to actually tell you what exactly is the problem.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The saviour - wvdial&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;'wvdial' is the alternative application that got the connection to work after a bit of reading. The documentation on wvdial can be confusing, and even as I've gotten it to work, I still don't fully understand the relationship between wvdial and pppd. Here's the excerpted config I had in '/etc/wvdial.conf', it's a little half-baked, and sometimes still fails:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;[Dialer O2]&lt;br /&gt;ISDN = 0&lt;br /&gt;Baud = 460800&lt;br /&gt;Modem = /dev/ttyUSB0&lt;br /&gt;Phone = *99#&lt;br /&gt;Modem Type = Analog Modem&lt;br /&gt;Stupid Mode = 1&lt;br /&gt;Username = gprs&lt;br /&gt;Password = gprs&lt;br /&gt;Init1 = ATZ&lt;br /&gt;Init2 = ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2&lt;br /&gt;Init3 = AT+CPIN="1234"&lt;br /&gt;Init5 = AT+CGDCONT=1,"IP","open.internet"&lt;br /&gt;&lt;br /&gt;[Dialer O22]&lt;br /&gt;ISDN = 0&lt;br /&gt;Baud = 460800&lt;br /&gt;Modem = /dev/ttyUSB0&lt;br /&gt;Phone = *99#&lt;br /&gt;Modem Type = Analog Modem&lt;br /&gt;Stupid Mode = 1&lt;br /&gt;Username = gprs&lt;br /&gt;Password = gprs&lt;br /&gt;Init1 = ATZ&lt;br /&gt;Init2 = ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2&lt;br /&gt;#Init3 = AT+CPIN="1234"&lt;br /&gt;Init5 = AT+CGDCONT=1,"IP","open.internet"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Do replace '1234' with the actual PIN number that you have.&lt;br /&gt;&lt;br /&gt;You can see that I have 2 entries for the connection, which the only difference between the two is that the second entry doesn't have a PIN authentication command. This is the intentional, because wvdial does not know whether the modem is in authenticated mode or not (ie, whether if it's flashing blue or flashing green. The ATZ command does not seem to reset this authenticated state.)&lt;br /&gt;&lt;br /&gt;If you started your computer fresh and your modem is showing a flashing green light, invoke wvdial this way:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% wvdial O2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That should work if you started your modem cold. Sometimes the first connection gets dropped for no reason, and to try to reestablish the connection, run wvdial with the O22 connection instead. If you succeed, you should see an output like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;--&gt; WvDial: Internet dialer version 1.60&lt;br /&gt;--&gt; Cannot get information for serial port.&lt;br /&gt;--&gt; Initializing modem.&lt;br /&gt;--&gt; Sending: ATZ&lt;br /&gt;ATZ&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2&lt;br /&gt;ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: AT+CGDCONT=1,"IP","open.internet"&lt;br /&gt;AT+CGDCONT=1,"IP","open.internet"&lt;br /&gt;OK&lt;br /&gt;--&gt; Modem initialized.&lt;br /&gt;--&gt; Sending: ATDT*99#&lt;br /&gt;--&gt; Waiting for carrier.&lt;br /&gt;ATDT*99#&lt;br /&gt;CONNECT&lt;br /&gt;--&gt; Carrier detected.  Starting PPP immediately.&lt;br /&gt;--&gt; Starting pppd at Sat May 30 08:20:44 2009&lt;br /&gt;--&gt; Pid of pppd: 7312&lt;br /&gt;--&gt; Using interface ppp0&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; local  IP address 89.204.199.133&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; remote IP address 10.64.64.64&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; primary   DNS address 62.40.32.33&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;--&gt; secondary DNS address 62.40.32.34&lt;br /&gt;--&gt; pppd: H�c X�c ��c&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Trying Network Manager Again&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have established a connection successfully before, but got dropped for some reason, the light on your modem should be flashing blue.  In this case your modem is in the authenticated state, and Network Manager will start working happily if you wanted to use it now.&lt;br /&gt;&lt;br /&gt;As I said, Network Manager did work with one of my friend's computer - the difference being that when I tried connecting, his version of Network Manager prompted me to key in my PIN, while my didn't. Even manually setting the PIN in the configuration won't make it work.&lt;br /&gt;&lt;br /&gt;But at least it'll work indirectly, and tells us that the problem lies within authentication.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fun things to do with the modem&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;- AT Commands&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Through using wvdial, I realised that the usb modem actually uses a variant of the AT commands of the phone modems I used to have for dialups and BBSes. It kind of piqued my interest a bit, and good for reliving the good old days of fiddling around with AT commands on my modem.&lt;br /&gt;&lt;br /&gt;To do so, we'll need to find the interface in which you can send and receive commands to - 'dmesg' will be helpful for these occasions:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;[   21.839161] usb-storage: device found at 2&lt;br /&gt;[   21.839163] usb-storage: waiting for device to settle before scanning&lt;br /&gt;[   21.849151] usbserial: USB Serial support registered for GSM modem (1-port)&lt;br /&gt;[   21.849175] option 4-1:1.0: GSM modem (1-port) converter detected&lt;br /&gt;[   21.849429] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB0&lt;br /&gt;[   21.849441] option 4-1:1.1: GSM modem (1-port) converter detected&lt;br /&gt;[   21.849519] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB1&lt;br /&gt;[   21.849535] usbcore: registered new interface driver option&lt;br /&gt;[   21.849538] option: USB Driver for GSM modems: v0.7.2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So, /dev/ttyUSB0 is the interface in which Network Manager/wvdial uses to connect to the mobile phone provider, which kind of perplexed me why there is an additional /dev/ttyUSB1 interface. One of the things that came up from googling was an out-of-date &lt;a href="http://oozie.fm.interia.pl/pro/huawei-e220/"&gt;kernel support page&lt;/a&gt; for the modem.&lt;br /&gt;&lt;br /&gt;It provided a tool to read the signal strength of the modem, which out of curiosity, I downloaded the source code and waded through it. That's when I realised that /dev/ttyUSB1 is the interface in which you can issue AT commands to.&lt;br /&gt;&lt;br /&gt;Armed with that knowledge, we can now start issuing commands straight into the device! Relying on a primitive method, do this by starting two terminal windows side by side. On one window, do:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;$ cat /dev/ttyUSB1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This shows you what's the output coming out from the commands issued. On the other window it is where you issue your commands. For example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;$ echo "AT" &gt; /dev/ttyUSB1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You should see "OK" coming out from the other window, showing that the modem has acknowledge your 'attention' command. Pretty cool eh?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fun Things To Do #1: Disabling PIN Authentication&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Remember the problem with PIN authentication that prevented Network Manager from working properly? Well you can side-step the problem by disabling the PIN authentication feature on the SIM card:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;echo 'AT+CLCK="SC",0,"1234"' &gt; /dev/ttyUSB1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;Replace '1234' with the actual PIN number that you have. This should disable the need for authentication. &lt;span style="font-weight: bold;"&gt;A word of caution&lt;/span&gt;: do this only if you're not too concerned about the physical security of your modem, otherwise if it gets lost or stolen, others can start using your Internet connection for free!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fun Things To Do #2: Get SMS Messages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For linux users, we aren't provided with any GUI for us to access and send SMS messages from the SIM card. Unfortunately the O2 site registration assumes that we are all Windoze users, which is the only way in which we can pull out the authentication SMS message that it sends to the mobile phone.&lt;br /&gt;&lt;br /&gt;Well fret no more, here's how we can gain access to SMS messages simply by using AT commands:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;$ echo 'AT+CMGF=1' &gt; /dev/ttyUSB1&lt;br /&gt;$ echo 'AT+CMGL="ALL"' &gt; /dev/ttyUSB1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This should turn on SMS mode on the modem and dump out all the received SMSes. And from the output messages, you can pick out the authentication message that looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;+CMGL: 0,"REC READ","02",,"25/05/27,20:33:07+04"&lt;br /&gt;&lt;br /&gt;Welcome to O2 Broadband! Should you have any queries, visit www.o2.ie/broadbandfaq or our interactive forum on http://forums.o2online.ie. Best wishes, O2.&lt;br /&gt;&lt;br /&gt;+CMGL: 1,"REC READ","0000000000",,"26/05/28,21:04:54+04"&lt;br /&gt;&lt;br /&gt;Your verification code is XXXXXXXX. Please go to o2.ie and continue your registration.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is at least useful if you don't want the hassle of manually pulling out the SIM card to put in into your phone to get the SMS message for authentication.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;More References&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The Wikipedia page on the &lt;a href="http://en.wikipedia.org/wiki/Hayes_command_set"&gt;Hayes modem command set&lt;/a&gt; has a set of good starter commands on AT commands. Or to read up more on SMS AT &lt;a href="http://www.developershome.com/sms/howToSendSMSFromPC.asp"&gt;write commands&lt;/a&gt; or &lt;a href="http://www.developershome.com/sms/howToReceiveSMSUsingPC.asp"&gt;read commands&lt;/a&gt; can be found in these links.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-8440811204550962908?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ywetwOAJWj0:Zo-Z4T8UUUE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ywetwOAJWj0:Zo-Z4T8UUUE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ywetwOAJWj0:Zo-Z4T8UUUE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ywetwOAJWj0:Zo-Z4T8UUUE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ywetwOAJWj0:Zo-Z4T8UUUE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ywetwOAJWj0:Zo-Z4T8UUUE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=ywetwOAJWj0:Zo-Z4T8UUUE:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=ywetwOAJWj0:Zo-Z4T8UUUE:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/ywetwOAJWj0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/8440811204550962908/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/05/huawei-e220-modem-on-linux.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/8440811204550962908?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/8440811204550962908?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/ywetwOAJWj0/huawei-e220-modem-on-linux.html" title="Huawei E220 Modem on Linux" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/05/huawei-e220-modem-on-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAGQH49fip7ImA9WxJQFUk.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-2432750822706989213</id><published>2009-05-28T14:30:00.000-07:00</published><updated>2009-05-28T14:55:21.066-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-28T14:55:21.066-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Personal Life" /><title>Internet, Finally!</title><content type="html">I finally have Internet at home!&lt;br /&gt;&lt;br /&gt;After 3 long months of going cold turkey involuntarily. I have finally gotten an Internet connection to my home, via mobile broadband. It's clocking about 300kbps download at best, which isn't great, but at least I can use it to type whimsical blog posts like these in the leisure of my home, rather than having to deal with late nights in the office. With commuting time after hours being unreliable and subjected to long half hour waits, it seriously isn't worth wasting the time just to be able to use the Internet, really.&lt;br /&gt;&lt;br /&gt;Surprisingly, the new place that I've moved in does not have a fibre-to-the-curb connection to my apartment - and it's only built 2 years ago! Not only that, the apartment does not even come with a phone line, which means I can't even get ASDL. I can get a technician to get it especially wired to my place, but that means installation charges + line rental for a phone that I do not want in order to get Internet access, making it a rather expensive proposition.&lt;br /&gt;&lt;br /&gt;So the only alternative left was to rely on cheap wireless broadband, which at 20 Euros is the cheapest by Irish standards (That's excluding VAT, which is another major bloodsucker in this country :P). That's roughly about $40 dollars AUD/SGD, which I suppose would have gotten me a decent network connection, and without any download restrictions (on a land line)?&lt;br /&gt;&lt;br /&gt;Oh well, at least for an el-cheapo bastard like me, it should suffice, since I don't do much that consumes a large amount of bandwidth anyway. 10Gb is quite hard to use up no matter how much blog posts, email or news I do in a day, but obviously it's never quite enough for the YouTube generation.&lt;br /&gt;&lt;br /&gt;Which is fine for an 'old fogey' like me - I belong to the &lt;a href="http://www.google.ie/search?q=640k+ought+to+be+enough+for+anybody"&gt;'640k ought to be enough for anybody&lt;/a&gt;' generation anyway, ;)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-2432750822706989213?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=85IdBnlEbYE:hWFYfPGkeyg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=85IdBnlEbYE:hWFYfPGkeyg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=85IdBnlEbYE:hWFYfPGkeyg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=85IdBnlEbYE:hWFYfPGkeyg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=85IdBnlEbYE:hWFYfPGkeyg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=85IdBnlEbYE:hWFYfPGkeyg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=85IdBnlEbYE:hWFYfPGkeyg:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=85IdBnlEbYE:hWFYfPGkeyg:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/85IdBnlEbYE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/2432750822706989213/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/05/internet-finally.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2432750822706989213?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/2432750822706989213?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/85IdBnlEbYE/internet-finally.html" title="Internet, Finally!" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/05/internet-finally.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkECSXc7fCp7ImA9WxJTEEQ.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-6923016973416114730</id><published>2009-04-18T11:58:00.000-07:00</published><updated>2009-04-18T14:37:48.904-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-18T14:37:48.904-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Personal Life" /><title>A Good Friday It Is!</title><content type="html">Decided that I wanted a reckless, unplanned holiday over the Easter weekend, so I packed my bag with only a toothbrush, a set of clothes, and took off on my bicycle.&lt;br /&gt;&lt;br /&gt;Given that I had a 4-day weekend, I had this 'delusion of grandeur' that I'll try to cycle to Waterford and back, which when I recounted my little adventure to my friends later, they all had thought that I was a little 'ambitious'. I'm sure they were  just be polite with me not to point out that I was deranged to try to cycle 320km to and back. :)&lt;br /&gt;&lt;br /&gt;Without even a map or any plans on how I'm supposed to get there, I cycled aimlessly south, passing through Shankill, Bray then Greystones. I had never been in those places before, and each of them were a lovely little towns of their own, with Bray the biggest, Shankill the smallest, and Greystones just nice. In a way this Goldilocks (yours truly) is certainly tempting fate without even planning for where he's going - it is really not funny trying to tough it out on the streets; there's still plenty of cold in mid-April to try to sleep on the streets when you're in Ireland!&lt;br /&gt;&lt;br /&gt;Stopped in each town for a while, and had plenty of soft-serve vanilla ice-cream cones along the way, which was when I noticed this Irish anomaly on their menus called the 'Special 99'. Even after later when I try to figure out they story behind the name by asking my Irish colleagues, nobody seems to know why having a stick of chocolate in the  ice-cream makes it a 'Special 99'. Very well then, I'm just going to have to make up my own story, and bluff anybody who asks that an Irishman invented this in '99, which took the whole country by storm which is how the name came about. So take note that you've heard it here first!&lt;br /&gt;&lt;br /&gt;Along the way, I met a couple of French backpackers whom I started chatting up with. They were asking for directions and I found out that they are travelling to Glendalough (pronounced 'Glen-da-lock'), where the main attraction there is some old ruins. They were lost, but they had a plan where I had none, so I thought I could give them a hand by trying to look up the place they are going on my Blackberry-cum-GPS, which only gave me a rough idea of where we were, and had no relevance to any of the landmarks that they have shown me on their map. ( &lt;span style="font-weight: bold;"&gt;A mental note to self:&lt;/span&gt; don't ever rely on the Blackberry's GPS to find your way out of the woods if your life depended on it! )&lt;br /&gt;&lt;br /&gt;Anyhow, given that I didn't have a plan, and they were quite adamant to go there, I thought they must be on to something, so I decided to abandon my original plan to  Waterford via zipping along the coastal fringe, and follow them inland instead.&lt;br /&gt;&lt;br /&gt;With hindsight, this had probably turned out to be a pretty good choice.&lt;br /&gt;&lt;br /&gt;Given that they were travelling by foot, and didn't have too much luck with hitch-hiking, we decided to camp out in someone's paddock:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SeojCNuuhRI/AAAAAAAAAJE/Y31uVLd97z8/s1600-h/P1020342.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SeojCNuuhRI/AAAAAAAAAJE/Y31uVLd97z8/s400/P1020342.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108030271390994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Obviously it was a little illegal, given that we're trespassing, but certainly the tripedation made it a little bit more exciting. Claire set up the tent while Alexandre and I started to look around for some wood to start a little campfire of our own. (When I recounted the story to an older guy later, he was curious where I got my firewood from - unbeknown my insanely dumb luck in retrospect, he was surprised that we managed to get some wood for burning; someone had left some strewn around when cutting down some overgrowth.)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SeojIXYd-bI/AAAAAAAAAJM/f66VDHM_PM4/s1600-h/P1020346.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SeojIXYd-bI/AAAAAAAAAJM/f66VDHM_PM4/s400/P1020346.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108135941601714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Spent the evening camping out with them, to which later they mentioned the fact that I had no place to stay. They had only a two-men tent, and didn't have any room for me, so I had go try my luck when they pointed out that there is a "Bed and Breakfast" somewhere adjacent to the street across the paddock. It just might be as well, to leave them some privacy to have some romantic personal time under the nice Irish moonlight. I think they did enjoy their camp there, but they did try their darn best not to make me feel left out by admitting to me about how cold the night was before, and that I must have had a better time living under a properly heated shelter.&lt;br /&gt;&lt;br /&gt;To me, living in a 'Bed &amp;amp; Breakfast' was a rather interesting experience . I had never lived in one before this, and certainly had no knowledge of the existence of such a concept. I had this mistaken idea that it was just another style of commercial hotelier gimmicks where they charge you extra by tagging breakfast to your bill compulsorily. Armed with this half-baked idea in my head, I was kind of worried when I made my approach to the residential property the BnB was signposted, and getting rather concerned that I won't be having a place to stay for the night.&lt;br /&gt;&lt;br /&gt;While the place did turn out to be a BnB, my lack of knowledge became even more of a comedy later when I was seated with the hostess in the living room for a rest when I remarked about how much the place resembled a family home, to which she responded in confusion, "but, aren't you looking for a Bed and Breakfast?" She would have gotten into bed that night confused, not only until the next morning would she have found out that I had absolutely no idea what I was in for when confessed that I thought I was going to be living in some funny-styled, breakfast-included hotel.&lt;br /&gt;&lt;br /&gt;The next Saturday morning past Good Friday turned out to be another glorious day, with the sun streaking above the country fields. I joined the couple once they got packed up and started on our way again:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SeojQsnMhHI/AAAAAAAAAJU/Q4c6OwdV8lY/s1600-h/P1020347.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SeojQsnMhHI/AAAAAAAAAJU/Q4c6OwdV8lY/s400/P1020347.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108279079470194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Even when one is outside a city, nobody can really escape into what is truly countryside anymore, as a helicopter hovered nearby in mid-air:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SeokI9JPxLI/AAAAAAAAAJ8/Co25q1WcGhY/s1600-h/P1020357.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SeokI9JPxLI/AAAAAAAAAJ8/Co25q1WcGhY/s400/P1020357.JPG" alt="" id="BLOGGER_PHOTO_ID_5326109245589931186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Glendalough was still a while away, and the French couple hitched their way there, while I was left to cycle in the vast country road in the early morning. It was an absolute bliss, all nice and serene, which is only irregularly punctured by a car whizzing through once in a while. And then I got to my intended destination:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SeolBaVw-UI/AAAAAAAAAKU/JT1q1KcyboY/s1600-h/P1020367.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 400px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SeolBaVw-UI/AAAAAAAAAKU/JT1q1KcyboY/s400/P1020367.JPG" alt="" id="BLOGGER_PHOTO_ID_5326110215499741506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Glendalough is like a nice national park, certainly reminded me of Yosemite, just a lot less crowded and commercial. If I had my way, I can certainly spend the remainder of my life here - if not only for this damn thing in life called 'work'!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_lSk990LIlbk/SeokQqOvmZI/AAAAAAAAAKE/aoG9aU8N-K4/s1600-h/P1020364.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_lSk990LIlbk/SeokQqOvmZI/AAAAAAAAAKE/aoG9aU8N-K4/s400/P1020364.JPG" alt="" id="BLOGGER_PHOTO_ID_5326109377951668626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Along the way, I got to know a few more friends - this is Fabio from Italy. I bumped into him along the way cycling. He and his mate happens to be heading towards the same direction as me, so I became the new party in their convoy. It's always fun to meet people from different cultures, you get to learn how very much people are different from you first hand. One of the early things I've come to learn ab0ut the Italians are they're rather fond of appending 'no' after their phrases, when they are actually wanting to mean 'yes' - talk about confusion!&lt;br /&gt;&lt;br /&gt;It was my good fortune to bump into them, as they had been instrumental in my return journey. I had no map, and had a lame-GPS that was running out of battery. Since they knew their way, and happen to be cycling their way back to Dublin, I decided to not push my luck any further, and tag along their return journey home.&lt;br /&gt;&lt;br /&gt;Along the way back, there's more of the lovely Irish countryside:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/Seojem4olmI/AAAAAAAAAJk/MbqFJ5kTqgQ/s1600-h/P1020352.JPG"&gt;&lt;img style="margin: 5px; cursor: pointer; width: 200px; height: 150px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/Seojem4olmI/AAAAAAAAAJk/MbqFJ5kTqgQ/s400/P1020352.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108518060168802" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/Seoj8r440jI/AAAAAAAAAJ0/9ssHfWSt39o/s1600-h/P1020354.JPG"&gt;&lt;img style="margin: 5px; cursor: pointer; width: 200px; height: 150px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/Seoj8r440jI/AAAAAAAAAJ0/9ssHfWSt39o/s400/P1020354.JPG" alt="" id="BLOGGER_PHOTO_ID_5326109034799485490" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_lSk990LIlbk/SeojnHTCcuI/AAAAAAAAAJs/LDpdkxxvsvA/s1600-h/P1020353.JPG"&gt;&lt;img style="margin: 5px; cursor: pointer; width: 200px; height: 150px;" src="http://3.bp.blogspot.com/_lSk990LIlbk/SeojnHTCcuI/AAAAAAAAAJs/LDpdkxxvsvA/s400/P1020353.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108664199803618" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_lSk990LIlbk/SeojWmxyLUI/AAAAAAAAAJc/z1E_xLZp7xg/s1600-h/P1020351.JPG"&gt;&lt;img style="margin: 5px; cursor: pointer; width: 200px; height: 150px;" src="http://1.bp.blogspot.com/_lSk990LIlbk/SeojWmxyLUI/AAAAAAAAAJc/z1E_xLZp7xg/s400/P1020351.JPG" alt="" id="BLOGGER_PHOTO_ID_5326108380592483650" border="0" /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;Sheep! The damn cutest thing in the whole wide world! Baaaaa!&lt;br /&gt;&lt;br /&gt;In the Chinese Almanac, I'm born in the year of the Sheep/Goat/Lamb (what's the difference?), maybe that explains why I have this weird sense of affection towards these cuddly little creatures. :)&lt;br /&gt;&lt;br /&gt;For an absolutely unplanned weekend, I must say the outcome has certainly been wildly positive. I can't believe my incredible luck I had for the couple of days - had a few firsts, made a few friends, and enjoyed an incredibly lovely weather for a country more renowned for cloudy, rainy weather - I must have had a 4-leafed clover stuck in the underside of my pants somewhere! So then, all that's left for me to do in this country is to catch some Leprechauns and find the pot of gold at the end of the rainbow! (Apologies to my Irish friends for such corny jokes ;p)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-6923016973416114730?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=tRRc9WnD2r0:160Wipsw5ls:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=tRRc9WnD2r0:160Wipsw5ls:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=tRRc9WnD2r0:160Wipsw5ls:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=tRRc9WnD2r0:160Wipsw5ls:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=tRRc9WnD2r0:160Wipsw5ls:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=tRRc9WnD2r0:160Wipsw5ls:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=tRRc9WnD2r0:160Wipsw5ls:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=tRRc9WnD2r0:160Wipsw5ls:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/tRRc9WnD2r0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/6923016973416114730/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/04/good-friday-it-is.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/6923016973416114730?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/6923016973416114730?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/tRRc9WnD2r0/good-friday-it-is.html" title="A Good Friday It Is!" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_lSk990LIlbk/SeojCNuuhRI/AAAAAAAAAJE/Y31uVLd97z8/s72-c/P1020342.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/04/good-friday-it-is.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAGQnk9fCp7ImA9WxVbEEg.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-895996715736811544</id><published>2009-03-26T02:10:00.000-07:00</published><updated>2009-03-26T02:12:03.764-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-26T02:12:03.764-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Personal Life" /><category scheme="http://www.blogger.com/atom/ns#" term="Philosophy" /><title>Happiness is ...</title><content type="html">Happiness is a warm steaming bowl of instant noodles&lt;br /&gt; when you are feeling cold and hungry.&lt;br /&gt;&lt;br /&gt;Happiness is a warm fuzzy feeling of a full tummy&lt;br /&gt; after a piping hot bowl of instant noodles.&lt;br /&gt;&lt;br /&gt;Sometimes happiness isn't too hard to attain after all :)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-895996715736811544?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=jd84UbbCI1Y:0UrHjrIynBM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=jd84UbbCI1Y:0UrHjrIynBM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=jd84UbbCI1Y:0UrHjrIynBM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=jd84UbbCI1Y:0UrHjrIynBM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=jd84UbbCI1Y:0UrHjrIynBM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=jd84UbbCI1Y:0UrHjrIynBM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=jd84UbbCI1Y:0UrHjrIynBM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=jd84UbbCI1Y:0UrHjrIynBM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/jd84UbbCI1Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/895996715736811544/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/03/happiness-is.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/895996715736811544?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/895996715736811544?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/jd84UbbCI1Y/happiness-is.html" title="Happiness is ..." /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/03/happiness-is.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8CQH87cSp7ImA9WxVXFU8.&quot;"><id>tag:blogger.com,1999:blog-6787189684621789552.post-3169496599334920715</id><published>2009-02-13T04:41:00.000-08:00</published><updated>2009-02-13T04:41:01.109-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-13T04:41:01.109-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Reanabling FCKEditor for MoinMoin Wiki</title><content type="html">&lt;span style="font-weight: bold;"&gt;The Costs of Free Software&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;FCKEditor, the rich text editor feature in MoinMoin wiki has been removed from the Debian/Ubuntu distributions from a decision the maintainer(s) made after notification of a security issue of enabling it. Obviously I wasn't the only person who &lt;a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=507081"&gt;got annoyed&lt;/a&gt; by its removal, given that the rich text editing feature has been the first place why many, like I, have used the wiki altogether.&lt;br /&gt;&lt;br /&gt;So even the 'free' as in 'freedom' in software turns out to be not so free anyway - given that I had no freedom in weighing my own pros and the cons of dealing with the potential security problem. For me, the answer is clear as day - the wiki is only used in a secured local area network and has no editing rights, not even reading rights to anybody outside the intranet - so why should anybody dictate that I can't use FCKEditor with MoinMoin?&lt;br /&gt;&lt;br /&gt;(No) thanks to them, this post wouldn't have existed if not for the shortsightedness in destroying the appeal of what otherwise would be an attractive software package. For all that FOSS is worth, it's main Achilles heel is certainly the lack of attention to the needs of end customers. That's why FOSS companies have to make their money out of service - because there is none!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How to Reanable FCKEditor for Debian/Ubuntu's MoinMoin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The workaround to using Debian/Ubuntu's version of MoinMoin is downloading the current version from the website and install it. Converting it to use your existing settings should be a relatively painless task.&lt;br /&gt;&lt;a href="http://moinmo.in/MoinMoinDownload"&gt;&lt;br /&gt;Download the package&lt;/a&gt; and install a local version of MoinMoin. Follow the same instructions as given on how to install as given in &lt;a href="http://moinmo.in/HelpOnInstalling/BasicInstallation"&gt;BasicInstallation&lt;/a&gt; section. I'll assume that you've installed it in &lt;code&gt;/usr/local/&lt;/code&gt; as was given in the example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;% python setup.py install --prefix='/usr/local' --record=install.log&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Using &lt;code&gt;/usr/local&lt;/code&gt; will separate the Debian/Ubuntu copy from your self installed copy.&lt;br /&gt;&lt;br /&gt;You can then proceed on to installing MoinMoin using the &lt;a href="https://help.ubuntu.com/7.04/server/C/moinmoin.html"&gt;same instructions from Ubuntu 7.04&lt;/a&gt; - the instructions are still valid, but the thing that you have to watch out is to remember to replace all references of &lt;code&gt;/usr/share/&lt;/code&gt; with &lt;code&gt;/usr/local/share&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;In addition, you will have to modify the &lt;code&gt;moin.cgi&lt;/code&gt; file. In downloaded version, it does not point to the &lt;code&gt;/etc/moin&lt;/code&gt; configuration path. In order to reuse your old configuration, add the following line in red into your &lt;code&gt;moin.cgi&lt;/code&gt; file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;#sys.path.insert(0, '/path/to/wikiconfigdir')&lt;br /&gt;#sys.path.insert(0, '/path/to/farmconfigdir')&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;sys.path.insert(0, '/etc/moin')&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This will make the wiki start reading from the &lt;code&gt;/etc/moin&lt;/code&gt; directory like your Debian/Ubuntu package does.&lt;br /&gt;&lt;br /&gt;Debian/Ubuntu has made further changes in the configuration to ensure you don't use the GUI editor, so you have to revert them back by adding or modifying the two lines your &lt;code&gt;/etc/moin/mywiki.py&lt;/code&gt; file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;strike&gt;# The GUI WYSISYG editor is not installed with Debian.&lt;br /&gt;# See /usr/share/doc/$(cdbs_curpkg)/README.Debian for more info&lt;br /&gt;editor_force = True&lt;br /&gt;editor_default = 'text'  # internal default, just for completeness&lt;br /&gt;&lt;/strike&gt;&lt;br /&gt;editor_force=False&lt;br /&gt;editor_default='gui'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Once the changes are made, restart apache, and FCKEditor should be reenabled again.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-7827109100899293";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_text = "000000";google_color_url = "008000";google_ui_features = "rc:6";//--&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6787189684621789552-3169496599334920715?l=blog.vinceliu.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=9FoVrD3SwEU:jmElMBuSv0o:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=9FoVrD3SwEU:jmElMBuSv0o:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=9FoVrD3SwEU:jmElMBuSv0o:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=9FoVrD3SwEU:jmElMBuSv0o:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=9FoVrD3SwEU:jmElMBuSv0o:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=9FoVrD3SwEU:jmElMBuSv0o:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/VincentLiu?a=9FoVrD3SwEU:jmElMBuSv0o:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/VincentLiu?i=9FoVrD3SwEU:jmElMBuSv0o:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/VincentLiu/~4/9FoVrD3SwEU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.vinceliu.com/feeds/3169496599334920715/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.vinceliu.com/2009/02/reanabling-fckeditor-for-moinmoin-wiki.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3169496599334920715?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6787189684621789552/posts/default/3169496599334920715?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VincentLiu/~3/9FoVrD3SwEU/reanabling-fckeditor-for-moinmoin-wiki.html" title="Reanabling FCKEditor for MoinMoin Wiki" /><author><name>Vincent Liu</name><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11478202932375690324" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.vinceliu.com/2009/02/reanabling-fckeditor-for-moinmoin-wiki.html</feedburner:origLink></entry></feed>
