<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2166377998926324011</id><updated>2011-11-28T01:31:11.107+01:00</updated><category term='WD MyBook'/><category term='MySQL'/><category term='Programming'/><title type='text'>Honza's perspective</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-4813576349306437955</id><published>2008-04-01T19:03:00.000+02:00</published><updated>2008-04-01T19:04:26.731+02:00</updated><title type='text'>Moved</title><content type='html'>&lt;p&gt;This blog has moved to &lt;a href="http://blog.stastnarodina.com/honza-en/"&gt;http://blog.stastnarodina.com/honza-en&lt;/a&gt; so redirect your RSS readers and enjoy reading.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-4813576349306437955?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/4813576349306437955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=4813576349306437955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/4813576349306437955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/4813576349306437955'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2008/04/moved.html' title='Moved'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-843803072934613729</id><published>2008-01-20T04:53:00.000+01:00</published><updated>2008-01-27T02:27:41.937+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><title type='text'>C++ round</title><content type='html'>&lt;p&gt;&lt;em&gt;27th January &lt;strong&gt;Update&lt;/strong&gt;:&lt;/em&gt;
as somebody has pointed via email (thanks for that), the function I gave only worked for positive numbers. This is the solution he offered (altered a bit not to give warnings so that you can cut&amp;paste ):
&lt;pre&gt;
#include &amp;lt;cmath&amp;gt;
int function round(double num) {
  char sign = static_cast&lt;char&gt;(num/fabs(num));
  return static_cast&amp;lt;int&amp;gt;(sign* (fabs(num)+ 0.5));
}
&lt;/pre&gt;
&lt;/p&gt;
Actually, the solution I gave first (and then suddenly changed it to the one that only works for positive number...) worked perfectly with both positive and negative too. This is it:
&lt;pre&gt;
#include &amp;lt;cmath&amp;gt;
int function round(double num) {
  return static_cast&amp;lt;int&amp;gt;(floor(num+0.5));
}
&lt;/pre&gt;

&lt;/p&gt;
&lt;p&gt;
I was a bit shocked first, finding out there was no &lt;em&gt;round&lt;/em&gt; function in C++.&lt;br /&gt;
It didn't fortunately take me long to google a nice substitute for it. It can be as simple as this (&lt;strong&gt;Warning:&lt;/strong&gt; this works for positive numbers only. See above for better solution):&lt;br /&gt;
&lt;pre&gt;
int round(double num) {
 return (int)(num+0.5);
}
&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;
I may be one of the more dumb and lazy programmers (isn't "laziness" in the flag of all programmers?), but I would expect a function like that to be a part of a modern language. Yes, it didn't take me long to google it (unlike some other C++ problems, which can take hours), but no googling is faster than short googling, isn't it?
&lt;/p&gt;
&lt;p&gt;
I think it is worth seeing, what &lt;a href="http://java.sun.com/"&gt;The Others&lt;/a&gt; &lt;a href="http://java.sun.com/javase/6/docs/api/java/lang/Math.html"&gt;offer&lt;/a&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-843803072934613729?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/843803072934613729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=843803072934613729' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/843803072934613729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/843803072934613729'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2008/01/c-round.html' title='C++ round'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-5776833443457981836</id><published>2008-01-12T12:35:00.000+01:00</published><updated>2008-01-12T13:03:54.434+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WD MyBook'/><title type='text'>WD MyBook useful links</title><content type='html'>&lt;h4&gt;System upgrade&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://mybookworld.wikidot.com/"&gt;Hacking WD MyBook at wikidot&lt;/a&gt; – Center of most of the WD hacks&lt;/li&gt;&lt;li&gt;&lt;a href="http://martin.hinner.info/mybook/"&gt;Martin Hinner's guide on enabling SSH&lt;/a&gt;  – Enable SSH on the original configuration WD MyBook. There are some precompiled packages such as vsftpd on his site too.&lt;/li&gt;&lt;li&gt;&lt;a href="http://kyyhkynen.net/stuff/mybook/spindown.php"&gt;Smart Spindown for WD MyBook&lt;/a&gt; – Save some energy by spinning the HDD down.&lt;/li&gt;&lt;/ul&gt;
&lt;h4&gt;When things break&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="http://mybookworld.wikidot.com/rescue-procedure"&gt;Restore the original system&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;(Advanced only) &lt;a href="http://www.ismprofessional.net/pascucci/documenti/mybook/mybook-hacking-en.html"&gt;Install Debian Lenny&lt;/a&gt; – both rescue and upgrade procedure&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-5776833443457981836?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/5776833443457981836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=5776833443457981836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/5776833443457981836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/5776833443457981836'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2008/01/wd-mybook-useful-links.html' title='WD MyBook useful links'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-5687177908366846430</id><published>2008-01-10T12:06:00.000+01:00</published><updated>2008-01-14T04:06:51.228+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WD MyBook'/><title type='text'>WD My Book Debian Lenny -- Samba</title><content type='html'>&lt;p&gt;I have recently installed Debian Lenny to my Western Digital My Book. All thanks to great guide at &lt;a href="http://www.ismprofessional.net/pascucci/documenti/mybook/mybook-hacking-en.html"&gt;Mario Pascucci's site&lt;/a&gt; (big thanks!)

A commented version with some other details can be found at &lt;a href="http://mybookworld.wikidot.com/forum/t-30649/my-fast-and-perfect-setup-of-debian-lenny-into-my-500gb-world-book"&gt;Hacking  WD MyBook World Ed site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The system installed is full-fledged version of testing version (called lenny) of Debian, so one can use use apt-get to install packages the same way as at PC (providing you use a &lt;a href="http://www.debian.org/mirror/list"&gt;packages mirror&lt;/a&gt;, that serves arm architecture). Having successfully installed FTP (vsftpd), htop, gcc, and others, I also wanted to install Samba (as the most important part of such a device).&lt;/p&gt;

&lt;p&gt;I was fighting with Samba at MyBook for more than two days (and nights). The problem was that it didn't want to list the shares at the server. The problem in the end was that there is a &lt;a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=445566"&gt;bug&lt;/a&gt; in Debian samba package  version 3.0.28-1-- current testing (lenny) version, which has something to do with arm compiler -- if you download Samba source code and compile it yourself without additional parameter -O0, the result will be the same as with the samba Debian package.&lt;/p&gt;

&lt;p&gt;The bug has already been fixed in 3.0.28-2. This version is not in testing (lenny) yet, but you can manually download the current versions from
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Samba common &lt;a href="http://http.us.debian.org/debian/pool/main/s/samba/samba-common_3.0.28-2_arm.deb"&gt;http://http.us.debian.org/debian/pool/main/s/samba/samba-common_3.0.28-2_arm.deb&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;Samba &lt;a href="http://http.us.debian.org/debian/pool/main/s/samba/samba_3.0.28-2_arm.deb"&gt;http://http.us.debian.org/debian/pool/main/s/samba/samba_3.0.28-2_arm.deb&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;To install it do as root:&lt;br /&gt;

&lt;code&gt;
cd /tmp&lt;br /&gt;
wget http://http.us.debian.org/debian/pool/main/s/samba/samba-common_3.0.28-2_arm.deb&lt;br /&gt;
wget http://http.us.debian.org/debian/pool/main/s/samba/samba_3.0.28-2_arm.deb&lt;br /&gt;
dpkg --install samba-common_3.0.28-2_arm.deb&lt;br /&gt;
dpkg --install samba_3.0.28-2_arm.deb&lt;br /&gt;
rm samba-common_3.0.28-2_arm.deb samba_3.0.28-2_arm.deb&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;

&lt;p&gt;Another way is to add sid deb sources to you &lt;code&gt;/etc/apt/sources.list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I hope that this can make somebody's fight shorter than two days...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-5687177908366846430?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/5687177908366846430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=5687177908366846430' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/5687177908366846430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/5687177908366846430'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2008/01/wd-my-book-debian-lenny-samba.html' title='WD My Book Debian Lenny -- Samba'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-108654095374480454</id><published>2007-11-11T18:09:00.000+01:00</published><updated>2008-12-10T14:40:50.170+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WD MyBook'/><title type='text'>How to open Western Digital My Book World Edition</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jAlz_CGnVQY/RzdILuyhAHI/AAAAAAAAAfw/M0Mcpz9svZw/s1600-h/PB110050.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://1.bp.blogspot.com/_jAlz_CGnVQY/RzdILuyhAHI/AAAAAAAAAfw/M0Mcpz9svZw/s200/PB110050.JPG" alt="" id="BLOGGER_PHOTO_ID_5131649666787639410" border="0" /&gt;&lt;/a&gt;There are few guides on how to dismantle Western Digital My Book World Edition (500 GB) available online. (see &lt;a href="http://rebootdaily.blogspot.com/2007/03/how-to-open-western-digital-my-book.html"&gt;here&lt;/a&gt; or  &lt;a href="http://www.ransackery.com/western-digital-mybook-open-case-recover-data.htm"&gt;here&lt;/a&gt;).
&lt;br /&gt;&lt;br /&gt;
Just for those who have the new model (white with rubber around it):
&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;There is no screw in the cover&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;You need to remove the rubber before you try to slide the cover.
&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-108654095374480454?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/108654095374480454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=108654095374480454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/108654095374480454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/108654095374480454'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2007/11/how-to-open-western-digital-my-book.html' title='How to open Western Digital My Book World Edition'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_jAlz_CGnVQY/RzdILuyhAHI/AAAAAAAAAfw/M0Mcpz9svZw/s72-c/PB110050.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2166377998926324011.post-8785745535338572142</id><published>2007-09-24T18:55:00.000+02:00</published><updated>2008-01-12T13:02:07.180+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><title type='text'>Mysterious MySQL</title><content type='html'>&lt;span style="font-style:italic;"&gt;Česká verze tohoto zápisku dostupná &lt;a href="http://honza-stastny.blogspot.com/2007/09/tajupln-mysql.html"&gt;zde&lt;/a&gt;&lt;/span&gt;
&lt;br /&gt;&lt;br /&gt;
MySQL can be sometimes pretty surprising.&lt;br /&gt;
I have recently encountered this thing:&lt;br /&gt;
I have this SQL query:&lt;br /&gt;
&lt;code&gt;
SELECT id, username, locked, c.*, (SELECT COUNT(*) FROM web_login_users WHERE user=id AND (NOW()-last_action)&lt;600) AS login_count FROM web_users LEFT JOIN web_user_information AS c ON (id=user)
&lt;/code&gt;&lt;br /&gt;
It works without any problems and the returned column set includes the column named &lt;strong&gt;login_count&lt;/strong&gt;.&lt;br /&gt;
I wanted to get only the rows, where login_count is greater than 1. I intuitively tried this:&lt;br /&gt;
&lt;code&gt;
SELECT id, username, locked, c.*, (SELECT COUNT(*) FROM web_login_users WHERE user=id AND (NOW()-last_action)&lt;600) as login_count FROM web_users LEFT JOIN web_user_information AS c ON (id=user) WHERE login_count &gt; 1
&lt;/code&gt;&lt;br /&gt;
This does't work. MySQL complains about not knowing the login_count column.
To make it more interesting, this will work as expected:&lt;br /&gt;
&lt;code&gt;
SELECT id, username, locked, c.*, (SELECT COUNT(*) FROM web_login_users WHERE user=id AND (NOW()-last_action)&lt;600) AS login_count FROM web_users LEFT JOIN web_user_information AS c ON (id=user) ORDER BY login_count
&lt;/code&gt;&lt;br /&gt;
&lt;strike&gt;Some JOIN workaround will probably be needed.&lt;/strike&gt;&lt;br /&gt;
Having made some more attempts and consulted the problem with a friend, I give up.&lt;br /&gt;
This is the JOIN version that I quite expected to work:&lt;br /&gt;
&lt;code&gt;
SELECT id, username, locked, c.*, COUNT(login_users.user) AS login_count FROM web_users LEFT JOIN web_user_information AS c ON (id=user) LEFT OUTER JOIN web_login_users AS login_users ON (user=id AND (NOW()-last_action)&lt;600) WHERE login_count &gt; 0
&lt;/code&gt;&lt;br /&gt;
It returns the same error as the previous attempts (Unknown column 'login_count' in 'where clause').&lt;br /&gt;

I don't quite like this version, but it functions well:&lt;br /&gt;
&lt;code&gt;
SELECT id, username, locked, c.*, (SELECT COUNT(*) FROM web_login_users WHERE user=id AND (NOW()-last_action)&lt;600) AS login_count FROM web_users LEFT JOIN web_user_information AS c ON (id=user) WHERE (SELECT COUNT(*) FROM web_login_users WHERE user=id AND (NOW()-last_action)&lt;600) &gt; 0
&lt;/code&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2166377998926324011-8785745535338572142?l=honza-stastny-en.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honza-stastny-en.blogspot.com/feeds/8785745535338572142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2166377998926324011&amp;postID=8785745535338572142' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/8785745535338572142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2166377998926324011/posts/default/8785745535338572142'/><link rel='alternate' type='text/html' href='http://honza-stastny-en.blogspot.com/2007/09/mysterious-mysql.html' title='Mysterious MySQL'/><author><name>Honza</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://2.bp.blogspot.com/_jAlz_CGnVQY/SQXZngzYQKI/AAAAAAAACKE/jONrum5vDMA/S220/svatba.jpg'/></author><thr:total>0</thr:total></entry></feed>
