<?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-4694652045435723378</id><updated>2011-11-28T03:51:56.135+04:00</updated><category term='linux'/><category term='bittorrent'/><category term='packages'/><category term='sad'/><category term='snippet'/><category term='advice'/><category term='p2p'/><category term='ntfs'/><category term='3d'/><category term='security'/><category term='howto'/><category term='programming'/><category term='argue'/><category term='forums'/><category term='sdl'/><category term='piracy'/><category term='games'/><category term='philosophy'/><category term='computers'/><category term='life'/><category term='time'/><category term='C++'/><category term='source'/><category term='firefox'/><category term='slackware'/><category term='existence'/><category term='criticism'/><category term='opengl'/><category term='opensource'/><category term='time-management'/><category term='python'/><category term='utf8'/><category term='thoughts'/><category term='internet'/><category term='script'/><category term='self-improvement'/><category term='windows'/><category term='compiling'/><category term='laws'/><category term='stl'/><category term='password'/><category term='rant'/><category term='generate'/><category term='backup'/><title type='text'>Alt+Ctrl+Backspace</title><subtitle type='html'>Various bits of code and random thoughts</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-5913945707468647888</id><published>2009-11-25T01:18:00.004+03:00</published><updated>2009-11-25T02:01:57.927+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rant'/><category scheme='http://www.blogger.com/atom/ns#' term='computers'/><category scheme='http://www.blogger.com/atom/ns#' term='ntfs'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Sometimes I hate Windows.</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Surely, &lt;a href="http://altctrlbackspace.blogspot.com/2009_04_01_archive.html"&gt;every OS has strong and weak points&lt;/a&gt; (I'm still using windows/linux dual-boot), but when something breaks for absolutely no reason, it is never funny.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Today I was supposed to spent a lot of time programming windows software. Unfortunately, at one point I had to reboot the system, and after reboot system went to hell.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;For some reason, my network adapters disappeared from &amp;quot;Network Connections&amp;quot; folder (although they were still working), I couldn't start VPN connection anymore, connection sharing broke up, and shortly after startup I was greeted by message telling me that RPC could not start, and system will shutdown in 60 seconds. &amp;quot;Last working configuration&amp;quot; (F8 at the boot time) didn't help either, and of course I disabled system restore on all drives few months ago. System CD was lost too, although I still had copy of installation files.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Investigation (My Computer-&amp;gt;Manage-&amp;gt;Event Viewer) uncovered dozens of errors in system logs:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Event ID: 4609&lt;br&gt;&lt;br /&gt;The COM+ Event System detected a bad return code during its internal processing.  HRESULT was 800706BA from line 44 of f:\xpsp3\com\com1x\src\events\tier1\eventsystemobj.cpp.&lt;br /&gt;&lt;li&gt;Event ID: 8193&lt;br&gt;&lt;br /&gt;Volume Shadow Copy Service error: Unexpected error calling routine CoCreateInstance.  hr = 0x80040206.&lt;br /&gt;&lt;li&gt;Event ID: 1802&lt;br&gt;&lt;br /&gt;The Windows Security Center Service was unable to establish event queries with WMI to monitor third party AntiVirus and Firewall.&lt;br /&gt;&lt;li&gt;Event ID: 7023&lt;br&gt;&lt;br /&gt;The Windows Firewall/Internet Connection Sharing (ICS) service terminated with the following error: &lt;br /&gt;The handle is invalid. &lt;br /&gt;&lt;li&gt;Event ID: 7023&lt;br&gt;&lt;br /&gt;The Security Center service terminated with the following error: &lt;br /&gt;The endpoint mapper database entry could not be created. &lt;br /&gt;&lt;li&gt;Event ID: 7034&lt;br&gt;&lt;br /&gt;The Remote Procedure Call (RPC) service terminated unexpectedly.  It has done this 1 time(s).&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;At first it looked as MsBlast virus comeback, but virus checking tool made by symantek didn't find the virus, and that vulnerability have been fixed long time ago.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;in the end it looked like everything was tied to COM+ and access rights. Somehow access rights on %windir%\restore has been reset to &amp;quot;no access to anyone&amp;quot; and COM+ services couldn't start, but of course fixing access rights didn't fix the problem. Then I searched for instruction on reinstalling/resetting COM+ (google for &amp;quot;reinstall COM+&amp;quot; and you will find them yourself). There were couple of instructions but none fixed my problem. Error messages changed to&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Event ID: 4689&lt;br&gt;&lt;br /&gt;The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, or other factors. Error in f:\xpsp3\com\com1x\src\comsvcs\events\lcedisp.cpp(131), hr = 80040206: Failed to CoCreate EventSystem object.&lt;br /&gt;&lt;li&gt;Event ID: 7000&lt;br&gt;&lt;br /&gt;The COM+ System Application service failed to start due to the following error: &lt;br /&gt;The service did not respond to the start or control request in a timely fashion. &lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Somehow I managed to make my NICs visible again, but this didn't make VPN work.&lt;br /&gt;I also tried to monitor processes with processmonitor (to find broken privilegies or missing files), but it quickly become evident that processmonitor is no match for strace/ptrace available on Linux. I was unable to reinstall COM+ completely, because of &amp;quot;Sub-component COM+ raised an exception while processing the OC_COMPLETE_INSTALLATION setup message&amp;quot; error.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In the end, after several hours of googling, swearing, and numerous failed attempt to fix the system, when I was about to give up and initiate full system reinstall, I finally remembered that system was transferred from older harddrive only week ago, and old system partition wasn't overwritten yet. A quick boot into Slackware Linux, &lt;a href="http://man.linux-ntfs.org/ntfsclone.8.html"&gt;ntfsclone&lt;/a&gt;+&lt;a href="http://man.linux-ntfs.org/ntfsresize.8.html"&gt;ntfsresize&lt;/a&gt;, and voila, I had working system again. &lt;br /&gt;&lt;p&gt;&lt;br /&gt;Why all this stuff happened, still remains a mystery to me.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;My advice: if you ever encounter similar problem, and if you were unable to fix it in 30 minutes, forget about it, and do full reinstall. You'll waste less time. It also makes sense to keep system restore enabled, and backup system at least sometimes (nothing beats backup, even search engine). NTFS backup can be easily done from linux system, see &amp;quot;&lt;a href="http://man.linux-ntfs.org/ntfsclone.8.html"&gt;ntfsclone manual&lt;/a&gt;&amp;quot; for more info. &lt;br /&gt;&lt;p&gt;&lt;br /&gt;Links I've been using while trying to fix the system:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://support.microsoft.com/kb/315296"&gt;How to clean up a damaged COM+ catalog&lt;/a&gt; on microsoft.com&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.tek-tips.com/viewthread.cfm?qid=758414"&gt;Reinstall COM+&lt;/a&gt; forum discussion.&lt;br /&gt;&lt;li&gt;&lt;a href="http://support.microsoft.com/kb/916254"&gt;COM+-related events may be logged in Event Viewer when you install Windows XP Service Pack 2 and join the computer to a domain&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.symantec.com/security_response/writeup.jsp?docid=2003-081119-5051-99"&gt;W32.Blaster.Worm Removal Tool&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://linux-ntfs.org/doku.php"&gt;Linux-NTFS wiki&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;a href=""&gt;Linux-NTFS&lt;/a&gt; manpages.&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-5913945707468647888?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/5913945707468647888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/11/sometimes-i-hate-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5913945707468647888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5913945707468647888'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/11/sometimes-i-hate-windows.html' title='Sometimes I hate Windows.'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-1566070459261571722</id><published>2009-10-29T01:38:00.007+03:00</published><updated>2009-11-19T21:18:39.184+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='howto'/><category scheme='http://www.blogger.com/atom/ns#' term='argue'/><category scheme='http://www.blogger.com/atom/ns#' term='life'/><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><category scheme='http://www.blogger.com/atom/ns#' term='advice'/><title type='text'>How to argue on the Internet</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h3&gt;Rule #1:&lt;/h3&gt;&lt;br /&gt;&lt;i&gt;Do not argue on the internet, unless you absolutely have to, or unless you know your opponent personally. (or unless you are a troll)&lt;/i&gt;.&lt;p&gt; &lt;br /&gt;&lt;br /&gt;Why? Because:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; Unless you know your opponent personally, you will be trying to prove your point to a stranger you probably won't ever meet. In general, no matter whether you win or lose, nothing will change. &lt;br /&gt;&lt;li&gt; Writing takes time. A lot of time. Good, cold-blooded, intelligent argument, supported by research (or at least by the Google search) might take from 30 minutes to a few hours to finish, even if you are typing 400 characters per second. In general, your time isn't worth the result - you in most cases you won't get satisfaction, even if you &amp;quot;win&amp;quot;. Also, eventually someone else will join the discussion without reading your arguments first. So it will be a waste of time.&lt;br /&gt;&lt;li&gt; Arguing sometimes takes emotions. If discussion becomes &amp;quot;heated&amp;quot;, you might start to feel angry, etc. This also isn't worth the result.&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Exceptions from rule:&lt;br /&gt;It makes sense to argue, if one of following conditions applies:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Your life is directly affected by result of argument.&lt;br /&gt;&lt;li&gt;You have warranty that your opponent(s) is sane, is not a troll, and can provide good arguments.&lt;br /&gt;&lt;li&gt;You truly enjoy the process.&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Of course, it is easy to say &amp;quot;do not argue&amp;quot;, but how to deal with annoying/insane arguments? Here goes &lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;h3&gt;Rule #2&lt;/h3&gt;&lt;br /&gt;&lt;i&gt;Add &amp;quot;I think&amp;quot; (&amp;quot;He/She thinks&amp;quot;) in front of opponent's arguments before reading them.&lt;/i&gt; &lt;br /&gt;&lt;p&gt;&lt;br /&gt;Why? &lt;br /&gt;&lt;p&gt;&lt;br /&gt;Because every argument on the Internet is an opinion. However, people very frequently forget to mention (by adding &amp;quot;IMHO&amp;quot;) that what they write is merely their opinion. And some unique individuals will truly believe that what they think is some kind of absolute truth. The problem is that when you see something outrageous that doesn't fit what you know/believe in, and this thing presented as a fact (or some kind of absolute truth), your brain (mine, at least) for some reason wants to prove that your point of view is right, and this argument is not. However, for some reason, opinions of other people are easier to dismiss/ignore than something that is presented as a fact.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;How to use it (example):&lt;br /&gt;&lt;p&gt;&lt;br /&gt;You log into forum. The user XYZ posted a message saying (keep in mind, this is just an example) &amp;quot;The universe was created by a big purple pipe-smoking rabbit with a pitchfork!&amp;quot; Now, it doesn't fit your religious beliefs and makes you enraged (keep in mind, it is still an example). Before starting a flamewar, add &amp;quot;I think that&amp;quot; in front of original sentence, and read it again. Now the message turns into &amp;quot;I think that the universe was created by a big purple pipe-smoking rabbit with a pitchfork!&amp;quot;. Now for some reason it doesn't feel enraging, because If this dude thinks so, it is his problem with his head, opinion of some random dude (you never met) doesn't matter for you, and he will not be able to provide interesting discussion anyway. So you ignore this guy, and move on instead of wasting next hours in flamewar. &lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;h3&gt;Rule #3&lt;/h3&gt;&lt;br /&gt;&lt;i&gt;Avoid discussions about religion at all costs&lt;/i&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Why? Because:&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Faith frequently blinds people, and makes them think they are right affects both atheists and believers) and their opponents are not.  There are very few(less than 1% of population, I think) people that can easily analyze/and change their beliefs when they are trying to prove they are right. During my life I never saw any religious that didn't end in flamewar. I also don't remember anyone in such discussion ever convincing someone else. So, in general, it will be a waste of time (unless you are troll, of course). Of course, there are always nice people that calmly follow their religion (or atheism) and don't bother anyone. However they normally don't have a need to participate in discussions about religion.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;h3&gt;Rule #4&lt;/h3&gt;&lt;br /&gt;&lt;i&gt;Unless you are dealing with science, any opinion (including yours) can be wrong and is not a universal truth&lt;/i&gt; Best applied to discussions about religion, in case you skipped Rule #3.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Why? Because:&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Imagine that you live in a city and know that population of your town is 5000000. The problem here is that you do not &lt;b&gt;know&lt;/b&gt;, but &lt;b&gt;believe&lt;/b&gt; that population is around 5000000 people. This is because information about size of population was given to you by some kind of authority you trust(which is supposed to provide correct information), and you cannot really verify number of people yourself. If this authority gave you invalid information, your knowledge about city population will be invalid. The problem here is that nearly everything you know comes from some kind of trusted authority. Perhaps you never been to South Pole, but you believe that it exists, because someone told you so. The bigger problem is that first trusted authorities you use are your senses. So if you think about it, entire world around you could be an illusion or result of your imagination, without any way to be absolutely sure that anything besides you is real (that's where &amp;quot;Cogito ergo sum&amp;quot; comes from). If we skip philosophy part, and return to simpler terms, this means that both you and your opponent most likely have incomplete or invalid information about the subject. For example, you or your opponent may refer to online resource that is not guaranteed to have valid information, and so on. Yes, it is possible to at least try to make sure that your information is valid, and trace/verify all sources you are using, but people rarely do it. So it makes sense to keep in mind that anyone can be wrong. And if you want to make things more fun, add Murphy's law to that (&amp;quot;Anything that can go wrong will go wrong.&amp;quot;), which will mean that in any discussion is probably wrong at one place or another.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;h3&gt;Rule #5&lt;/h3&gt;&lt;br /&gt;&lt;i&gt;Remember that you don't have to agree with someone.&lt;/i&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Why? Because:&lt;br /&gt;&lt;p&gt;&lt;br /&gt;There are many people in the world, and they all have different opinions, believe in different things, follow different religions, etc. And there is no absolute, universal truth, at least it isn't easily accessible. It is not possible make everyone agree, and it is not necessary. It makes sense to argue in situation when something serious depends on result - life of millions, perhaps. Clearly most Internet arguments and flamewars doesn't qualify as such situations, so participating in them is nearly always a waste of time (well, unless you are a troll and enjoy provoking other people). In most cases it is perfectly fine to disagree with anyone, as long as your position looks valid to yourself. And it makes sense to ignore &amp;quot;incorrect&amp;quot; opinions of other people, unless your life (or life or friends, relatives, etc) is directly affected by them. It makes sense, because people&lt;br /&gt;don't like being told that they are wrong, proving something to someone takes time, and doesn't always provide useful result.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;End of article.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Hope this helps someone.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-1566070459261571722?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/1566070459261571722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/10/how-to-argue-on-internet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1566070459261571722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1566070459261571722'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/10/how-to-argue-on-internet.html' title='How to argue on the Internet'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-5509104425565158891</id><published>2009-09-30T12:38:00.003+04:00</published><updated>2009-09-30T14:52:43.528+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='games'/><category scheme='http://www.blogger.com/atom/ns#' term='computers'/><category scheme='http://www.blogger.com/atom/ns#' term='bittorrent'/><category scheme='http://www.blogger.com/atom/ns#' term='piracy'/><category scheme='http://www.blogger.com/atom/ns#' term='p2p'/><category scheme='http://www.blogger.com/atom/ns#' term='laws'/><title type='text'>Computer piracy: common myths, and how copyright laws should be working</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;Intro&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Recently I saw some old thread on ign or gamespot, where someone told people that he uses pirated game. Immediately a flamewar erupted, with standard pro/anti-piracy argument :"you should be paying game developers!", "why should I be paying for something I can get free?", "piracy is theft!", "no it is not a theft", etc.&lt;br /&gt;&lt;br /&gt;I'm sick of such arguments, because they are based on mistakes and misconceptions.&lt;br /&gt;So I've decided to write a small list of "standard" arguments, explain why (I think) they are wrong, how I think copyright should be working, and why it is not going to happen.&lt;br /&gt;&lt;br /&gt;Everything written here is my personal opinion.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;Standard pro/anti-piracy arguments and why they are wrong&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;&amp;quot;Piracy is a theft!&amp;quot;&lt;/b&gt;&lt;br /&gt;&lt;p&gt;This one is most often discussed. If you do a little google search about &lt;i&gt;piracy theft&lt;/i&gt;, you'll probably find a lot of blog posts explaining why it is not a theft. Many of them will make sense(&lt;a href="http://frem.wordpress.com/2006/01/17/is-piracy-theft/"&gt;this one&lt;/a&gt;, for example), and some are even written by people that were interesting in things other than legalizing piracy. &lt;br /&gt;&lt;p&gt;&lt;br /&gt;I have to disappoint moralists, saying that &amp;quot;piracy is theft, which is why it is bad&amp;quot; - piracy is not a theft, it is &lt;i&gt;copyright infringement&lt;/i&gt; or &lt;i&gt;copyright violation&lt;/i&gt; (read wikipedia, or your local laws). It was already explained one billion times, but let's explain it once again (to keep all argument within this article).&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Theft is when you take someone's property, and after that owner doesn't have access to that property anywhere. This is a critical part of &amp;quot;theft&amp;quot;. I.e. if you take item from the shop without paying, and shop can't sell that item anymore, then it is theft. However, when you copy material (be it music, movie or game), owner still has access to original media, and still can sell endless number of copies. So, because owner doesn't lose access to the property, it is not a theft. However, it is still &lt;i&gt;copyright violation&lt;/i&gt;.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In case of theft, stolen object doesn't have to be material. If you steal someone's email password, or if you log into online game, and steal someone's item, it is stell theft (although laws most likely will classify that as hacking/unathorized access). Same thing happens if you take someone's serial number/registration info and delete all trace of that information on victim's computer. &lt;br /&gt;&lt;p&gt;&lt;br /&gt;The reason why you keep hearing that &amp;quot;piracy is theft&amp;quot; is because someone wants you to feel guilty for pirating stuff. Although this is a fine goal (since people in general will feel less guilt about pirating than they will feel about stealing something), it is a lie.&lt;br /&gt;&lt;li&gt;&lt;b&gt;&amp;quot;If it isn't theft, then it isn't bad!&amp;quot;&lt;/b&gt;&lt;br /&gt;&lt;p&gt; This one is never said in the open, but is probably by at least half of people that keep saying that "piracy is not a theft". Theft or not, it is still &lt;i&gt;illegal&lt;/i&gt;. It is much simpler to keep words &amp;quot;good&amp;quot; and &amp;quot;bad&amp;quot;(and &amp;quot;right&amp;quot;/&amp;quot;wrong&amp;quot;) away, and simply concentrate on &amp;quot;legal&amp;quot; and &amp;quot;illegal&amp;quot;. This is because everyone has slightly different definition of &amp;quot;good&amp;quot; and &amp;quot;bad&amp;quot; while legality of something is defined by your laws which are at least supposed to be impossible to misinterpret. So if you still want to pirate something, keep in mind, that no matter whether you think it is &amp;quot;right&amp;quot; or &amp;quot;wrong&amp;quot; thing to do, it is still &lt;i&gt;illegal&lt;/i&gt;, which means you might get your punishment eventually.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The sad thing about this is that sometimes people that already bought computer game or movie (this problem doesn't affect music) have also to get pirated copy because of some problem with the game. To my experience, normally publisher is responsible for that. Some examples:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;If the game or movie is localized and original game/movie was not in your language, then publisher might remove original soundtrack and/or text. Which means (if you know original language of the game), you will have to either to pirate original (because translation is never perfect), or tolerate bad acting and/or bad translation. The one nice example of this situation is &amp;quot;Witcher&amp;quot; computer game. The game had 3 versions: Polish, Russian, and English. Polish version had best voice acting. Russian had best translation, and worst voice acting. And Englih had mediocre voice acting and worst english translation (translators simply cut 50..75% of original material). Great, isn't it? Why is it that difficult to keep original soundtrack is beyond me. After all, we have DVD9 (not to mention bluray( at the moment.&lt;br /&gt;&lt;li&gt;The game has some kind of copy protection mechanism that doesn't work on user's computer. In this case user might be forced to buy game and then pirate it in order to play it. I know at least a few publishers that remove SECUROM and replace it with Starforce during localization. While (non disk-based)securom is pretty tame copy-protection mechanism(never had a single problem with my Spore), the destiny of starforce is to chew your CD/DVD to death, so you will have to buy game again. Also it is very picky and I heard more than one story about it causing BSODs.&lt;br /&gt;&lt;li&gt;The game has serious disk-based copy-protection, so user is unable to create a backup. In this case user will probably have to bypass copy protection mechanism in order to keep disk playable. Online authorization (steam, securom) is much better than disk-based protection, however you have no warranty that servers will exist forever. Will steam servers still exist 50 years later? I don't know, but it looks unrealistic.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;If you pay for your game/movie, you give money to developers!&amp;quot;&lt;br /&gt;&lt;p&gt;This one is the funniest from all arguments. &lt;br /&gt;&lt;p&gt;I do not know how cash flows in music, industry, but I worked as a hired programmer on few games, so I have at least brief idea how cash works in game industry. &lt;br /&gt;&lt;p&gt;The cold truth that whether original game developer gets any money you gratuitously paid for the game depends on how they manage royalties. There are no warranties. &lt;br /&gt;&lt;p&gt;&lt;br /&gt;At least some people won't get a dime from your money - because they were hired, paid by hour and won't get additional payment once development is over. There always will be one person that won't get your cash. Perhaps lead designer or lead programmer gets a cut from all the cash. Fine. But what about all the testers? Tool programmers? All artists? Motion capture actors? The janitor (yeah, he/she is also responsible for the game development)? Do they all get a cut from profits? I seriously doubt that. Most of those folks probably won't get any extra cash once development is over.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Indie developer probably will get good portion of money, minus commission paid to reseller - because they might be selling stuff nearly directly. As for larger companies, this needs investigation (see &lt;a href="http://www.devmaster.net/forums/archive/index.php/t-1811.html"&gt;this thread&lt;/a&gt; for more info, for example). There are couple of ways how publisher could acquire game right. Publisher could buy all rights (so game developers won't get your extra money), some of them might pay royalties, but this is not warrantied. Also keep in mind, that sometimes games are still sold when developer is long gone (example: Fallout 2, old games in general). Who is getting your money? The publisher.&lt;br /&gt;&lt;p&gt;Same is probably true for the movie industry. Can you imagine camera man getting royalties for new Hollywood blockbuster? I cannot. Perhaps in music industry situation is different, but I do not know that for sure.&lt;br /&gt;&lt;p&gt;There is always creator/developer who creates stuff and publisher who sells you the stuff. If they are same person/company, then you are lucky. And if they are not - then it is unclear whether creator gets anything from cash you gave or not. However thinking that all your cash goes straight to the developer is lying to yourself.&lt;br /&gt;&lt;p&gt;The situation might be better for companies that develop software (not games), because they might be selling it themselves. However, in this case some developers probably still won't get a dime from your money. Certain large companies are famous for buying right for piece of software from other companies, and then selling it to end users. In this case original developer not getting anything from your cash.&lt;br /&gt;&lt;li&gt;&amp;quot;More cash means better games&amp;quot;&lt;br /&gt;&lt;p&gt;It is a bit unrelated to to piracy, but I had to mention it anyway. For some strange reason, when (game) developer starts its' journey to the top, they create classics (example: Doom 1), but once they are well-known, well-paid and have tons of cash, situation sometimes changes and instead of quality product, they start aiming at larger audiences. This result in good graphics and bad gameplay. This is how (I think) we got boxes with unlimited ammo in first-person shooters, regenerating health, and enemies that scream at you to indicate where they are. This is how games from being a challenge turned into popular entertainment, like TV. There are some exceptions, but in general when product becomes popular, it somehow might get nice graphics and bad gameplay. So you get a game where you can see how much money was thrown at it judging by graphical quality, but which loses to its' predecessor when it comes to gameplay. There are exceptions, of course (and there are games that have good graphics and solid gameplay), but in general, more money does not mean better games.&lt;br /&gt;&lt;li&gt;&amp;quot;Why should I pay for something I can get for free&amp;quot;. This one is obvious, but I had to mention it for the sake of completeness. Original creator(s) should be praised for his/her/their job, or there will be no more games/movies for you. If no one pays - eventually creators obviously won't get paid. However, on other hand, there will be always overpriced low-quality products, and you really need to be sure who gets your money. Which makes situation not so obvious.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;How copyright should work&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;Here is how I see ideal copyright laws:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; By purchasing digital product (music, video game, software), you acquire right to download, use, view, copy, recompress (or convert into another format), upload it onto any network and download it again in another resolution/language. &lt;br /&gt;&lt;li&gt; This right is can be sold/transferred to another person. After the the transfer you no longer have the rights mentioned in part 1.&lt;br /&gt;&lt;li&gt; You cannot keep the right after you gave it to someone else. &lt;br /&gt;&lt;li&gt; Only publisher or original creator can sell/give those rights in unlimited quantites.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;Why it makes sense&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;In this situation you would be able to download movie from any p2p network you like, pay for it, and live happily ever after. You will be able to continue seeding the movie without fear of getting sued - because you are reducing transfer costs for the publisher, and make material available for other people. In this case guy that downloaded movie without paying will be responsible, not you. You will be able to convert movie or music to any format you want, to be able to listen/use it on other device. And if you had a hardware failure, you will be able to download your material again with no additional fees. And you will be able to get same thing dubbed into another language.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;..and why it is never going to happen&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; This set of rules doesn't mention broadcast/public performance rights. &lt;br /&gt;&lt;li&gt; Such scheme requires central registry of your rights. &lt;br /&gt;&lt;li&gt; Such scheme requires a way to identify what you are using on your PC.&lt;br /&gt;&lt;li&gt; And I cannot imagine any way to manage those rights and keep user to be able to convert material into any possible format. &lt;br /&gt;&lt;li&gt; This will mean heavy losses for publishers - user won't have to buy same movie/game again if disk was destroyed by accident. Which would mean either higher prices, or lower-quality material&lt;br /&gt;&lt;li&gt; To be implemented perfectly, this system should not be dependant on any external servers. Which makes it impossible to implement.&lt;br /&gt;&lt;li&gt; We are not living in perfect world, unfortunately.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;What we have now instead.&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Right now two closest things we have are Valve's Steam and any DRM.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Steam is good because it allows you to get required language pack for your game, but it doesn't qualify for the ideal copyright management system, because it doesn't allow you to upload (to p2p)/sell your games, and because your account can be stolen. Also, if server is offline, you won't be able to play your game.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;And DRM doesn't qualify because of dependency on external server (server is down - no music for you), and because it forbids copying. Pity that inventors of DRM seems to be more interested in restricting copying than in making user's life easier.&lt;br /&gt;&lt;p&gt;&lt;p&gt;&lt;br /&gt;&lt;h2&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/h2&gt;&lt;br /&gt;And, this is it... &lt;br /&gt;End of article. There are still imperfect laws and there is still piracy. What to do? Honestly, I don't know. Perhaps, this writing will give someone better ideas, and perhaps someday there will be better copyright management system. Maybe even ideal one. Or maybe nothing will ever change, and people will always equalize piracy to theft, or they will still thing that if it is not a theft, than it is good thing to do, not recognizing that "there is no black and white, only shades of gray", and piracy situation is not so simple. &lt;br /&gt;Only time will tell.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-5509104425565158891?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/5509104425565158891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/computer-piracy-common-myths-and-how.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5509104425565158891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5509104425565158891'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/computer-piracy-common-myths-and-how.html' title='Computer piracy: common myths, and how copyright laws should be working'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-7552289115230104766</id><published>2009-09-29T11:37:00.008+04:00</published><updated>2009-09-29T13:53:45.038+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sdl'/><category scheme='http://www.blogger.com/atom/ns#' term='3d'/><category scheme='http://www.blogger.com/atom/ns#' term='source'/><category scheme='http://www.blogger.com/atom/ns#' term='opengl'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Example-based texture generation with SDL/OpenGL using bruteforce</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;b&gt;Intro:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;During last weekend I've decided to try implementing texture generation algorithm, where texture is being generated from example (photo or something else). I've got several interesting results, and a couple of problems. The attempt was inspired by &lt;a href="http://mgarland.org/files/papers/jumpmap_egsr2003.pdf"&gt;this paper&lt;/a&gt;(PDF link), but I decided to try simple bruteforce before trying to use "jumpmaps".&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Links:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://graphics.cs.uiuc.edu/~zelinka/pubs.html"&gt;Steve Zelinka's publications&lt;/a&gt;(includes couple of interesting material, like &lt;i&gt;"Interactive Texture Synthesis on Surfaces Using Jump Maps."&lt;/i&gt;, &lt;i&gt;"Mesh Modelling With Curve Analogies"&lt;/i&gt;. Definitely worth checking out, however, I was only interested in texture generation at the moment.&lt;br /&gt;&lt;li&gt;&lt;a href="http://mgarland.org/files/papers/jumpmap_egsr2003.pdf"&gt;Jump maps on surfaces&lt;/a&gt; (pdf, Steve Zelinka and Michael Garland) &lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Results:&lt;/b&gt;&lt;br /&gt;Here is the example pattern I used:&lt;br /&gt;&lt;a href="http://imagecloset.com/view27/af9a332c9dc894e55c961c464fd38542/example3.png"&gt;&lt;img src="http://imagecloset.com/27/af9a332c9dc894e55c961c464fd38542/example3_thumb.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;And here is the result I got:&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_7W182WvO8Qw/SsG932mEf7I/AAAAAAAAAAU/V8OlXJPokH8/s1600-h/result.png"&gt;&lt;img src="http://3.bp.blogspot.com/_7W182WvO8Qw/SsG932mEf7I/AAAAAAAAAAU/V8OlXJPokH8/s320/result.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5386795396557471666" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Algorithm:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Fill destination image with black, and make every pixel transparent.&lt;br /&gt;&lt;li&gt;Copy any pixel from pattern image into top-left corner of destination image.&lt;br /&gt;&lt;li&gt;For every transparent pixel of destination image (i.e. alpha == 0) with non-transparent neighbors within search distance, replace it with pixel from pattern image where non-transparent pixels in neighborhood most closely resemble non-transparent pixels in destination image's neighborhood of current pixel. Best matching pixel found by bruteforce search (yes, it is slow). Repeat until there are no more transparent pixels left.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;How neighborhoods are compared:&lt;br /&gt;There are several ways to do this:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Compute distance(within search distance) for every non-transparent pixel in current neighborhood, add distances up, divide sum by number of non-transparent pixels. Find pixel in pattern image with the smallest distance.&lt;br /&gt;&lt;li&gt;Add up (into rgb vector) all non-transparent pixel within search distance in destination surface into one vector, Add up up all non-transparent pixels within search distance from candidate pixel in pattern surface, compute distance between them. Find surface with smallest distance. &lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Things to keep in mind:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;When calculating differences, watch out for transparency. DO not use pixels at offsets (from candidate) where source or pattern pixel are transparent.&lt;br /&gt;&lt;li&gt;Destination surface should be tileable, so pixel operations wrap around. Pattern is no tileable, so pixels near the border should not used. &lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Good things:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Tileable (well, you can see some repeating patterns, bot no obvious seams)&lt;br /&gt;&lt;li&gt;Looks great/realistic.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Problems:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; It is incredibly slow. Example image took at least one hour (or more) to be finished. Cannot be used in realtime.&lt;br /&gt;&lt;li&gt; I've run into problems when I tried to do same thing using OpenGL/GLSL and DirectX/HLSL (to see if it will work faster):&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;In DirectX HLSL shader could not be compiled. D3DXCompileShaderFromFile simply hung during compilation, and I wasn't in the mood for assembly.&lt;br /&gt;&lt;li&gt;In OpenGL, it looks like there is no way to select mip level from within GLSL fragment shader. So, I can say farewell to cheap search optimization.&lt;br /&gt;&lt;li&gt;In OpenGL, I hit weird problem - entire system becomes unusable (stops responding, etc) when current frame is being rendered. And because one frame takes several seconds, this means, you can't do anything else on the system while application is running.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Perhaps it makes sense to try another algorithm or reimplement this thing on CUDA. Maybe I'll do it some other time, maybe not.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;br /&gt;Code is free to use/redistribute for non-commercial purposes.&lt;br /&gt;Code didn't completely fit into window, and I'm not in the mood for template hacking right now. If you want to see everything, select, copy and paste code into notepad (or kedit/jedit or whatever).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sdl version&lt;/b&gt;&lt;br /&gt;main.cpp:&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre style="font-family: helvetica, sans-serif;font-size: small;"&gt;#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;#include &amp;lt;SDL/SDL_image.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/timer.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/keyboard.h&amp;gt;&lt;br /&gt;#include &amp;lt;wchar.h&amp;gt;&lt;br /&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;br /&gt;using Keyboard::keyPressed;&lt;br /&gt;&lt;br /&gt;static Timer timer;&lt;br /&gt;static int texPowX = 9;&lt;br /&gt;static int texPowY = 9;&lt;br /&gt;static int texWidth = 1 &amp;lt;&amp;lt; texPowX;&lt;br /&gt;static int texHeight = 1 &amp;lt;&amp;lt; texPowY;&lt;br /&gt;static int scrWidth = texWidth;&lt;br /&gt;static int scrHeight = texHeight;&lt;br /&gt;static int texMaskX = texWidth - 1;&lt;br /&gt;static int texMaskY = texHeight - 1;&lt;br /&gt;static int searchWidth = 3;&lt;br /&gt;static int searchHeight = 3;&lt;br /&gt;struct Dist{&lt;br /&gt; unsigned long r, g, b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;size_t numPatternPixels = 0;&lt;br /&gt;Dist* precomputedDist = 0;&lt;br /&gt;&lt;br /&gt;struct Pixel{&lt;br /&gt; unsigned char b, g, r, a;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void fillPixel(int x, int y, SDL_Surface* dst, SDL_Surface* src, int dstMaskX, int dstMaskY){&lt;br /&gt; Pixel&amp;amp; dstPix = *((Pixel*)((char*)(dst-&amp;gt;pixels) + sizeof(Pixel)*x + dst-&amp;gt;pitch*y));&lt;br /&gt;&lt;br /&gt; int xMin = x + texWidth - searchWidth;&lt;br /&gt; int xMax = xMin + searchWidth*2;&lt;br /&gt; int yMin = y + texHeight - searchHeight;&lt;br /&gt; int yMax = yMin + searchHeight*2;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int numFilled = 0;&lt;br /&gt; for (int curY = yMin; curY &amp;lt; yMax; curY++)&lt;br /&gt;  for (int curX = xMin; curX &amp;lt; xMax; curX++){&lt;br /&gt;   Pixel&amp;amp; cur = *((Pixel*)((char*)(dst-&amp;gt;pixels) + sizeof(Pixel)*(curX &amp;amp; texMaskX) + dst-&amp;gt;pitch*(curY &amp;amp; texMaskY)));&lt;br /&gt;   if (cur.a != 0)&lt;br /&gt;    numFilled++;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; if (numFilled == 0){&lt;br /&gt;  int srcX = rand() % src-&amp;gt;w;&lt;br /&gt;  int srcY = rand() % src-&amp;gt;h;&lt;br /&gt;  dstPix = *((Pixel*)((char*)(src-&amp;gt;pixels) + sizeof(Pixel)*srcX + src-&amp;gt;pitch*srcY));&lt;br /&gt;  dstPix.a = 0xFF;&lt;br /&gt;  return;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; int storedSrcX = rand() % src-&amp;gt;w;&lt;br /&gt; int storedSrcY = rand() % src-&amp;gt;h;&lt;br /&gt; float lastDifference = 3.40282347e+37F;&lt;br /&gt;&lt;br /&gt; //unsigned char mask = &lt;br /&gt;&lt;br /&gt; for (int srcY = searchHeight; srcY &amp;lt; (src-&amp;gt;h - searchHeight); srcY++)&lt;br /&gt;  for (int srcX = searchWidth; srcX &amp;lt; (src-&amp;gt;w - searchWidth); srcX++){&lt;br /&gt;   float curDifference = 0;&lt;br /&gt;   int numPixels = 0;&lt;br /&gt;   for (int tmpY = -searchHeight; tmpY &amp;lt; searchHeight; tmpY++)&lt;br /&gt;    for(int tmpX = -searchWidth; tmpX &amp;lt; searchWidth; tmpX++){&lt;br /&gt;     Pixel&amp;amp; tmpSrc = *((Pixel*)((char*)(src-&amp;gt;pixels) + sizeof(Pixel)*(srcX+tmpX) + src-&amp;gt;pitch*(srcY+tmpY)));&lt;br /&gt;     Pixel&amp;amp; tmpDst = *((Pixel*)((char*)(dst-&amp;gt;pixels) + sizeof(Pixel)*((x + dst-&amp;gt;w + tmpX) &amp;amp; dstMaskX) + dst-&amp;gt;pitch*((y + dst-&amp;gt;h + tmpY) &amp;amp; dstMaskY)));&lt;br /&gt;     if (tmpDst.a){&lt;br /&gt;      numPixels++;&lt;br /&gt;      int dr = tmpSrc.r - tmpDst.r;&lt;br /&gt;      int dg = tmpSrc.g - tmpDst.g;&lt;br /&gt;      int db = tmpSrc.g - tmpDst.g;&lt;br /&gt;      curDifference += dr*dr + dg*dg + db*db;&lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;   if (numPixels)&lt;br /&gt;    curDifference /= (float)numPixels;&lt;br /&gt;   if (curDifference &amp;lt; lastDifference){&lt;br /&gt;    lastDifference = curDifference;&lt;br /&gt;    storedSrcX = srcX;&lt;br /&gt;    storedSrcY = srcY;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; dstPix = *((Pixel*)((char*)(src-&amp;gt;pixels) + sizeof(Pixel)*storedSrcX + src-&amp;gt;pitch*storedSrcY));&lt;br /&gt; dstPix.a = 0xFF;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv){&lt;br /&gt;    SDL_Init(SDL_INIT_VIDEO);&lt;br /&gt; &lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);&lt;br /&gt; &lt;br /&gt; Keyboard::init();&lt;br /&gt; timer.reset();&lt;br /&gt; timer.setMaxFps(100);&lt;br /&gt; timer.setMinFps(5);&lt;br /&gt; &lt;br /&gt; SDL_Surface* screen = SDL_SetVideoMode(scrWidth, scrHeight, 32, SDL_SWSURFACE);&lt;br /&gt;&lt;br /&gt; SDL_Surface *texture = SDL_CreateRGBSurface(SDL_SWSURFACE, scrWidth, scrHeight, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);&lt;br /&gt;&lt;br /&gt; if (screen == 0){&lt;br /&gt;  fprintf(stderr, &amp;quot;couldn't set mode %dx%d!\n&amp;quot;, 640, 480);&lt;br /&gt;  SDL_Quit();&lt;br /&gt;  return -1;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; SDL_Surface *image = IMG_Load(&amp;quot;example.png&amp;quot;);&lt;br /&gt; SDL_Surface *example = SDL_CreateRGBSurface(SDL_SWSURFACE, image-&amp;gt;w, image-&amp;gt;h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);&lt;br /&gt; SDL_BlitSurface(image, 0, example, 0);&lt;br /&gt;&lt;br /&gt; SDL_FreeSurface(image);&lt;br /&gt; SDL_LockSurface(example);&lt;br /&gt;&lt;br /&gt; numPatternPixels = example-&amp;gt;w * example-&amp;gt;h;&lt;br /&gt; precomputedDist = new Dist[numPatternPixels * 256];&lt;br /&gt; memset(precomputedDist, 0, sizeof(Dist)*numPatternPixels*256);&lt;br /&gt; for (int mask = 0; mask &amp;lt; 256; mask++){&lt;br /&gt;  printf(&amp;quot;processing mask %d&amp;quot;, mask);&lt;br /&gt;  for (int y = 0; y &amp;lt; example-&amp;gt;h; y++)&lt;br /&gt;   for (int x = 0; x &amp;lt; example-&amp;gt;w; x++){&lt;br /&gt;    Dist&amp;amp; curDist = precomputedDist[x + y*example-&amp;gt;h + mask*numPatternPixels];&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; size_t numPixels = scrWidth*scrHeight;&lt;br /&gt; SDL_LockSurface(texture);&lt;br /&gt; for (int y = 0; y  &amp;lt;scrHeight; y++)&lt;br /&gt;  for (int x = 0; x &amp;lt; scrWidth; x++){&lt;br /&gt;   Pixel&amp;amp; cur = *((Pixel*)((char*)(texture-&amp;gt;pixels) + sizeof(Pixel)*x + texture-&amp;gt;pitch*y));&lt;br /&gt;   cur.r = cur.g = cur.b = 0xFF;&lt;br /&gt;   cur.a = 0;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt; SDL_UnlockSurface(texture);&lt;br /&gt; &lt;br /&gt; int x = 0;&lt;br /&gt; int y = 0;&lt;br /&gt;&lt;br /&gt; bool running = true;&lt;br /&gt; while (running){&lt;br /&gt;  SDL_Event event;&lt;br /&gt;  if (SDL_PollEvent(&amp;amp;event)){&lt;br /&gt;   switch(event.type){&lt;br /&gt;    case SDL_QUIT:&lt;br /&gt;        running = false;&lt;br /&gt;        break;&lt;br /&gt;   };&lt;br /&gt;  }&lt;br /&gt;  timer.update();&lt;br /&gt;  Keyboard::update();&lt;br /&gt;&lt;br /&gt;  SDL_LockSurface(texture);&lt;br /&gt;&lt;br /&gt;  for (int i = 0; (i &amp;lt; 100) &amp;amp;&amp;amp; (y &amp;lt; scrHeight); i++){&lt;br /&gt;   /*Pixel&amp;amp; cur = *((Pixel*)((char*)(texture-&amp;gt;pixels) + sizeof(Pixel)*x + texture-&amp;gt;pitch*y));&lt;br /&gt;   cur.r = rand() &amp;amp; 0xFF;&lt;br /&gt;   cur.g = rand() &amp;amp; 0xFF;&lt;br /&gt;   cur.b = rand() &amp;amp; 0xFF;&lt;br /&gt;   cur.a = 0xFF;*/&lt;br /&gt;   fillPixel(x, y, texture, example, texMaskX, texMaskY);&lt;br /&gt;   x++;&lt;br /&gt;   if (x &amp;gt;= scrWidth){&lt;br /&gt;    x = 0;&lt;br /&gt;    y++;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  SDL_UnlockSurface(texture);&lt;br /&gt;&lt;br /&gt;  static bool saved = false;&lt;br /&gt;  if ((y &amp;gt;= scrHeight) &amp;amp;&amp;amp; !saved){&lt;br /&gt;   SDL_SaveBMP(texture, &amp;quot;result.bmp&amp;quot;);&lt;br /&gt;   saved = true;&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  if (keyPressed(SDLK_ESCAPE))&lt;br /&gt;   running = false;&lt;br /&gt;  &lt;br /&gt;  SDL_BlitSurface(texture, 0, screen, 0);&lt;br /&gt;  SDL_UpdateRect(screen, 0, 0, scrWidth, scrHeight);&lt;br /&gt; } &lt;br /&gt;&lt;br /&gt; delete[] precomputedDist;&lt;br /&gt; SDL_UnlockSurface(example);&lt;br /&gt; SDL_FreeSurface(example);&lt;br /&gt; SDL_FreeSurface(texture);&lt;br /&gt;    SDL_Quit();&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;OpenGL version:&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre style="font-family: helvetica, sans-serif;font-size: small;"&gt;#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;#include &amp;lt;glee/glee.h&amp;gt;&lt;br /&gt;#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;#include &amp;lt;GL/glu.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/glutils.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/Framebuffer.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/textures.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/timer.h&amp;gt;&lt;br /&gt;#include &amp;lt;common/keyboard.h&amp;gt;&lt;br /&gt;#include &amp;lt;FTGL/FTGL.h&amp;gt;&lt;br /&gt;#include &amp;lt;FTGL/FTGLPixmapFont.h&amp;gt;&lt;br /&gt;#include &amp;lt;wchar.h&amp;gt;&lt;br /&gt;#include &amp;lt;math.h&amp;gt;&lt;br /&gt;&lt;br /&gt;using Keyboard::keyPressed;&lt;br /&gt;&lt;br /&gt;static Timer timer;&lt;br /&gt;static const int texSize = 128;&lt;br /&gt;static int scrWidth = texSize;&lt;br /&gt;static int scrHeight = texSize;&lt;br /&gt;static const int searchSize = 3;&lt;br /&gt;&lt;br /&gt;static const char* vsText = &lt;br /&gt;&amp;quot;varying vec2 texCoords;\n&amp;quot;&lt;br /&gt;&amp;quot; const float gridSize = 10.0;\n&amp;quot;&lt;br /&gt;&amp;quot;void main(void){\n&amp;quot;&lt;br /&gt;&amp;quot; gl_Position = ftransform();\n&amp;quot;&lt;br /&gt;&amp;quot;  texCoords = gl_MultiTexCoord0;\n&amp;quot;&lt;br /&gt;&amp;quot;}\n&amp;quot;;&lt;br /&gt;&lt;br /&gt;static const char* fsText = &lt;br /&gt;&amp;quot;varying vec2 texCoords;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform sampler2D srcTex;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform sampler2D patternTex;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform vec2 srcTextureSize;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform vec2 srcPixelSize;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform vec2 patternTextureSize;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform vec2 patternPixelSize;\n&amp;quot;&lt;br /&gt;&amp;quot;uniform vec2 searchSize;\n&amp;quot;&lt;br /&gt;&amp;quot;void main(void){\n&amp;quot;&lt;br /&gt;&amp;quot; vec2 uv = texCoords;\n&amp;quot;&lt;br /&gt;&amp;quot; vec4 thisColor = texture2D(srcTex, uv);\n&amp;quot;&lt;br /&gt;&amp;quot; gl_FragColor = thisColor;\n&amp;quot;&lt;br /&gt;&amp;quot; if (thisColor.a &amp;gt; 0.0)\n&amp;quot;&lt;br /&gt;&amp;quot;  return;\n&amp;quot;&lt;br /&gt;&amp;quot; vec4 leftColor = texture2D(srcTex, uv - vec2(srcPixelSize.x, 0.0));\n&amp;quot;&lt;br /&gt;&amp;quot; vec4 topColor = texture2D(srcTex, uv - vec2(0.0, srcPixelSize.y));\n&amp;quot;&lt;br /&gt;/*&amp;quot; vec4 rightColor = texture2D(srcTex, uv + vec2(srcPixelSize.x, 0.0));\n&amp;quot;&lt;br /&gt;&amp;quot; vec4 bottomColor = texture2D(srcTex, uv + vec2(0.0, srcPixelSize.y));\n&amp;quot;&lt;br /&gt;&amp;quot; if ((leftColor.a == 0.0)&amp;amp;&amp;amp;(topColor.a == 0.0)&amp;amp;&amp;amp;(rightColor.a == 0.0)&amp;amp;&amp;amp;(bottomColor.a == 0.0))\n&amp;quot;*/&lt;br /&gt;&amp;quot; if ((leftColor.a == 0.0)&amp;amp;&amp;amp;(topColor.a == 0.0))\n&amp;quot;&lt;br /&gt;&amp;quot;  return;\n&amp;quot;&lt;br /&gt;&amp;quot; float lastDistance = 0.0;\n&amp;quot;&lt;br /&gt;&amp;quot; bool first = true;\n&amp;quot;&lt;br /&gt;&amp;quot; vec2 lastCoords = vec2(0.0);\n&amp;quot;&lt;br /&gt;&amp;quot; vec2 patEndCoords = (patternTextureSize - searchSize - vec2(0.5))*patternPixelSize;\n&amp;quot;&lt;br /&gt;&amp;quot; vec2 patStartCoords = (searchSize + vec2(0.5))*patternPixelSize;\n&amp;quot;&lt;br /&gt;&amp;quot; vec2 patCoords = patStartCoords;\n&amp;quot;&lt;br /&gt;&amp;quot; for(patCoords.y = patStartCoords.y; patCoords.y &amp;lt; patEndCoords.y; patCoords.y += patternPixelSize.y){\n&amp;quot;&lt;br /&gt;&amp;quot;  for(patCoords.x = patStartCoords.x; patCoords.x &amp;lt; patEndCoords.x; patCoords.x += patternPixelSize.x){\n&amp;quot;&lt;br /&gt;&amp;quot;   vec2 tmpCoords = vec2(0.0);\n&amp;quot;&lt;br /&gt;&amp;quot;   float distance = 0.0;\n&amp;quot;&lt;br /&gt;&amp;quot;   for(tmpCoords.y = -searchSize.y; tmpCoords.y &amp;lt;= searchSize.y; tmpCoords.y += 1.0){\n&amp;quot;&lt;br /&gt;&amp;quot;    for(tmpCoords.x = -searchSize.x; tmpCoords.x &amp;lt;= searchSize.x; tmpCoords.x += 1.0){\n&amp;quot;&lt;br /&gt;&amp;quot;     vec4 srcColor = texture2D(srcTex, (tmpCoords*srcPixelSize) + uv);\n&amp;quot;&lt;br /&gt;&amp;quot;     vec4 patternColor = texture2D(patternTex, (tmpCoords*patternPixelSize) + patCoords);\n&amp;quot;&lt;br /&gt;&amp;quot;     if (srcColor.a &amp;gt; 0.0){\n&amp;quot;&lt;br /&gt;&amp;quot;      vec3 dist = srcColor.xyz - patternColor.xyz;\n&amp;quot;&lt;br /&gt;&amp;quot;      distance += dot(dist, dist);\n&amp;quot;&lt;br /&gt;&amp;quot;     }\n&amp;quot;&lt;br /&gt;&amp;quot;    }\n&amp;quot;&lt;br /&gt;&amp;quot;   }\n&amp;quot;&lt;br /&gt;&amp;quot;   if (first||(distance &amp;lt; lastDistance)){\n&amp;quot;&lt;br /&gt;&amp;quot;    lastDistance = distance;\n&amp;quot;&lt;br /&gt;&amp;quot;    lastCoords = patCoords;\n&amp;quot;&lt;br /&gt;&amp;quot;    first = false;\n&amp;quot;&lt;br /&gt;&amp;quot;   }\n&amp;quot;&lt;br /&gt;&amp;quot;  }\n&amp;quot;&lt;br /&gt;&amp;quot; }\n&amp;quot;&lt;br /&gt;&amp;quot; gl_FragColor = texture2D(patternTex, lastCoords);\n&amp;quot;&lt;br /&gt;&amp;quot; gl_FragColor.a = 1.0;\n&amp;quot;&lt;br /&gt;&amp;quot;}\n&amp;quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void textureRect(float x, float y, float width, float height){&lt;br /&gt; float x1 = x, y1 = y, x2 = x1 + width, y2 = y1 + height;&lt;br /&gt; glBegin(GL_TRIANGLE_FAN);&lt;br /&gt; glTexCoord2f(0, 0);&lt;br /&gt; glVertex2f(x1, y1);&lt;br /&gt; glTexCoord2f(1, 0);&lt;br /&gt; glVertex2f(x2, y1);&lt;br /&gt; glTexCoord2f(1, 1);&lt;br /&gt; glVertex2f(x2, y2);&lt;br /&gt; glTexCoord2f(0, 1);&lt;br /&gt; glVertex2f(x1, y2);&lt;br /&gt; glEnd();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv){&lt;br /&gt; srand(GetTickCount());&lt;br /&gt;    SDL_Init(SDL_INIT_VIDEO);&lt;br /&gt; &lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);&lt;br /&gt; SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);&lt;br /&gt; &lt;br /&gt; Keyboard::init();&lt;br /&gt; timer.reset();&lt;br /&gt; /*timer.setMaxFps(100);&lt;br /&gt; timer.setMinFps(5);*/&lt;br /&gt;&lt;br /&gt; if (scrWidth &amp;lt;= 128){&lt;br /&gt;  scrWidth = texSize * 4;&lt;br /&gt;  scrHeight = texSize * 4;&lt;br /&gt; }&lt;br /&gt;     &lt;br /&gt; if (SDL_SetVideoMode(scrWidth, scrHeight, 32, SDL_OPENGL) == 0){&lt;br /&gt;  fprintf(stderr, &amp;quot;couldn't set mode %dx%d!\n&amp;quot;, scrWidth, scrHeight);&lt;br /&gt;  SDL_Quit();&lt;br /&gt;  return -1;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; FTGLPixmapFont font(&amp;quot;DejaVuSans.ttf&amp;quot;);&lt;br /&gt; font.CharMap(ft_encoding_unicode);&lt;br /&gt; font.FaceSize(10);&lt;br /&gt; FTGLPixmapFont largeFont(&amp;quot;DejaVuSans.ttf&amp;quot;);&lt;br /&gt; largeFont.CharMap(ft_encoding_unicode);&lt;br /&gt; largeFont.FaceSize(40);&lt;br /&gt; SDL_ShowCursor(SDL_DISABLE);&lt;br /&gt;    &lt;br /&gt; glClearColor(0, 0, 0, 0);&lt;br /&gt; glClearDepth(1.0);&lt;br /&gt;&lt;br /&gt; Framebuffer *framebuffers[2] = {0, 0};&lt;br /&gt; framebuffers[0] = new Framebuffer();&lt;br /&gt; framebuffers[1] = new Framebuffer();&lt;br /&gt; for (int i = 0; i &amp;lt; 2; i++)&lt;br /&gt;  framebuffers[i]-&amp;gt;setSize(texSize, texSize);&lt;br /&gt;&lt;br /&gt; int currentFramebuffer = 0;&lt;br /&gt;&lt;br /&gt; Texture* texture = new Texture(&amp;quot;example3.png&amp;quot;, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR);&lt;br /&gt; &lt;br /&gt; glEnable(GL_DEPTH_TEST);&lt;br /&gt; glEnable(GL_TEXTURE_2D);&lt;br /&gt; &lt;br /&gt; GLuint filterProgram = 0;&lt;br /&gt;&lt;br /&gt; filterProgram = createProgram(vsText, fsText);&lt;br /&gt; checkGlError();&lt;br /&gt;&lt;br /&gt; GLuint srcSamplerUniform = glGetUniformLocation(filterProgram, &amp;quot;srcTex&amp;quot;);&lt;br /&gt; GLuint patternSamplerUniform = glGetUniformLocation(filterProgram, &amp;quot;patternTex&amp;quot;);&lt;br /&gt; GLuint srcTextureSizeUniform = glGetUniformLocation(filterProgram, &amp;quot;srcTextureSize&amp;quot;);&lt;br /&gt; GLuint srcPixelSizeUniform = glGetUniformLocation(filterProgram, &amp;quot;srcPixelSize&amp;quot;);&lt;br /&gt; GLuint patternTextureSizeUniform = glGetUniformLocation(filterProgram, &amp;quot;patternTextureSize&amp;quot;);&lt;br /&gt; GLuint patternPixelSizeUniform = glGetUniformLocation(filterProgram, &amp;quot;patternPixelSize&amp;quot;);&lt;br /&gt; GLuint searchSizeUniform = glGetUniformLocation(filterProgram, &amp;quot;searchSize&amp;quot;);&lt;br /&gt;&lt;br /&gt; bool running = true;&lt;br /&gt; while (running){&lt;br /&gt;  SDL_Event event;&lt;br /&gt;  if (SDL_PollEvent(&amp;amp;event)){&lt;br /&gt;   switch(event.type){&lt;br /&gt;    case SDL_QUIT:&lt;br /&gt;        running = false;&lt;br /&gt;        break;&lt;br /&gt;   };&lt;br /&gt;  }&lt;br /&gt;  timer.update();&lt;br /&gt;  Keyboard::update();&lt;br /&gt;&lt;br /&gt;  currentFramebuffer = currentFramebuffer ^ 1;&lt;br /&gt;  Framebuffer* src = framebuffers[currentFramebuffer];&lt;br /&gt;  Framebuffer* dst = framebuffers[currentFramebuffer ^ 1];&lt;br /&gt;  &lt;br /&gt;  if (keyPressed(SDLK_ESCAPE))&lt;br /&gt;   running = false;&lt;br /&gt;  &lt;br /&gt;  glDisable(GL_DEPTH_TEST);&lt;br /&gt;&lt;br /&gt;  /*&lt;br /&gt;  framebuffer rendering&lt;br /&gt;  */&lt;br /&gt;  dst-&amp;gt;begin();&lt;br /&gt;  glClearColor(0, 0, 0, 0);&lt;br /&gt;  glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;  glMatrixMode(GL_PROJECTION);&lt;br /&gt;  glLoadIdentity();&lt;br /&gt;  gluOrtho2D(0, dst-&amp;gt;width, 0, dst-&amp;gt;height);&lt;br /&gt; &lt;br /&gt;  glMatrixMode(GL_MODELVIEW);&lt;br /&gt;  glLoadIdentity();&lt;br /&gt;&lt;br /&gt;  glActiveTexture(GL_TEXTURE0);&lt;br /&gt;  glBindTexture(GL_TEXTURE_2D, src-&amp;gt;renderTexture);&lt;br /&gt;&lt;br /&gt;  glEnable(GL_ALPHA_TEST);&lt;br /&gt;  glAlphaFunc(GL_GREATER, 0);&lt;br /&gt;  float f = 1.0f/ 9.1f;&lt;br /&gt;  /*glEnable(GL_BLEND);&lt;br /&gt;  glBlendFunc(GL_ONE, GL_ONE);*/&lt;br /&gt;  static bool first = true;&lt;br /&gt;  textureRect(0, 0, (float)(src-&amp;gt;width), (float)(src-&amp;gt;height));&lt;br /&gt;  bool justFinished = false;&lt;br /&gt;  if (first){&lt;br /&gt;   glActiveTexture(GL_TEXTURE0);&lt;br /&gt;   glBindTexture(GL_TEXTURE_2D, texture-&amp;gt;tex);&lt;br /&gt;&lt;br /&gt;   float s = (float)(rand() % texture-&amp;gt;width)/(float)texture-&amp;gt;width;&lt;br /&gt;   float t = (float)(rand() % texture-&amp;gt;height)/(float)texture-&amp;gt;height;&lt;br /&gt;   glTexCoord2f(s, t);&lt;br /&gt;   glBegin(GL_POINTS);&lt;br /&gt;   glVertex2f(0, 0);&lt;br /&gt;   glEnd();&lt;br /&gt;&lt;br /&gt;   glRasterPos2i(10, 20);&lt;br /&gt; &lt;br /&gt;   //textureRect((float)(rand() % dst-&amp;gt;width), (float)(rand() % dst-&amp;gt;height), (float)(texture-&amp;gt;width), (float)(texture-&amp;gt;height));&lt;br /&gt;   //textureRect(0, 0, (float)(texture-&amp;gt;width), (float)(texture-&amp;gt;height));&lt;br /&gt;   first = false;&lt;br /&gt;  }&lt;br /&gt;  else{&lt;br /&gt;   textureRect(0, 0, (float)src-&amp;gt;width, (float)src-&amp;gt;height);&lt;br /&gt;   static int x = 0;&lt;br /&gt;   static int y = 0;&lt;br /&gt;   static const int tileSize = texSize;&lt;br /&gt;   static int xSize = texSize/tileSize;&lt;br /&gt;   static int ySize = texSize/tileSize;&lt;br /&gt;   static int counter = -tileSize;&lt;br /&gt;   if (y &amp;lt; ySize){&lt;br /&gt;    glActiveTexture(GL_TEXTURE1);&lt;br /&gt;    glBindTexture(GL_TEXTURE_2D, texture-&amp;gt;tex);&lt;br /&gt;    glUseProgram(filterProgram);&lt;br /&gt;    if(filterProgram){&lt;br /&gt;     glUniform1i(srcSamplerUniform, 0);&lt;br /&gt;     glUniform1i(patternSamplerUniform, 1);&lt;br /&gt;     glUniform2f(srcTextureSizeUniform, (float)src-&amp;gt;width, (float)src-&amp;gt;height);&lt;br /&gt;     glUniform2f(srcPixelSizeUniform, 1.0f/(float)src-&amp;gt;width, 1.0f/(float)src-&amp;gt;height);&lt;br /&gt;     glUniform2f(patternTextureSizeUniform, (float)texture-&amp;gt;width, (float)texture-&amp;gt;height);&lt;br /&gt;     glUniform2f(patternPixelSizeUniform, 1.0f/(float)texture-&amp;gt;width, 1.0f/(float)texture-&amp;gt;height);&lt;br /&gt;     glUniform2f(searchSizeUniform, (float)searchSize, (float)searchSize);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    float x1 = (float)(x * tileSize);&lt;br /&gt;    float s1 = x1/(float)(src-&amp;gt;width);&lt;br /&gt;    float x2 = (float)((x+1) * tileSize);&lt;br /&gt;    float s2 = x2/(float)(src-&amp;gt;width);&lt;br /&gt;    float y1 = (float)(y * tileSize);&lt;br /&gt;    float t1 = y1/(float)(src-&amp;gt;height);&lt;br /&gt;    float y2 = (float)((y+1) * tileSize);&lt;br /&gt;    float t2 = y2/(float)(src-&amp;gt;height);&lt;br /&gt;    glBegin(GL_TRIANGLE_FAN);&lt;br /&gt;    glTexCoord2f(s1, t1);&lt;br /&gt;    glVertex2f(x1, y1);&lt;br /&gt;    glTexCoord2f(s2, t1);&lt;br /&gt;    glVertex2f(x2, y1);&lt;br /&gt;    glTexCoord2f(s2, t2);&lt;br /&gt;    glVertex2f(x2, y2);&lt;br /&gt;    glTexCoord2f(s1, t2);&lt;br /&gt;    glVertex2f(x1, y2);&lt;br /&gt;    glEnd();&lt;br /&gt;&lt;br /&gt;    counter++;&lt;br /&gt;    if (counter &amp;gt;= tileSize){&lt;br /&gt;     counter = 0;&lt;br /&gt;     x++;&lt;br /&gt;     if (x &amp;gt;= xSize){&lt;br /&gt;      x = 0;&lt;br /&gt;      y++;&lt;br /&gt;      if (y &amp;gt;= ySize){&lt;br /&gt;       //save texture&lt;br /&gt;       justFinished = true;&lt;br /&gt;      }&lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   //textureRect(0, 0, (float)src-&amp;gt;width, (float)src-&amp;gt;height);&lt;br /&gt;  }&lt;br /&gt;  glUseProgram(0);&lt;br /&gt;  glActiveTexture(GL_TEXTURE0);   &lt;br /&gt;  dst-&amp;gt;end();&lt;br /&gt;&lt;br /&gt;  if (justFinished){&lt;br /&gt;   SDL_Surface* tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, dst-&amp;gt;width, dst-&amp;gt;height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);&lt;br /&gt;   SDL_LockSurface(tmp);&lt;br /&gt;   glBindTexture(GL_TEXTURE_2D, dst-&amp;gt;renderTexture);&lt;br /&gt;   glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, tmp-&amp;gt;pixels);&lt;br /&gt;&lt;br /&gt;   SDL_UnlockSurface(tmp);&lt;br /&gt;   SDL_SaveBMP(tmp, &amp;quot;result.bmp&amp;quot;);&lt;br /&gt;   SDL_FreeSurface(tmp);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  glMatrixMode(GL_PROJECTION);&lt;br /&gt;  glLoadIdentity();&lt;br /&gt;  gluOrtho2D(0, scrWidth, scrHeight, 0);&lt;br /&gt; &lt;br /&gt;  glMatrixMode(GL_MODELVIEW);&lt;br /&gt;  glLoadIdentity();&lt;br /&gt;  &lt;br /&gt;  glClearColor(0, 0, 0.5f, 0);&lt;br /&gt;  glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;   &lt;br /&gt;  glBindTexture(GL_TEXTURE_2D, dst-&amp;gt;renderTexture);&lt;br /&gt;&lt;br /&gt;  //textureRect(0, 0, (float)dst-&amp;gt;width, (float)dst-&amp;gt;height);&lt;br /&gt;  textureRect(0, 0, (float)scrWidth, (float)scrHeight);&lt;br /&gt;&lt;br /&gt;  glBindTexture(GL_TEXTURE_2D, 0);&lt;br /&gt;&lt;br /&gt;  wchar_t buf[256];&lt;br /&gt;  swprintf(buf, 256, L&amp;quot;fps: %.2f&amp;quot;, timer.getFps());&lt;br /&gt;  glRasterPos2i(10, 20);&lt;br /&gt;&lt;br /&gt;  font.Render(buf);&lt;br /&gt;  &lt;br /&gt;  glFlush();&lt;br /&gt;  SDL_GL_SwapBuffers();  &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt; if (glIsProgram(filterProgram))&lt;br /&gt;  glDeleteProgram(filterProgram);&lt;br /&gt;&lt;br /&gt; delete texture;&lt;br /&gt; for (int i = 0; i &amp;lt; 2; i++)&lt;br /&gt;  delete framebuffers[i];&lt;br /&gt; &lt;br /&gt;    SDL_Quit();&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-7552289115230104766?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/7552289115230104766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/example-based-bruteforce-texture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/7552289115230104766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/7552289115230104766'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/example-based-bruteforce-texture.html' title='Example-based texture generation with SDL/OpenGL using bruteforce'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7W182WvO8Qw/SsG932mEf7I/AAAAAAAAAAU/V8OlXJPokH8/s72-c/result.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-1454138477158167559</id><published>2009-09-03T07:21:00.010+04:00</published><updated>2009-09-03T09:14:09.508+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='life'/><category scheme='http://www.blogger.com/atom/ns#' term='philosophy'/><category scheme='http://www.blogger.com/atom/ns#' term='sad'/><category scheme='http://www.blogger.com/atom/ns#' term='existence'/><title type='text'>The meaning of life and everything</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;Well, this time it isn't about programming or computers, but this was bothering me for a while. &lt;b&gt;Warning&lt;/b&gt;: this text might be depressing, because I have no answer for that question.&lt;br /&gt;&lt;br /&gt;Have you ever thought about this: &lt;i&gt;everything you see around you eventually will disappear&lt;/i&gt;. Think about it. Many human-made object will be broken within 100 years. People last less than 200 years, so in a 200 years there probably will be no you (well unless you are lucky enough to find or invent immortality cure). Buildings last longer, but most of them won't survive even a few hundreds of years. In a few billions of years sun will explode and destroy the planet. And in a few more billions of years universe will collapse back to the single point it appeared from. So there will be nothing left at all. &lt;br /&gt;&lt;br /&gt;"Daisy Owl" nicely illustrates the problem(&lt;a href="http://www.daisyowl.com/comic/2008-12-10"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;This makes me wonder - what is the point of everything? Every single thing that exists will eventually disappear. And in the end there will be no one left to tell the tale or remember anything. As if nothing ever existed at all.&lt;br /&gt;&lt;br /&gt;I guess happiest people never run into that question.&lt;br /&gt;&lt;br /&gt;The problem here is not that all matter will disappear. Some of the theories about the end of universe suggests that matter will remain (but temperature will drop to absolute zero). The problem is that every object or person (including yourself) around you &lt;i&gt;already&lt;/i&gt; doesn't exist anymore - at some point in the future (or there is no longer any observer for this object), which is hard to accept simply because it doesn't feel "right".&lt;br /&gt;&lt;br /&gt;Another problem is that human mind wants a meaning for everything (well, at least mine does). The most logical answer is that life has no meaning and is an accident. However, this idea is incredibly hard to accept. I guess that it is easier for religious people to face this question - after all, at least in some religions you are immortal (your soul, which is basically you), or you are reborn, and at the "end of times" you will meet all other people and you will live happily ever after. On other hand that eternal life in heaven/hell might not be that different from "end of time" in one of scientific theories - everything kind of "stops" and remains same forever.&lt;br /&gt;&lt;br /&gt;If you think more about all of this, you can notice one interesting thing: the more advanced technology becomes, the less chances it has to exist for long time and less chances it has to be comprehensible for next civilization should humanity disappear. Think about it. As far as I know, writings on the stone can exist for a lot of time. Paper is more convenient, but requires extra care in order to persist for many years. And in order to make all information in your computer inaccessible, all you need is to cut the power. Also, the way information is stored is incredibly complicated, which means that should humanity disappear, the next civilization won't be able to get much from remains of our computers. Digital info is incredibly fragile itself, &lt;a href="http://portal.unesco.org/en/ev.php-URL_ID=4805&amp;URL_DO=DO_TOPIC&amp;URL_SECTION=201.html"&gt;this&lt;/a&gt; article illustrates some problems. If you think about this, our civilization suddenly looks incredibly fragile, like a card house - just lose a few key technologies, and you are back in the medieval times.&lt;br /&gt;This returns me to original problem:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; Our world is fragile, and should something serious happen, many things we know will be lost forever. &lt;br /&gt;&lt;li&gt; In fact, nearly everything (on earth, at least) is going to disappear eventually hardly leaving the trace. Organic creatures die. Machinery rusts. Buildings are being destroyed by the elements. Eventually, Sun itself will "blow up" and burn the earth down, or it will eventually stop producing light.&lt;br /&gt;&lt;li&gt; Most of those events cannot be avoided. &lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Perhaps I'm missing something, but for me all this combined together doesn't make any sense.&lt;br /&gt;&lt;br /&gt;So, what is the point of all this? What is the meaning of everything? The purpose? &lt;br /&gt;&lt;br /&gt;Ideas, anyone? &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-1454138477158167559?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/1454138477158167559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/meaning-of-life-and-everything.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1454138477158167559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1454138477158167559'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/09/meaning-of-life-and-everything.html' title='The meaning of life and everything'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-5743378104788822453</id><published>2009-05-07T19:41:00.007+04:00</published><updated>2009-05-08T20:16:18.580+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='howto'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='advice'/><title type='text'>How to become a programmer, How to choose programming language</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;On many message boards and forums I've seen many wannabe programmers. &lt;br /&gt;&amp;quot;Guys, I want to become a programmer! Can you help me?&amp;quot;. Sounds &lt;br /&gt;familiar, isn't it? Those wannabes were asking same basic questions, over and over: &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Which programming language should I learn?&amp;quot; &lt;br /&gt;&lt;li&gt;&amp;quot;Which programming language is the best?&amp;quot;.&lt;br /&gt;&lt;li&gt;&amp;quot;Can you recommend a good book about programming?&amp;quot;&lt;br /&gt;&lt;/ul&gt; &lt;br /&gt;Each of those guys (well, maybe there also were few girls) appeared, asked question, got some answers, disappeared and was never heard of again. I assume that some of them maybe were able to learn something, and maybe even became a really skillful professionals, but I believe most of those people have failed to become programmers. Because to my opinion they were doing it wrong from the beginning.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;What you should never do if want to become a programmer&lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Never ask &amp;quot;Which programming language is the best?&amp;quot; on any message board.&lt;br /&gt;&lt;p&gt;This is because there is no &amp;quot;the best&amp;quot; programming language, but many people will think otherwise. Typically, asking this question anywhere will provoke horrible flamewar where each person will attemp to prove that their language is &amp;quot;the best one&amp;quot;. Of course, few first responses &lt;i&gt;might&lt;/i&gt; be helpful for you, people even might provide some polite, useful, and unbiased info, but (in most situations) the thread will quickly turn into flamewar, or people will start demonstrating various language features using complex constructs (which will be completely uncomprehensible for a wannabe). Either way, there will be a very good chance that all discussion won't be helpful for a newbie.&lt;br /&gt;&lt;li&gt;Don't waste your time searching for &amp;quot;the best book&amp;quot; about your programming language.&lt;br /&gt;You will waste more time searching than you could spend programming. You will need a book, but it isn't really important to get best available book, especially if you are just a beginner. The practice and writing code is more important than books, at least in the beginning. So if you are in doubt (about which book to read), pick any book about your language, and use it for study.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;What is really important&lt;/h2&gt;&lt;br /&gt;Book and choice of language are secondary things. Here is a list of requirements to become a programmer:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;You should have a really good motivation or a goal. &amp;quot;I want to become a professional and get paid a lot of $$$&amp;quot; won't work - because you don't need to be programmer in order to earn cash. However &amp;quot;I want to make my own game&amp;quot; will be perfect.&lt;br /&gt;&lt;li&gt;Programming should be always interesting and fun for you. If it isn't interesting, if you aren't having fun when you write programs, then you won't be able to learn it quickly and efficiently. If your first programs look like a miracle/wonder for you, and you feel joy and happiness once it is finished, then you will have no trouble learning more difficult aspects. However, if you are bored to death each time you want to write something, you are not going to learn much. You will probably decide not to learn programming.&lt;br /&gt;&lt;li&gt;Do not try to pick &amp;quot;the best&amp;quot; language. Try to pick language which is &amp;quot;the best&amp;quot; just for &lt;i&gt;you&lt;/i&gt;. If you are more comfortable with Python than with C++, then you probably will achieve more with Python.&lt;br /&gt;&lt;li&gt;When you are practicing, you should stick with stuff which is interesting for you. Making test program that inverts matrices is boring - pure math, not much to do. However, making "tetris" is not boring. Try to avoid boring examples from book. Keep books nearby and frequently use it as reference, but in order to learn more you should solve interseting, real-life problems.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Specialization: one important question you should answer before you start&lt;/h2&gt;&lt;br /&gt;You can't (easily) become universal programmer that can write in every language on every operating system. You should decide what you want to program, and pick your language accordingly.&lt;br /&gt;Below is a short list of languages with short descriptions and explanations about how they are commonly used.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Assembler&lt;br /&gt;&lt;p&gt;Not really a langauge. Assembler is simply a mnemonic representation of CPU instruction codes. So, (although there were some advanced assembler packages, like MASM), it is tightly tied to CPU, and will be mostly useful when programming low-level otpimized routines for that CPU. It won't be easy to use it for large projects.&lt;br /&gt;&lt;li&gt;C &lt;br /&gt;&lt;p&gt;One of the popular languages, right now mostly used with OpenSource software, mostly on Unix/Linux/BSD and other unix-like system. It is very close to assembler (you still manipulate memory directly), but isn't tied to CPU type, so, unlike Assembler, C code is portable.&lt;br /&gt;&lt;li&gt;C++&lt;br /&gt;&lt;p&gt;High-level language, with some of C features, and with higher-level features: objects, templates, etc. This language is really complex, and although you can learn syntax in few days, it might year or two to master it. C++ is used in most applications on many platforms, in many different tasks. It is portable.&lt;br /&gt;&lt;li&gt;Python&lt;br /&gt;&lt;p&gt;High-level interpreted language. Platform-independant, isn't supposed to be compiled into machine code.&lt;br /&gt;&lt;li&gt;Java&lt;br /&gt;&lt;p&gt;High level language which is meant to be completely platform-independant. Java program compiles into pseudo-code of non-existent processor. The code is run using interpreter, which is available for several platforms. So it is a hybrid of compiled and interpreted language.&lt;br /&gt;&lt;li&gt;C# and .NET&lt;br /&gt;&lt;p&gt;Microsoft's attempts to make another java. Also compiles into pseudocode, but resulting application will be windows-only, because interpreter is developed only for windows (yes, I know about &amp;quot;Mono project&amp;quot;, and I know it isn't frequently used).&lt;br /&gt;&lt;li&gt;Perl&lt;br /&gt;&lt;p&gt;Interpreted language suitable for text processing, scripts, making tools, also for web.&lt;br /&gt;&lt;li&gt;PHP&lt;br /&gt;&lt;p&gt;Interpreted language, used on the web servers.&lt;br /&gt;&lt;li&gt;JavaScript&lt;br /&gt;&lt;p&gt;Used in web-pages, hardly for anything else.&lt;br /&gt;&lt;li&gt;Shell&lt;br /&gt;&lt;p&gt;Unix shell script language. Used for making tools and scripts.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;There are also several languages I never used much:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Haskell&lt;br /&gt;&lt;li&gt;Prolog&lt;br /&gt;&lt;li&gt;Common Lisp&lt;br /&gt;&lt;li&gt;OCaml&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;I"ve heard a lot of good things about those but I didn't need to use any of them. All of those languages are supposed to be powerful, but they are not &amp;quot;mainstream&amp;quot;, and they aren't used frequently. Anyway, many people recommend at least to take a look at them.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Things you should keep in mind when you select language&lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Interpreted languages have better development speed, but worse performance, when compared to compiled languages. I.e. You might create Python program using less time, but C++ program are likely to have better performance. Notice that this a not always true, but in most cases. It is easy to make slow C++ program, especially if you don't know what you are doing. Keep in mind that although you don't need always need maximum performance or maximum development speed, in some situation they are important. For example, you wouldn't want to throw all power of C++ to make a simple text processing program - it will be faster to make it using shell script, python, perl, etc. On other hand, it won't be wise to make a raytracer in python - it is possible thing to do, of course, but for this application you will need a good performance, low-level memory access, etc. Notice, that in this situation you might consider assembler, but development time will be too high, and good C++ compiler might be able to produce better code than you. &lt;br /&gt;&lt;li&gt;You might not want to be tied to just one operating system, architecture or platform. If you want to be able to switch platforms later, then you should avoid Assembler(it is linked to just one CPU type), C# and all .NET languages (right now they are basically Windows-only), and you should be extra careful with C++ and compiled languages. Several companies provide language extensions which will be a lot of trouble if you ever decide to port your application to another platform (or simply if you decide to use another compiler). FIne example of that is microsoft's &amp;quot;safe&amp;quot; version of C string manipulation routines - &amp;quot;strcpy_s&amp;quot; and similar. They are not in C++ standard, so if you decide to port your application, you will have to write those routines yourself, or replace them with something else.  Also, all compiled languages need libraries to interact with operating system, or create GUI windows, etc. This is because that standard for those compiled languages typically doesn't define libraries for all tasks. Because of this you should be careful about what libraries you use - they shouldn't be available only on one platform.&lt;br /&gt;&lt;li&gt;Some languages (typically interpreted or high-level: java, python, etc) try to help you and do some things for you - manage memory, for example (Python, Java, etc). Other languages assume that you are the &amp;quot;smart one&amp;quot; and you know what you are doing. They don't babysit you, and you are supposed to free memory yourself (C, C++ in some cases). Some people like automatic memory management, some don't like it. Typically, if you want to have all things under your control, you won't like automatic memory management. Keep that in mind when selecting language.&lt;br /&gt;&lt;li&gt;If you want to program for web, then you will probably have to use interpreted languages: Perl, Python, PHP, JavaScript. Compiled languages can be used to the some extent, but they won't help you much. This is because PHP and Javascript are easy to integrate into page, and you can't do same thing with C++ program.&lt;br /&gt;&lt;li&gt;IF you are using Linux/Unix-like system, then the first thing you might want to learn are shell scripts. This is because they are used very frequently. Also you might want to learn Perl or Python - because they are also very popular and frequently are being used for making simple unix/linux tools.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;&lt;br /&gt;This is it. Think about all that and pick language. If you still don't know what to choose, pick anything and start studying it, but remember that you can always select another language later.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-5743378104788822453?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/5743378104788822453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/05/how-to-become-programmer-how-to-choose.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5743378104788822453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5743378104788822453'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/05/how-to-become-programmer-how-to-choose.html' title='How to become a programmer, How to choose programming language'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-9077822708384621246</id><published>2009-04-27T18:01:00.013+04:00</published><updated>2009-05-14T23:49:05.714+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='opensource'/><title type='text'>"Windows versus Linux": yet another opinion</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;It is widely known that &amp;quot;Linux vs Windows&amp;quot; is one of the most popular discussion topics. There are numerous large threads (for example, &lt;a href="http://www.linuxquestions.org/questions/general-10/the-all-new-linux-vs-windows-megasuperthread-606415/"&gt;this one&lt;/a&gt;), discussing this question. Typically such threads never end (unless they turn into flamewar, and moderators close them), and new messages are being added during many years. After reading yet another thread where several people tried to prove that &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Why is this question so popular&lt;/h2&gt;&lt;br /&gt;People keep discussing this because of (on of the) following reasons:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Because they see only better side of their operating system, and refuse to accept that there are weaknesses in their operating system. &lt;br /&gt;&lt;li&gt;Because they finally discovered that &amp;quot;there is no ideal operating system&amp;quot;, and are trying to explain it to someone else.&lt;br /&gt;&lt;li&gt;Because they don't know which OS is more suitable for them, and didn't think about using search engines&lt;br /&gt;&lt;li&gt;Because they like trolling. (Windows/Linux/MacOS users are very easy to enrage by making comments about their operating system)&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Why Linux users discuss it&lt;/h3&gt;&lt;br /&gt;(Based on personal experience, not guaranteed to be true about every user) Most linux user go through &amp;quot;fanboy&amp;quot; (or &amp;quot;euphoria&amp;quot;) phase. This typically happens within few months after user learned basic skills and medium-level system skills, used few applications, made first &lt;i&gt;useful&lt;/i&gt; shell script, learned iptables, etc.&lt;br /&gt;&lt;p&gt;For example, there is a KDE application called kstars, which displays night sky for any place on earth for any date within few thousands of years from now. It also can control telescope, and has access to large database of stars. And it is free. And you can get its' source code, read it, modify, and derive your own application from it, and sell it. Now think about it - you have very complex, cool-looking application, which can &lt;i&gt;control telescope&lt;/i&gt;, display sky for any point on earth and any date in human history, AND it is free, AND you can get source code, sell it. Even though I knew about GPL long before I discovered kstars, I couldn't understand how this is possible. And there are tons of very useful shell utilities, graphical desktops, compilers, browsers, there is web-server software, ipfilter software, and tons and tons of other utilities and all this is &lt;i&gt;free&lt;/i&gt;. If you are know at least a little bit about programming, you will be able to estimate how much it would cost to develop all this stuff. If you have some medium-level programming skills, then you will be delighted to discover that you can tear any piece of software apart, read its' source code, understand how it works and modify it. When you will understand all this, (especially if you are a programmer) your mind first will refuse to accept this(&amp;quot;how is this possible? We are paying for other software, why all this stuff is free?&amp;quot;), and then you will decide that you are in heaven and linux is the best thing ever created by mankind, so you should go forth and spread the word about opensource. &lt;p&gt;Congratulations, at this state you will become a &amp;quot;fanboy&amp;quot; which will attempt to convert all friends and relatives into using linux. This attitude will eventually wear off (it will take from several weeks to several months, depending on your personality. Some people are never cured, though).  &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Why windows users discuss it&lt;/h3&gt;&lt;br /&gt;Honestly, I have no idea. I've been using Windows for several years, and it never looked like something I would say is &amp;quot;the best operating system ever&amp;quot;.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Personal experience with both platform&lt;/h2&gt;&lt;br /&gt;&lt;h3&gt; Windows: pros and cons&lt;/h3&gt;&lt;br /&gt;Pros:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Well-known, widely spread, has most market share.&lt;br /&gt;&lt;li&gt;Supports newest hardware.&lt;br /&gt;&lt;li&gt;Has games.&lt;br /&gt;&lt;li&gt;Has visual studio (don't get me wrong - it has a bunch of really horrible features (like IntelliSense), but VS2005 had best GUI I saw since Delphi 5)&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Cons:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Price. &lt;br /&gt;&lt;li&gt;Malware. You'll need AV software to deal with malware/viruses, and not all AV packages are free.&lt;br /&gt;&lt;li&gt;For most problems solution is reinstallation&lt;br /&gt;&lt;li&gt;Reinstallation takes forever. If you have a lot of custom software, which is configured for your needs, and managed to completely kill your system (so the only reinstallation from scratch will help), then it will take up to several days to repair everything.&lt;br /&gt;&lt;li&gt;Program settings are hidden in registry, which isn't really well documented. Which means if registry is damaged, you will lose all program settings. Also, it won't be that easy to recover the registry.&lt;br /&gt;&lt;li&gt;When you discover a bug, you are not allowed to fix it, even if you can. You'll have to wait another patch, which will introduce more bugs.&lt;br /&gt;&lt;li&gt;Poor quality of desktop environment. Only one desktop, can't configure shortcuts (not on WinXP, at least).&lt;br /&gt;&lt;li&gt;Fresh installation has poor selection of software and can't do much useful. Will need codecs, etc.&lt;br /&gt;&lt;li&gt; Many system-wide actions require reboot.&lt;br /&gt;&lt;li&gt; License conditions. Average Windows (XP) machine is allowed to connect 10 network devices at once (fixing this will probably break EULA). As far as I know, there is also limit on the number of hardware upgrades.&lt;br /&gt;&lt;li&gt; Commercial software isn't guaranteed to be free from bugs, to be usable or to do what you want. See EULAs.&lt;br /&gt;&lt;li&gt; Doesn't include development tools.&lt;br /&gt;&lt;li&gt;You can't legally become better programmer by analyzing this system - source code is available, reverse-engineering s forbiddeb by EULA. Basically, it is a car where engine compartment is welded shut.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt; Linux: pros and cons&lt;/h3&gt;&lt;br /&gt;Pros:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Price.&lt;br /&gt;&lt;li&gt;Several very configurable desktop environment (always liked KDE desktop, never liked Windows desktop)&lt;br /&gt;&lt;li&gt; Supported hardware &amp;quot;Just works&amp;quot; without additional steps.&lt;br /&gt;&lt;li&gt; Large amount of software available.&lt;br /&gt;&lt;li&gt; Very good environment for a programmer (unless he/she uses .NET) Provides good opportunity to learn code, use source from real projects (instead of book examples), many languages and dozens of free tools.&lt;br /&gt;&lt;li&gt; Most problems can be fixed without reinstalling system.&lt;br /&gt;&lt;li&gt; Most actions doesn't require reboot.&lt;br /&gt;&lt;li&gt; No limit on the number of connections, number of hardware upgrades.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Cons:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Smaller selection of commercial games. However, smaller companies tend to create Linux version of games more frequently.&lt;br /&gt;&lt;li&gt;No alternative to visual studio. Quality of free IDEs will vary. However, working without IDE seems to be the best option, and even simple text editor might be used as a sufficient alternative.&lt;br /&gt;&lt;li&gt;Newest hardware frequently isn't supported - because manufacturers do not want to create drivers or doesn't provide specification.&lt;br /&gt;&lt;li&gt;Using USB devices (web-cameras, scanners, cameras) can be a real trouble. &lt;br /&gt;&lt;li&gt;You should be willing to learn something to be comfortable on Linux.&lt;br /&gt;&lt;li&gt;Less popular than windows, although frequently used in large number of network devices (routers, modems, etc)&lt;br /&gt;&lt;li&gt;Available software might not be completely finished, and probably is still in development. On other hand, this also applies to commercial software.&lt;br /&gt;&lt;li&gt;You will have to be careful when upgrading hardware - you will have to research if your hardware is supported before purchasing something. Linux will work fine on old machines, but if you have top hardware (which isn't supported yet), you might not be able to even install Linux in some cases. This issue is known to cause problems for people that suddenly decide to move from Windows to Linux.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Commonly used myths and incorrect arguments&lt;/h2&gt;&lt;br /&gt;&lt;h3&gt;General&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;My commercial applcation isn't available on your platform! Therefore, my platform is superior&amp;quot;&lt;br /&gt;&lt;p&gt;Not true. When you have application you can't live without (maybe it is your main source of income), then using this application is more important for you that choosing certain operating system. I.e. you use OS where application works, instead of using applications that work on your OS (as people normally do). This is not an OS problem.&lt;br /&gt;&lt;li&gt;&amp;quot;Average user can't use Linux!&amp;quot;&lt;br /&gt;&lt;p&gt;First, there is no &amp;quot;average user&amp;quot;. Self-proclaimed &amp;quot;experts&amp;quot; often can get stuck with basic problems, while inexperienced novices can solve difficult things because it is more interesting for them. System administrator or programmer might have problems with word processors, while someone experienced with word processor surely will have problems compiling even basic application. Every user has his/her own area of expertise, and because using computer doesn't require license, everyone can be a computer user. Which means there will be no &amp;quot;average&amp;quot;&lt;br /&gt;&lt;p&gt;Second, &amp;quot;complete newbie&amp;quot; can use Linux system in the same fashion as Windows machine. This is because configured Linux system doesn't &lt;i&gt;look&lt;/i&gt; too different from windows machine. On Windows machine you will have graphical desktop with icons and buttons, where each program is window, and each window can be moved/resized with mouse. And, guess what? On Linux it will be exactly same things: graphical desktop with icons and buttons, where each program is a window, and each window can be moved/resized with mouse (although software is slightly different). To my experience true computer newbie will operate both systems with similar level of success, and might not even realize which operating system is installed on his computer.&lt;br /&gt;&lt;li&gt;&amp;quot;Linux is more difficult to learn&amp;quot;&lt;br /&gt;&lt;p&gt;Not true. If you start from zero level on either system, you will have to spend similar amount of time to learn it (kids should have least amount of problems learning either system). No one learned windows instantly.&lt;br /&gt;&lt;li&gt;&amp;quot;Linux is only for geeks&amp;quot;&lt;br /&gt;&lt;p&gt;Isn't anymore. Linux was only for geeks when it was created. Since that time, Linux has gone a long way, and right now there are several companies attempting to make Linux into a product suitable for everyone, &amp;quot;for novices&amp;quot; or for mythical &amp;quot;average user&amp;quot;. While making a product useful for everyone isn't a good idea (what is easy to learn isn't always easy to use, and vice versa), there are couple of distributions which everyone can install from scratch.&lt;br /&gt;&lt;li&gt;&amp;quot;Linux is for everyone&amp;quot;&lt;br /&gt;&lt;p&gt;No. Linux is free, and because of this, it demands something from you. To be able to successfully master Linux system, you should be willing to learn it. If you do not want to learn, you will not master the system (although you still might be able to use it for some extent). Also, if you have to use software which doesn't work on linux, then you won't be able to keep Linux as the only operating system on your PC.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Games&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Linux don't have games!&amp;quot;&lt;br /&gt;&lt;p&gt;Linux has large amount of games. The problem is that there is a relatively small number of commercial games (examples: Doom 3, Penumbra, Unreal Tournament 2004, Quake 4, Darwinia, etc), for whatever reason. You can run &lt;i&gt;some&lt;/i&gt; of the commercial windows games using &lt;a href="http://www.winehq.org/"&gt;WINE&lt;/a&gt; software (or similar commercial derivatives), but you will get minor performance drop if game extensively uses shaders, and you will get problems if games uses certain copy protection mechanisms. However, Linux has a large amount of free games written by hobbyists. One resource for them is &lt;a href="http://www.happypenguin.org/"&gt;happypenguin.org&lt;/a&gt;. Notable examples of free Linux games include &lt;a href="http://icculus.org/alienarena/rpa/aquire.html"&gt;Alien Arena&lt;/a&gt;, &lt;a href="http://www.urbanterror.net/"&gt;Urban Terror&lt;/a&gt;, &lt;a href="http://www.warsow.net/"&gt;War$ow&lt;/a&gt;, America's Army, &lt;a href="http://www.sauerbraten.org/"&gt;Sauerbraten&lt;/a&gt;, etc.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Linux isn't suitable for making games&amp;quot:&lt;br /&gt;&lt;p&gt;It is suitable for making games. You have advanced graphic API (OpenGL, which is easier to use on Linux, because on Windows default supported OpenGL version is still 1.x), generic cross-platform framework (&lt;a href="http://www.libsdl.org/"&gt;SDL&lt;/a&gt;), several free physics engines and a bunch of similar libraries. Also there are ready to use game engines, like Ogre3D, Sauerbraten's Engine, etc. And you have tons of free tools for every gaming task. &lt;br /&gt;&lt;li&gt;&amp;quot;Windows has best games&amp;quot; or &amp;quot;Windows has better gaming experience&amp;quot;&lt;br /&gt;&lt;p&gt;This is not true. To my experience, best games are available on consoles, and PC gaming terribly suffers from one big PC problem: hardware. The problem with PC's hardware is that it is flexible, and every user will have different configuration. This will make hardware developers either spend too much time trying to make game work on every video card ever created (instead of spending this time on making better game), or place high system requirements (so you will be able to comfortably play the game only two years later after several hardware upgrades). Another problem is that there is a low number of high-quality games on PC. Latest titles I bought (Fallout 3, Spore, L4D), were clearly overhyped and didn't provide quality I expected. Sure, you will be able to spend several dozens hours playing this, but you will very quickly reach the point where you know everything and don't want to play game ever again - because there is nothing left to do and you already know how to beat it. In short: best games on PC currently are only mediocre, and I'd like to play a masterpiece. The games that are not &amp;quot;the best ones&amp;quot; focus on  graphics too much, and because of this gameplay suffers. Another problem with PC games is that once game is released, instead of playing it, you will spend most of your time tuning performance, fighting bugs and crashes, and waiting for patches that will turn game into something stable and playable. Whether you like it or not, a PC game released without bugs is a very rare sight, which spoils PC gaming experience in general. &lt;br /&gt;&lt;li&gt;&amp;quot;Linux doesn't have DirectX 10&amp;quot;&lt;br /&gt;&lt;p&gt;True. But I haven't seen a game that couldn't work without it. Every game created so far with DirectX 10 support seems to use it only for minor, small graphical improvements. I haven't seen a DirectX 10 game with a truly astonishing graphics. For example, compare Quake 1 and Quake 4. If game uses &amp;quot;superior&amp;quot; graphical API, it should provide similar increase of graphic quality. This means, that DirectX 10 game when compared to the best DirectX 9 game should look as Quake 4 when compared to Quake 1.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Hardware&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Linux supports small number of hardware&amp;quot;&lt;br /&gt;&lt;p&gt;Only partially true. Linux has a good support for large number of devices, which is provided by the kernel. Which means that on Linux system if hardware is supported, it will work out of the box. While on Windows, you will have to search for drivers. Buy a new ethernet card, install it in WinXP machine and you will have to search for a driver. And if you've just installed windows on completely new computer, you will have to search for several drivers. Until you find all of them - your machine might stand here without sound and network access. On Linux this card will work right now. &lt;br /&gt;&lt;p&gt;However, Linux does have trouble with new hardware, USB devices (cheap web-cameras, scanners, force feedback on joysticks). This is because most hardware manufacturers don't support Linux, and don't provide specifications for writing drivers. Which means, some time will have to pass before someone reverse-engineer device protocol and write a Linux driver for it. Which means when you decide to upgrade your computer, you will have to check if new hardware is supported or not. &lt;br /&gt;&lt;p&gt;On other hand, situation with hardware on windows isn't that great. For some reason, with each year driver packages tend to become larger and larger. Sometimes, just one driver takes more megabytes than entire Linux kernel. If you have a very fast connection, this won't be a problem, but if your internet speed is below 500kbps, this will quickly become annoying. Also, many windows drivers are buggy. I was very surprised to discover than on WinXP my &amp;quot;Vista Certified&amp;quot; motherboard produces slightly noisy sound (can't be fixed), while on Linux same problem doesn't exist, I have better sound quality, although motherboard isn't officially supported.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Software&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Linux doesn't have any good software&amp;quot;&lt;br /&gt;&lt;p&gt;On contrary, amount of Linux software is quite large. Currently average Linux distribution includes Word Processor, compiler, several music players, several different image editors, several IDEs, and several  desktop environments on the same DVD. So when you install it, you have ready to use working environment. On windows, after first installation you'll have empty machine that can't do much useful - you'll have to spend several hours installing codecs, Adobe Acrobat, your Office Suite, IDE, normal music player, and so on. The downside of all this is that most of the linux software is provided &amp;quot;as is, without warranty of any kind&amp;quot;, and many programs are still in development. Which means some of them might have unfinished features, etc. &lt;br /&gt;&lt;li&gt;&amp;quot;I don't want to compile software&amp;quot;&lt;br /&gt;&lt;p&gt;On large number of distributions, software is installed via package manager - you won't have to compile anything (unless you are using Gentoo, LFS or Slackware). However, it is highly recommended to learn how to compile programs manually - sometimes software might not be available via package manager.&lt;br /&gt;&lt;li&gt;&amp;quot;Compiling software on Linux takes hours&amp;quot;&lt;br /&gt;&lt;p&gt;Not on modern hardware. Only largest packages (Qt 4, KDE, etc) might take hours to build. Normally software compiles within 5..15 minutes.&lt;br /&gt;&lt;li&gt;&amp;quot;I don't want to compile kernel on Linux&amp;quot;&lt;br /&gt;&lt;p&gt;You don't have to compile kernel. Most distribution already provide properly tune kernel for you. Unless you want to make your machine a bit faster, you don't want to attempt rebuilding kernel yourself.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Communities&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;If something breaks on Linux, community will help you&amp;quot;&lt;br /&gt;&lt;p&gt;Not quite true. Community will &lt;i&gt;try&lt;/i&gt; to help you. However, people in communities are mostly volunteers, and they might refuse to help you if:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;You didn't read and apply rules from &lt;a href="http://www.catb.org/~esr/faqs/smart-questions.html"&gt;&amp;quot;How to ask questions the smart way&amp;quot;&lt;/a&gt;&lt;br /&gt;&lt;li&gt;You haven't tried to fix problem yourself.&lt;br /&gt;&lt;li&gt;You didn't ask question properly (&amp;quot;Help me, please&amp;quot; is not a good idea);&lt;br /&gt;&lt;li&gt;You just wish someone fix your problem for you (and for free).&lt;br /&gt;&lt;li&gt;You complain about things, and say something like &amp;quot;This didn't happen on windows&amp;quot;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Also, quality of community (skill, knowledge level) depends on distribution. As far as I know, most helpful/skillful people use most difficult distributions (Gentoo, Slackware), however they may be a bit strict about the &amp;quot;rules&amp;quot;, and you will have to ask question properly (and read &amp;quot;How to ask questions smart way&amp;quot; - it isn't that hard) to get high quality help. On other hand, communities that use &amp;quot;simpler&amp;quot; and &amp;quot;friendlier&amp;quot; distributions are not guaranteed to have skilled users (personally, I had serious trouble with advanced questions on Ubuntu communities).&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Licensing and philosophy&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&amp;quot;Open Source is the way software all should be distributed! It is the future!&amp;quot;:&lt;br /&gt;&lt;p&gt;Unfortunately, this isn't true. Open Source software has one serious problem: you can't earn serious amount of money by making programs and selling them. Don't get me wrong: you still can earn some cash from donations, or by selling merchandise (T-shirts, toys, gadgets) which is somehow associated with you program, or you can sell CDs/DVDs with that program, but you can't sell the program. At least, not with &lt;a href="http://www.gnu.org/copyleft/gpl.html"&gt;GPL&lt;/a&gt;. Of course, &lt;a href="www.gnu.org/copyleft/gpl.html"&gt;GPL&lt;/a&gt; allows you to &amp;quot;sell&amp;quot; programs, but once you do this, anyone can resell your program for lower price, or give it away for free in &lt;i&gt;unlimited quantities&lt;/i&gt;. I believe this is one of the reasons why large software companies aren't releasing their products under &lt;a href="www.gnu.org/copyleft/gpl.html"&gt;GPL&lt;/a&gt;. Of course, there are other licenses, like BSD license, but software under those licenses can be easily converted into proprietary. So, although Open Source is (in &lt;i&gt;some&lt;/i&gt; cases) good for software development, it isn't really good for software developers. I don't think you can make the living by developing your own OpenSource software. &lt;br /&gt;&lt;p&gt;Another problem is that OpenSource doesn't seem to be suitable for at least one kind of projects: games. Sure, there are many good games made by individual developers, but I haven't seen a sophisticated OpenSource game with a great story, music, gameplay and art. I'd love to see gaming masterpiece (for example, something comparable to &amp;quot;Max Payne&amp;quot;, &amp;quot;Silent Hill 2&amp;quot;, &amp;quot;The Movies&amp;quot;, etc) developed under OpenSource license, but it looks like such game doesn't exist. Another interesting thing is that good OpenSource games (for example, &lt;a href="http://www.warsow.net/"&gt;War$ow&lt;/a&gt;) use different license for their art, music and models, and typically this license is proprietary. Which makes me believe that OpenSource isn't suitable for making games, only for making game engines (which is different story).&lt;br /&gt;&lt;li&gt;&amp;quot;Proprietary software always is the best!&amp;quot;&lt;br /&gt;&lt;p&gt;Unfortunately it also isn't true. When some software is being developed by a single company, they control the course of software development. While it is exactly what you would want in game development, it isn't always good for other kinds of software. Software developer might decide to add flashy GUI with dozen of bugs instead of making software more useful for &lt;i&gt;you&lt;/i&gt;. Or it might decide to change course of development, so the next version of software will not meet your requirements anymore, but will appeal to larger audience. And another problem with proprietary software is that once it is broken, you are not allowed to fix it, even if you can do it. And Let's not forget various licensing and DRM problems. However, this was already discussed many times.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Truth&lt;/h2&gt;&lt;br /&gt;The truth is that there is no &amp;quot;the best&amp;quot; operating system. Every OS that is available has problems in one or another area. User's goal is to pick operating system that doesn't have problems in important (for that user) area. For example, if you don't use some windows application, lack of its' alternative on Linux won't be a problem for you. Or if you don't use some linux utilities (dd, mount, iptables, cron), their unavailability on Windows won't be a problem for you.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;So, What should I do about all this?&lt;/h2&gt;&lt;br /&gt;Nothing. &amp;quot;Linux vs Windows&amp;quot; appears again and again and again. People keep using same arguments over. Some people provide a very lengthy, detailed responses which cover common problems and provide a really good comparison of operating system, but large amount of people don't read them, and simply jump in discussion to prove their point. So the best thing you can do about those discussions is never participate in them.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Links&lt;/h2&gt;&lt;br /&gt;&lt;a href="http://linux.oneandoneis2.org/LNW.htm"&gt;Linux is not Windows&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.catb.org/~esr/faqs/smart-questions.html"&gt;How to ask questions the smart way&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-9077822708384621246?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/9077822708384621246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/versus-linux-yet-another-opinion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/9077822708384621246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/9077822708384621246'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/versus-linux-yet-another-opinion.html' title='&amp;quot;Windows versus Linux&amp;quot;: yet another opinion'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-5164117563938698474</id><published>2009-04-19T18:03:00.004+04:00</published><updated>2009-04-19T18:38:19.638+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='time-management'/><category scheme='http://www.blogger.com/atom/ns#' term='self-improvement'/><category scheme='http://www.blogger.com/atom/ns#' term='life'/><category scheme='http://www.blogger.com/atom/ns#' term='time'/><title type='text'>Time management: how to get things done (if lists doesn't help you)</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;Although this blog is supposed to be mostly about programming, I decided to post one &amp;quot;self-improvement&amp;quot; tip which was useful for me.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Standard approach&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Everyone(or most people know) know that normal way to deal with tons of things you should do today is to make a &amp;quot;to do&amp;quot; list for every day. In ideal case you should have several lists - list of long-term goals (lifetime), mid-term goals (several years), short-term goals(several months) and list of things that should be done right now (today, during this week, etc). Every day your to do list should contain several items from each list (or items that will bring you closer to reaching goal from each list), that should be written down according to their priority. I.e. if your mid-term goal is to learn new language, and immediate goal is to buy food, your daily to-do list should have one item for each of those goals. This looks neat, easy enough, however as I found out, there will be several problems.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Problems&lt;/h2&gt;&lt;br /&gt;Typically with standard to-do list, following problems arise:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;One item from the list takes too much time or even all your time.&lt;br /&gt;&lt;li&gt;You don't really want to do that right now.&lt;br /&gt;&lt;li&gt;One of the items on the list looks like it will take too much time today, so you decide to do it tomorrow. Tomorrow, same things happens again. As a result task is not being completed within weeks or months.&lt;br /&gt;&lt;li&gt;You have too many long-term goals, and can finish anything, because they all take too much time, and can't be finished during one day.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Part of those problems arise from natural laziness - your consciousness (or subconsciousness) will invent various excuses to prevent you from doing anything useful. It is hard to understand why your own mind is against you, but this thing happens.  Another part of problems will happen when you will incorrectly estimate time required to finish the task. Also, life is full of surprises, and it is quite possible that something will get in your way and you won't be able to finish some important task today because of external events.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Solution&lt;/h2&gt;&lt;br /&gt;There is a very easy solution for those problems (I haven't seen it written anywhere, which is why I've decided to post this thing here): when you make your daily &amp;quot;to-do&amp;quot; list, for each task write down how much time you will spend on it today. For example, if you are learning new language, (to my opinion) you will learn a lot if you will exercise for 30 minutes every day.&lt;br /&gt;When you start your day, for each task spend as much time as you wrote down in your to do list (Unless you finish the task faster than you expected). Of course, this time you should seriously work on the problem without fooling around, without being distracted, etc. If you won't finish task in time, proceed to the next task, and put unfinished task on tomorrow's &amp;quot;to do&amp;quot; list (you might want to adjust time according to today's experience). If you have a lot of tasks for today, you can spend 30 minutes for each. 30 minutes isn't much, but you still can do a lot during this time.&lt;br /&gt;This approach is incredibly useful for a very long goals (write a large program, learn language, study something huge, etc). At least it works for me, so I think it will be useful for someone else.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-5164117563938698474?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/5164117563938698474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/time-management-how-to-get-things-done.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5164117563938698474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/5164117563938698474'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/time-management-how-to-get-things-done.html' title='Time management: how to get things done (if lists doesn&apos;t help you)'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-8378465650389385193</id><published>2009-04-18T02:49:00.004+04:00</published><updated>2009-04-18T03:40:22.190+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rant'/><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='criticism'/><category scheme='http://www.blogger.com/atom/ns#' term='opensource'/><title type='text'>The most annoying problems in Mozilla Firefox 3.0.6</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;Many people love Mozilla Firefox. For some reason it surpasses opera browser in popularity (or at least, it is said so) - possibly because it might be better than IE, or perhaps because of number of extensions, or because Firefox is yet another example of OpenSource philosophy.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;List of problems&lt;/h2&gt;&lt;br /&gt;However, it has some problems that are clearly not going to disappear any time soon.&lt;br /&gt;Below is the list of those problems. All problems happen on dualcore linux machine with 2Gb of RAM. Most of them exist on Windows XP as well. So you can't blame hardware or operating system.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;1. Bug with resizing windows.&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;How to reproduce: open any Firefox dialog (preferences, or whatever). Now drag bottom right corner of dialog to the left and up. See what happens:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7W182WvO8Qw/SekJOR1hLpI/AAAAAAAAAAM/t0V64NLL5oQ/s1600-h/bug.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 241px;" src="http://2.bp.blogspot.com/_7W182WvO8Qw/SekJOR1hLpI/AAAAAAAAAAM/t0V64NLL5oQ/s320/bug.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5325798175253016210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Typically this is a standard problem which occurs in GUI applications made by beginner programmer. However, in Firefox this bug has exists at least since 2.0.0.x version.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;2. Slow startup&lt;/h3&gt; &lt;br /&gt;Firefox 3.0.6 takes at least 8 seconds to start up, more if it is started from &amp;quot;cold boot&amp;quot;. On my system &amp;quot;cold boot&amp;quot; launch of firefox takes at least 15 seconds. This is quite annoying.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;3. Firefox frequently stops responding&lt;/h3&gt;&lt;br /&gt;Firefox frequently stops responding for a very long time. 10, perhaps 30 seconds. Normally this happens when you type something into &amp;quot;location bar&amp;quot; - there is a very good probability that browser will hang in the middle of the word, won't accept any input for quite a while, and even won't repaint browser window. After &amp;quot;sleeping&amp;quot; for quite some time browser will suddenly wake up and finally show the rest of the phrase you were trying to enter. Firefox also stops responding for prolonged period when you open history. Or when you try to search history. Or when you attempt to close browser (which can be seen &lt;a href="http://img254.imageshack.us/img254/8138/firefoxhang.png"&gt;here&lt;/a&gt;). It also happens randomly when you try to load pages. It looks like problem is related to the way how browser history is stored. The problem exists since the first release of Firefox 3.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;4. It is not possible to right-click link on the page when another page is loading&lt;/h3&gt;&lt;br /&gt;This is the only problem which exists on Linux only - It is not possible to right click a link on the page in the tab if another page is about to load. Doesn't sound like a big problem, but it is still annoying.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;5. It is not possible to disable javascript when &amp;quot;alert&amp;quot; is being shown&lt;/h3&gt;&lt;br /&gt;Without adding more extensions it is not possible to disable javascript when you see alert shown by javascript. Have you ever run into a script which launches series of &amp;quot;alert&amp;quot; messages? When you run into such webpage, you will easily notice the problem.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;6. No reasonable keyboard navigation&lt;/h3&gt;&lt;br /&gt;Caret mode is a joke - it is simply too slow when using from keyboard. And although it is possible to instantly focus to individual tab using  keyboard shortcut (which is good), it isn't possible to navigate page with reasonable speed using keyboard only. For example, in Opera you can quickly navigate between links on the page if you use Shift+Arrow Keys, in firefox this feature is still missing.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;7. Page loses focus for some reqson&lt;/h3&gt;&lt;br /&gt;On completely random occasions interesting thing happens: you can't jump to location bar using keyboard shortcut unless you first click on the page with mouse. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;8. Stops responding to keyboard shortucts when flash movie is shown&lt;/h3&gt;&lt;br /&gt;When there is a flash content on the website, it is possible that you won't be able to close tab with this content using keyboard shortucts (Ctrl+F4 or Ctrl+W), unless you first click on the page somewhere outside of the flash content. Same things seems to happen with java applets as well. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;9. It is not possible focus to "find" box without mouse if you view image&lt;/h3&gt;&lt;br /&gt;Assume you were viewing some page, tried to find some text on it (using Ctrl+F) and then opened some image in the same tab. You will notice that &amp;quot;Search&amp;quot; window is still present at the bottom of the screen. On normal page, to dismiss it without using mouse by pressing Ctrl+F (which will move text entyr cursor into search bar), and the &amp;quot;Escape&amp;quot; In case of image this won't work - you'll have to click on the text in search bar, then press &amp;quot;Escape&amp;quot;. Happens frequently.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;10. When saving picture to hard disk, it looks like it is being downloaded again&lt;/h3&gt;&lt;br /&gt;This is simply illogical. When you right click on any image and attempt to save it to disk, &amp;quot;Downloads&amp;quot; window will appear. On window platform picture will be even scanned by antivirus. I just don't understand why this works this way. Picture is already inside of browser cache, so there is no reason to downlaod it again - it will simply take longer.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;&lt;br /&gt;So far I know the only two reasons to use firefox&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; Ad Block plus&lt;br /&gt;&lt;li&gt; some plugin which is supported only on Firefox.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Other than that, Firefox 3 gives the impression of unfinished and unpolished product with a lot of problems, several bugs, and very poor support for keyboard-only navigation.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-8378465650389385193?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/8378465650389385193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/most-annoying-problems-in-mozilla.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/8378465650389385193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/8378465650389385193'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/04/most-annoying-problems-in-mozilla.html' title='The most annoying problems in Mozilla Firefox 3.0.6'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7W182WvO8Qw/SekJOR1hLpI/AAAAAAAAAAM/t0V64NLL5oQ/s72-c/bug.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-3923783486129758739</id><published>2009-03-25T21:50:00.003+03:00</published><updated>2009-03-25T22:47:07.835+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='snippet'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>How to use sprintf/wsprintf with std::string/std::wstring</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;&lt;h3&gt;Explanation&lt;/h3&gt;&lt;br /&gt;One of the few problems with &lt;a href="http://www.cplusplus.com/reference/string/string/"&gt;&lt;i&gt;std::string&lt;/i&gt;&lt;/a&gt; (and &lt;i&gt;std::wstring&lt;/i&gt;) class in C++ is the lack of &lt;a href="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html"&gt;sprintf&lt;/a&gt; function that would return &lt;a href="http://www.cplusplus.com/reference/string/string/"&gt;&lt;i&gt;std::string&lt;/i&gt;&lt;/a&gt; as result. Or sprintf-styled constructor would be nice to have. Of course, there are many alternatives to sprintf - &lt;a href="http://www.boost.org/doc/libs/1_38_0/libs/format/index.html"&gt;boost format library&lt;/a&gt;, sstream class and &lt;a href="http://doc.trolltech.com/4.5/qstring.html"&gt;QString&lt;/a&gt; class in &lt;a href="http://doc.trolltech.com/4.5/index.html"&gt;Qt 4&lt;/a&gt;, but so far plain old &lt;a href="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html"&gt;sprintf&lt;/a&gt; is most compact and easy when compared to them. &lt;i&gt;sstream&lt;/i&gt; requires several statements(lines) to make a simple formatted string. Unless you like it too much, it is an overkill for making small formatted string. &lt;a href="http://www.boost.org/doc/libs/1_38_0/libs/format/index.html"&gt;Boost format library&lt;/a&gt; will require &lt;a href="http://www.boost.org/"&gt;boost&lt;/a&gt; or a part of it.  And &lt;a href="http://doc.trolltech.com/4.5/index.html"&gt;Qt 4&lt;/a&gt; &lt;a href="http://doc.trolltech.com/4.5/qstring.html"&gt;QString&lt;/a&gt; class will require entire Qt installation, acceptance of one of few available licenses, and it still won't be as compact as &lt;a href="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html"&gt;sprintf&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Solution&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The first thing that comes to mind is to create temporary buffer, sprintf into buffer, and then assign buffer to &lt;i&gt;std::string&lt;/i&gt; class. When your programs grows, you'll eventually get sick of many temporary buffers, besides it would still require few lines of code. Here is better way to do that:&lt;br /&gt;Str.h:&lt;br /&gt;&lt;pre style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;&lt;br /&gt;#ifndef STR_H&lt;br /&gt;#define STR_H&lt;br /&gt;#include &lt;string&gt;&lt;br /&gt;&lt;br /&gt;typedef std::string Str;&lt;br /&gt;typedef std::wstring WStr;&lt;br /&gt;&lt;br /&gt;WStr swprintf(const wchar_t* format, ...);&lt;br /&gt;WStr vswprintf(const wchar_t* format, va_list args);&lt;br /&gt;WStr swprintf(const WStr&amp; format, ...);&lt;br /&gt;WStr vswprintf(const WStr&amp; format, va_list args);&lt;br /&gt;&lt;br /&gt;Str sprintf(const char* format, ...);&lt;br /&gt;Str vsprintf(const char* format, va_list args);&lt;br /&gt;Str sprintf(const Str&amp; format, ...);&lt;br /&gt;Str vsprintf(const Str&amp; format, va_list args);&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Str.cpp:&lt;br /&gt;&lt;pre style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;&lt;br /&gt;#include "Str.h"&lt;br /&gt;&lt;br /&gt;WStr swprintf(const wchar_t* format, ...){&lt;br /&gt; va_list args;&lt;br /&gt; va_start(args, format);&lt;br /&gt; WStr result = vswprintf(format, args);&lt;br /&gt; va_end(args);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;WStr vswprintf(const wchar_t* format, va_list args){&lt;br /&gt; const int bufferSize = 16384;&lt;br /&gt; wchar_t buffer[bufferSize];&lt;br /&gt; vswprintf(buffer, bufferSize, format, args);&lt;br /&gt; return WStr(buffer);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;WStr swprintf(const WStr&amp; format, ...){&lt;br /&gt; va_list args;&lt;br /&gt; va_start(args, format);&lt;br /&gt; WStr result = vswprintf(format, args);&lt;br /&gt; va_end(args);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;WStr vswprintf(const WStr&amp; format, va_list args){&lt;br /&gt; return vswprintf(format.c_str(), args);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Str sprintf(const char* format, ...){&lt;br /&gt; va_list args;&lt;br /&gt; va_start(args, format);&lt;br /&gt; Str result = vsprintf(format, args);&lt;br /&gt; va_end(args);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Str vsprintf(const char* format, va_list args){&lt;br /&gt; const int bufferSize = 16384;&lt;br /&gt; char buffer[bufferSize];&lt;br /&gt; vsnprintf(buffer, bufferSize, format, args);&lt;br /&gt; return Str(buffer);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Str sprintf(const Str&amp; format, ...){&lt;br /&gt; va_list args;&lt;br /&gt; va_start(args, format);&lt;br /&gt; Str result = vsprintf(format, args);&lt;br /&gt; va_end(args);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Str vsprintf(const Str&amp; format, va_list args){&lt;br /&gt; return vsprintf(format.c_str(), args);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This will allow to quickly create formatted string in one function call.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Problems:&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;This code works with gcc on Linux system, but it might require some tweaking on different compilers. For example, &lt;a href="http://www.mingw.org"&gt;mingw&lt;/a&gt; version of vswprintf has different number of arguments (it doesn't have &amp;quot;buffer size&amp;quot; argument), so it will need to be replaced by another function. In general, wchar_t-based printf functions might cause problems when making cross-platform application. For example, swnprintf exists on MSVC compiler but is missing in gcc. On other hand, default version of vswprintf used in MinGW compiler doesn't have &amp;quot;buffer size&amp;quot; argument, so it is vulnerable to buffer overruns (linux version of function doesn't have this problem).&lt;br /&gt;And yet another problem is that linux/windows versions of wprintf-related functions might handle %s and %S differently. As I remember, in mingw compiler %S in swprintf does the same thing as %s in linux version of printf and vise versa. Those problems can be partially fixed by using few hacks, but people making portable applications with swprintf should be aware of those problems.&lt;br /&gt;&lt;br /&gt;Another problem is that there is hard-coded size limit for created strings (it can be changed, but it still doesn't look &amp;quot;nice&amp;quot; when used with C++ string classes. This problem can be bypassed for std::string classes (by using vsnprintf which returns how much characters could not be written in buffer, so you could allocate buffer dynamically, then sprintf into it, and then assign it to std::string), but not for std::wstring (vswnprintf is not available on gcc, doesn't look like standard).&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Other solutions&lt;/h3&gt;&lt;br /&gt;To my opinion, the best (not the fastest) way to make custom sprintf for std::string classes is probably to write it from scratch (in C++ it might be easier) or derive from existing C implementation of sprintf (for example, you can take one out of freebsd source repository). The reason for that is that several printf implementations might have differences. The problem here is that it won't be easy, and you probably will need some time to write standard-compliant (or &amp;quot;format-compliant&amp;quot;) version of swprintf/sprintf which will operate on std::string/std::wstring. Of course, you can also implement limited version of those functions.&lt;br /&gt;&lt;br /&gt;Another way is to make your own formatting routines or use already mentioned ones: boost format library, QString or sstream. This way you won't get sprintf function, but few formatting routines to use instead.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-3923783486129758739?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/3923783486129758739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-use-sprintfwsprintf-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/3923783486129758739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/3923783486129758739'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-use-sprintfwsprintf-with.html' title='How to use sprintf/wsprintf with std::string/std::wstring'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-1657685302001070468</id><published>2009-03-07T20:46:00.005+03:00</published><updated>2009-03-07T23:58:44.636+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='snippet'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>how to find identical files on Linux using python script</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;In situation where you have two directories (A &amp; B) with a lot of files, where some files in B directory are same as some files in A directory, you can use this python script to find identical files.&lt;br /&gt;&lt;br /&gt;find_identical.py:&lt;br /&gt;&lt;pre style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;#!/usr/bin/env python&lt;br /&gt;import os&lt;br /&gt;import sys&lt;br /&gt;import commands&lt;br /&gt;#import string&lt;br /&gt;&lt;br /&gt;if len(sys.argv) != 3:&lt;br /&gt;    print """not enough arguments!&lt;br /&gt;usage: find_identical.py source destination"""&lt;br /&gt;    exit(0)&lt;br /&gt;&lt;br /&gt;src=sys.argv[1]&lt;br /&gt;dest=sys.argv[2]&lt;br /&gt;&lt;br /&gt;#print "src: %s, dest: %s" % (src, dest)&lt;br /&gt;print "#!/bin/sh"&lt;br /&gt;&lt;br /&gt;srcText = commands.getoutput("md5sum %s/*" % src)&lt;br /&gt;destText = commands.getoutput("md5sum %s/*" % dest)&lt;br /&gt;&lt;br /&gt;def dictFromString(val):&lt;br /&gt;    lines = val.split("\n")&lt;br /&gt;    result = {}&lt;br /&gt;    for line in lines:&lt;br /&gt;        line = line.split()&lt;br /&gt;        result[line[0]] = line[1]&lt;br /&gt;    return result&lt;br /&gt;&lt;br /&gt;def listFromString(val):&lt;br /&gt;    result = val.split("\n")&lt;br /&gt;    for i in range(len(result)):&lt;br /&gt;        result[i] = result[i].split();&lt;br /&gt;    return result;&lt;br /&gt;&lt;br /&gt;srcDict = dictFromString(srcText)&lt;br /&gt;destList = listFromString(destText)&lt;br /&gt;filesFound = False&lt;br /&gt;for file in destList:&lt;br /&gt;    if srcDict.has_key(file[0]):&lt;br /&gt;        print "rm \"%s\" #identical to %s" % (file[1], srcDict[file[0]])&lt;br /&gt;        filesFound = True;&lt;br /&gt; &lt;br /&gt;if not filesFound:&lt;br /&gt;    print "#no identical files found"&lt;br /&gt;    exit(1)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Script needs two arguments - name of first and second directory. By default script prints (to standard output) shell script that would remove files from B directory which present in A directory.&lt;br /&gt;So, to remove files from B which already present in A, you'll need to run:&lt;br /&gt;&lt;pre style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;find_identical.py A B &gt;applychanges.sh&lt;br /&gt;bash applychanges.sh&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This done this way so you can examine list of files which will be removed before removing them. This behavior can be easily changed by modifying line:&lt;br /&gt;&lt;pre style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt; print "rm \"%s\" #identical to %s" % (file[1], srcDict[file[0]])&lt;/pre&gt;&lt;br /&gt;to something you need.&lt;br /&gt;&lt;br /&gt;Script needs md5sum to work.&lt;br /&gt;Notice, that there is already linux software available that does same thing (finds identical files). So this script is mostly useful for learning python, or as base for making another script.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-1657685302001070468?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/1657685302001070468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-find-identical-files-on-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1657685302001070468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1657685302001070468'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-find-identical-files-on-linux.html' title='how to find identical files on Linux using python script'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-6793112003731215065</id><published>2009-03-07T20:24:00.003+03:00</published><updated>2009-03-07T20:34:38.877+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>How to find largest file in directory on Linux system</title><content type='html'>If you run out of disk space and would like to know which files took the most of it, us following command.&lt;br /&gt;&lt;br /&gt;In terminal "cd" into any folder (or your home folder) and type:&lt;br /&gt;&lt;pre class="bbcodeblock" style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;du -sm *|sort -nr|less&lt;/pre&gt;&lt;br /&gt;or&lt;br /&gt;&lt;pre class="bbcodeblock" style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; text-align: left;"&gt;du -sm *|sort -nr|head&lt;/pre&gt;&lt;br /&gt;Explanation:&lt;br /&gt;&amp;quot;&lt;i&gt;du -sm *&lt;/i&gt;&amp;quot; returns how many megabytes file takes - for all files and directories within current directory.&lt;br /&gt;&amp;quot;&lt;i&gt;sort -nr&lt;/i&gt;&amp;quot; sorts list according to the value of the first column (which is size in megabytes), and puts largest files first.&lt;br /&gt;&amp;quot;&lt;i&gt;less&lt;/i&gt;&amp;quot; is used to scroll output using cursor keys.&lt;br /&gt;&amp;quot;&lt;i&gt;head&lt;/i&gt;&amp;quot; is used if you want to print only first largest files.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-6793112003731215065?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/6793112003731215065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-find-largest-file-in-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/6793112003731215065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/6793112003731215065'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-find-largest-file-in-directory.html' title='How to find largest file in directory on Linux system'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-7642479908823145029</id><published>2009-03-07T04:17:00.005+03:00</published><updated>2009-03-07T04:59:21.336+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='snippet'/><category scheme='http://www.blogger.com/atom/ns#' term='utf8'/><category scheme='http://www.blogger.com/atom/ns#' term='source'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='stl'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ utf8 to wstring conversion routine</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;Some time ago I was looking for C++ conversion routine that could convert utf8 string(stored in std::string) into std::wstring and vice versa. It is certainly possible to do that using setlocale and some C functions, but I wanted something done in "pure C++". I &lt;a href="http://www.linuxquestions.org/questions/programming-9/wstring-utf8-conversion-in-pure-c-701084/"&gt;did some research&lt;/a&gt;, didn't find anything, and after all wrote conversion routine myself (using&lt;a href="http://en.wikipedia.org/wiki/Utf8"&gt; information on wikipedia&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;br /&gt;&lt;hr width="50%" align="center"&gt;&lt;br /&gt;Str.h:&lt;br /&gt;&lt;pre class="bbcodeblock" dir="ltr" style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; height: 242px; text-align: left;"&gt;#ifndef STR_H&lt;br /&gt;#define STR_H&lt;br /&gt;#include &lt;string&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;&lt;br /&gt;typedef std::string Str;&lt;br /&gt;typedef std::wstring WStr;&lt;br /&gt;&lt;br /&gt;std::ostream&amp;amp; operator&lt;&lt;(std::ostream&amp;amp; f, const WStr&amp;amp; s); std::istream&amp;amp; operator&gt;&gt;(std::istream&amp;amp; f, WStr&amp;amp; s);&lt;br /&gt;void utf8toWStr(WStr&amp;amp; dest, const Str&amp;amp; src);&lt;br /&gt;void wstrToUtf8(Str&amp;amp; dest, const WStr&amp;amp; src);&lt;br /&gt;&lt;br /&gt;#endif&lt;/iostream&gt;&lt;/string&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr width="50%" align="center"&gt;&lt;br /&gt;Str.cpp:&lt;br /&gt;&lt;pre class="bbcodeblock" dir="ltr" style="border: 1px inset ; margin: 0px -99999px 0px 0px; padding: 3px; overflow: auto; width: 98%; height: 498px; text-align: left;"&gt;/*&lt;br /&gt;Copyright (c) 2009 SegFault aka "ErV" (altctrlbackspace.blogspot.com)&lt;br /&gt;&lt;br /&gt;Redistribution and use of this source code, with or without modification, is&lt;br /&gt;permitted provided that the following conditions are met:&lt;br /&gt;&lt;br /&gt;1. Redistributions of source code must retain the above copyright&lt;br /&gt; notice, this list of conditions and the following disclaimer.&lt;br /&gt;&lt;br /&gt;THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED&lt;br /&gt;WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF&lt;br /&gt;MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO&lt;br /&gt;EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,&lt;br /&gt;SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;&lt;br /&gt;OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,&lt;br /&gt;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR&lt;br /&gt;OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF&lt;br /&gt;ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;*/&lt;br /&gt;#include "Str.h"&lt;br /&gt;#ifdef UTF8TEST&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;void utf8toWStr(WStr&amp;amp; dest, const Str&amp;amp; src){&lt;br /&gt; dest.clear();&lt;br /&gt; wchar_t w = 0;&lt;br /&gt; int bytes = 0;&lt;br /&gt; wchar_t err = L'�';&lt;br /&gt; for (size_t i = 0; i &lt; src.size(); i++){&lt;br /&gt;  unsigned char c = (unsigned char)src[i];&lt;br /&gt;  if (c &lt;= 0x7f){//first byte&lt;br /&gt;   if (bytes){&lt;br /&gt;    dest.push_back(err);&lt;br /&gt;    bytes = 0;&lt;br /&gt;   }&lt;br /&gt;   dest.push_back((wchar_t)c);&lt;br /&gt;  }&lt;br /&gt;  else if (c &lt;= 0xbf){//second/third/etc byte&lt;br /&gt;   if (bytes){&lt;br /&gt;    w = ((w &lt;&lt; 6)|(c &amp;amp; 0x3f));&lt;br /&gt;    bytes--;&lt;br /&gt;    if (bytes == 0)&lt;br /&gt;     dest.push_back(w);&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;    dest.push_back(err);&lt;br /&gt;  }&lt;br /&gt;  else if (c &lt;= 0xdf){//2byte sequence start&lt;br /&gt;   bytes = 1;&lt;br /&gt;   w = c &amp;amp; 0x1f;&lt;br /&gt;  }&lt;br /&gt;  else if (c &lt;= 0xef){//3byte sequence start&lt;br /&gt;   bytes = 2;&lt;br /&gt;   w = c &amp;amp; 0x0f;&lt;br /&gt;  }&lt;br /&gt;  else if (c &lt;= 0xf7){//3byte sequence start&lt;br /&gt;   bytes = 3;&lt;br /&gt;   w = c &amp;amp; 0x07;&lt;br /&gt;  }&lt;br /&gt;  else{&lt;br /&gt;   dest.push_back(err);&lt;br /&gt;   bytes = 0;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; if (bytes)&lt;br /&gt;  dest.push_back(err);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void wstrToUtf8(Str&amp;amp; dest, const WStr&amp;amp; src){&lt;br /&gt; dest.clear();&lt;br /&gt; for (size_t i = 0; i &lt; src.size(); i++){&lt;br /&gt;  wchar_t w = src[i];&lt;br /&gt;  if (w &lt;= 0x7f)&lt;br /&gt;   dest.push_back((char)w);&lt;br /&gt;  else if (w &lt;= 0x7ff){&lt;br /&gt;   dest.push_back(0xc0 | ((w &gt;&gt; 6)&amp;amp; 0x1f));&lt;br /&gt;   dest.push_back(0x80| (w &amp;amp; 0x3f));&lt;br /&gt;  }&lt;br /&gt;  else if (w &lt;= 0xffff){&lt;br /&gt;   dest.push_back(0xe0 | ((w &gt;&gt; 12)&amp;amp; 0x0f));&lt;br /&gt;   dest.push_back(0x80| ((w &gt;&gt; 6) &amp;amp; 0x3f));&lt;br /&gt;   dest.push_back(0x80| (w &amp;amp; 0x3f));&lt;br /&gt;  }&lt;br /&gt;  else if (w &lt;= 0x10ffff){&lt;br /&gt;   dest.push_back(0xf0 | ((w &gt;&gt; 18)&amp;amp; 0x07));&lt;br /&gt;   dest.push_back(0x80| ((w &gt;&gt; 12) &amp;amp; 0x3f));&lt;br /&gt;   dest.push_back(0x80| ((w &gt;&gt; 6) &amp;amp; 0x3f));&lt;br /&gt;   dest.push_back(0x80| (w &amp;amp; 0x3f));&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;   dest.push_back('?');&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Str wstrToUtf8(const WStr&amp;amp; str){&lt;br /&gt; Str result;&lt;br /&gt; wstrToUtf8(result, str);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;WStr utf8toWStr(const Str&amp;amp; str){&lt;br /&gt; WStr result;&lt;br /&gt; utf8toWStr(result, str);&lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;std::ostream&amp;amp; operator&lt;&lt;(std::ostream&amp;amp; f, const WStr&amp;amp; s){&lt;br /&gt; Str s1;&lt;br /&gt; wstrToUtf8(s1, s);&lt;br /&gt; f &lt;&lt; s1;&lt;br /&gt; return f;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;std::istream&amp;amp; operator&gt;&gt;(std::istream&amp;amp; f, WStr&amp;amp; s){&lt;br /&gt; Str s1;&lt;br /&gt; f &gt;&gt; s1;&lt;br /&gt; utf8toWStr(s, s1);&lt;br /&gt; return f;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#ifdef UTF8TEST&lt;br /&gt;bool utf8test(){&lt;br /&gt; WStr w1;&lt;br /&gt; //for (wchar_t c = 1; c &lt;= 0x10ffff; c++){&lt;br /&gt; for (wchar_t c = 0x100000; c &lt;= 0x100002; c++){&lt;br /&gt;  w1 += c; &lt;br /&gt; }&lt;br /&gt; Str s = wstrToUtf8(w1);&lt;br /&gt; WStr w2 = utf8toWStr(s);&lt;br /&gt; bool result = true;&lt;br /&gt; if (w1.length() != w2.length()){&lt;br /&gt;  printf("length differs\n");&lt;br /&gt;  //std::cout &lt;&lt; "length differs" &lt;&lt; std::endl;&lt;br /&gt;  result = false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; printf("w1: %S\ns: %s\nw2: %S\n", w1.c_str(), s.c_str(), w2.c_str());&lt;br /&gt; &lt;br /&gt; for (size_t i = 0; i &lt; w1.size(); i++)&lt;br /&gt;  if (w1[i] != w2[i]){&lt;br /&gt;   result = false;&lt;br /&gt;   printf("character at pos %x differs (expected %.8x got %.8x)\n", i, w1[i], w2[i]);&lt;br /&gt;   //std::cout &lt;&lt; "character at pos " &lt;&lt; i  &lt;&lt; " differs" &lt;&lt; std::endl;&lt;br /&gt;   break;&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt; if (!result){&lt;br /&gt;  printf("utf8 dump: \n");&lt;br /&gt;  for (size_t i = 0; i &lt; s.size(); i++)&lt;br /&gt;   printf("%2x ", (unsigned char)s[i]);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv){&lt;br /&gt; std::wstring ws(L"фыва");&lt;br /&gt; std::string s("фыва");&lt;br /&gt; std::cout &lt;&lt; ws &lt;&lt; s &lt;&lt; std::endl;&lt;br /&gt; std::cout &lt;&lt; wstrToUtf8(utf8toWStr("фыва")) &lt;&lt; std::endl;&lt;br /&gt; if (utf8test())&lt;br /&gt;  std::cout &lt;&lt; "utf8Test succesful" &lt;&lt; std::endl;&lt;br /&gt; else&lt;br /&gt;  std::cout &lt;&lt; "utf8Test failed" &lt;&lt; std::endl;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;#endif&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Code was successfully tested on 32bit linux system (see "utf8test()" routine) and seems to work. Should work on 32bit windows platform as well, but keep in mind that wchar_t on msvc has size of 2 bytes, so on windows platform routine won't handle unicode characters in range 0xffff..0x10ffff).&lt;br /&gt;&lt;br /&gt;If you need routine like this, feel free to use it, just don't claim you wrote it.&lt;br /&gt;&lt;/div&gt;Code is available under modified BSD license.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-7642479908823145029?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/7642479908823145029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/c-utf8-to-wstring-conversion-routine.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/7642479908823145029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/7642479908823145029'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/c-utf8-to-wstring-conversion-routine.html' title='C++ utf8 to wstring conversion routine'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-2004243876963520769</id><published>2009-03-07T03:29:00.002+03:00</published><updated>2009-03-07T03:59:15.748+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='password'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='howto'/><category scheme='http://www.blogger.com/atom/ns#' term='generate'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><title type='text'>How to generate password on linux system</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;Every user eventually will need to create secure password (alphanumeric, not a common word, etc).&lt;br /&gt;On linux, you can easily generate it without additional software&lt;br /&gt;&lt;br /&gt;To generate eight characters long alphanumeric password use following line:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;tr -dc '0-9a-zA-Z' &amp;lt;/dev/urandom |head -c 8;echo&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can put this into shell script, if you are going to need it often.&lt;br /&gt;&lt;br /&gt;In case you are a newbie and don't understand what this line does, explanation is below.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Explanation&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;/dev/urandom&lt;/i&gt; is one of a few special files on linux/unix systems (other files are &lt;i&gt;/dev/zero&lt;/i&gt;, &lt;i&gt;/dev/null&lt;/i&gt; and &lt;i&gt;/dev/random&lt;/i&gt;).&lt;br /&gt;&lt;i&gt;/dev/urandom&lt;/i&gt; provides endless stream of pseaudo-random data, but even if you paste data from that file into text file, you won't be able to use it as password, because it will containt a lot of characters that doesn't fit into ASCII charset.&lt;br /&gt;So that's why "&lt;i&gt;tr&lt;/i&gt;" comand is used. "&lt;i&gt;tr -dc '0-9a-zA-Z'&lt;/i&gt;" reads data from &lt;i&gt;/dev/urandom&lt;/i&gt; and then prints to output only characters that fit into given character set (which is &lt;i&gt;'0-9a-zA-Z'&lt;/i&gt;). See "&lt;i&gt;man tr&lt;/i&gt;" for more details.&lt;br /&gt;This means that if you want use another set of characters in password, you will need change character set to something else.&lt;br /&gt;For example, &lt;i&gt;'0-9'&lt;/i&gt; means only numeric characters, &lt;i&gt;'0-9a-z'&lt;/i&gt; - numeric or lowercase latin letters, and &lt;i&gt;'0-9a-zA-Z!@#$%^&amp;amp;*()_+-'&lt;/i&gt; will include extra characters to make your password more secure.&lt;br /&gt;&lt;br /&gt;Because &lt;i&gt;/dev/urandom&lt;/i&gt; is "endless", "&lt;i&gt;head -c 8&lt;/i&gt;" is used to copy first 8 characters (see "&lt;i&gt;man head&lt;/i&gt;" for explanation).&lt;br /&gt;If you need more or less characters, change number accordingly.&lt;br /&gt;&lt;br /&gt;"&lt;i&gt;echo&lt;/i&gt;" command without arguments simply prints a newline. It is only useful if you want to print password into terminal (because without "&lt;i&gt;echo&lt;/i&gt;" next shell prompt will be printed right after password - on the same line).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Possible problems&lt;/span&gt;&lt;br /&gt;On system with UTF-8 locale, you won't be able to generate password with non-ASCII letters using this method. This is because tr handles only one character(&amp;quot;byte&amp;quot;) at the time, and UTF8-encoded non-ASCII character will use more than one byte.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-2004243876963520769?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/2004243876963520769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-generate-password-on-linux.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/2004243876963520769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/2004243876963520769'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-generate-password-on-linux.html' title='How to generate password on linux system'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-1610473997101942790</id><published>2009-03-06T17:21:00.004+03:00</published><updated>2009-03-06T17:46:30.396+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='packages'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='slackware'/><category scheme='http://www.blogger.com/atom/ns#' term='compiling'/><title type='text'>Making slackware packages from source without slackbuild</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;Originally posted on &lt;a href="http://www.linuxquestions.org/blog/erv-329740/2008/12/30/howto-making-slackware-packages-from-source-without-slackbuilds-1485/"&gt;linuxquestions.org&lt;/a&gt; by me.&lt;br /&gt;&lt;br /&gt;This article describes how to build software packages for slackware linux from source code.&lt;br /&gt;It is not easiest method, but it is useful for quick package creation.&lt;br /&gt;If you simply want to install software, and do not want to compile it, then either download precompiled packages from www.linuxpackages.net, or get slackbuild from &lt;a href="http://www.slackbuilds.org/"&gt;www.slackbuilds.org&lt;/a&gt;. Another option is to use src2pkg utility or &lt;a href="http://www.asic-linux.com.mx/%7Eizto/checkinstall/"&gt;checkinstall &lt;/a&gt;(but checkinstall is mostly broken since Slackware 11.0).&lt;br /&gt;&lt;br /&gt;I'm posting this because some people have problems with making packages from source code, and howto where I learned how to do it isn't available anymore.&lt;br /&gt;&lt;br /&gt;WARNING!:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;howto is pretty short and doesn't dive into details too much (although I initially thought about overview of commonly used build systems).&lt;/li&gt;&lt;li&gt;This doesn't work for all packages, only for most of them. Method is not universal&lt;/li&gt;&lt;li&gt;This stuff is written for people that don't like Slackbuilds, or want to compile software without slackbuild. If you simply want to install program as fast as possible, search for compiled package on www.linuxpackages.net, or search for slackbuild on www.slackbuilds.org.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Requirements&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This method will work only if following conditions are met:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;program package contains ./configure script.&lt;/li&gt;&lt;li&gt;Makefile produced by ./configure contains word DESTDIR (case-sensitive).&lt;/li&gt;&lt;/ol&gt;Seems pretty restrictive, but, fortunately, this covers 95% of all available linux software.&lt;br /&gt;&lt;br /&gt;If there is no ./configure, or makefile doesn't have "DESTDIR" inside, this will not work. (there are exceptions from that rule, of course, but explaing them will take too much space)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Short explanation&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;In this example I assume that we have extracted our package, and right now are within source code directory, where ./configure script is located. In example our program has name "programname" and version "programversion". When compiling your own package, replace "programname" and "programversion" with values you need.&lt;br /&gt;&lt;br /&gt;Most software can be turned into slackware package using this sequence:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;./configure&lt;/li&gt;&lt;li&gt;make&lt;/li&gt;&lt;li&gt;mkdir pkg&lt;/li&gt;&lt;li&gt;make DESTDIR=`pwd`/pkg install&lt;/li&gt;&lt;li&gt;cd pkg&lt;/li&gt;&lt;li&gt;su&lt;/li&gt;&lt;li&gt;makepkg programname-programversion-1xyz.tgz&lt;/li&gt;&lt;li&gt;chown me.users ./programname-programversion-1xyz.tgz (instead of "me" use your user name)&lt;/li&gt;&lt;li&gt;mv ./programname-programversion-1xyz.tgz ..&lt;/li&gt;&lt;li&gt;cd ..&lt;/li&gt;&lt;li&gt;rm -r pkg&lt;/li&gt;&lt;li&gt;Ctrl+D (exits "su")&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;If package meets requirements mentioned before, this sequence will create slackware package for you.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;How it works&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;"./configure" - configures package according to our system.&lt;/li&gt;&lt;li&gt;"make" - compiles package.&lt;/li&gt;&lt;li&gt;"mkdir pkg" - creates directory called "pkg" within same directory where ./configure is located. This "pkg" directory will be used to&lt;br /&gt;store files that will be put into package.&lt;/li&gt;&lt;li&gt;"make DESTDIR=`pwd`/pkg install":&lt;br /&gt;This tells to the "make" command to install package as if "pkg" subdirectory (that we created in current directory) were root "/" folder.&lt;br /&gt;"`pwd`" inserts output of "pwd" command into current command line. DESTDIR is a variable used inside makefile. DESTDIR specify the root of installations, and because GNU make allows to override some variables during compilation, we can change it, and say that "pkg" subdirectory is a root of installation.&lt;/li&gt;&lt;li&gt;"cd pkg" we are going into "pkg" subdirectory.&lt;/li&gt;&lt;li&gt;"su" (enter password here) - changing privilegies to root, because makepkg (which is used to create packages) won't work with other privilegies.&lt;/li&gt;&lt;li&gt;"makepkg programname-programversion-1xyz.tgz" This creates slackware package without description. Answer "yes" to all questions (well, unless it doesn't suit your needs). Also, notice "1xyz" part of the filename instead of numbers. When you build custom packages, you need to be able to distinguish them from stock packages. To do that, instead of standard numbers numbers, use custom signature, something like "1abc", "2abc", etc. Use whatever combination you want (I use number + my nickname), as long as you can distinguish your package from packages made by other people.&lt;/li&gt;&lt;li&gt;"chown me.users ./programname-programversion-1xyz.tgz" Created package has "root.root" owner. If we want to be able later to move it somewhere, we need to change owner to our user ID.&lt;/li&gt;&lt;li&gt;"mv ./programname-programversion-1xyz.tgz .." We are moving our package into the source directory - i.e. one level up.&lt;/li&gt;&lt;li&gt;"cd .." Going one level up. (back into directory with "configure")&lt;/li&gt;&lt;li&gt;"rm -r pkg" we are cleaning up and removing our pkg subdirectory.&lt;/li&gt;&lt;li&gt;"Ctrl+D" - this equivalent to "exit" command which ends "su" session.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Done&lt;/span&gt;&lt;br /&gt;Now you have your slackware package.&lt;br /&gt;If something doesn't work, or you don't understand something, ask it on slackware forums.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Few Notes&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Package created this way normally will end in "/usr/local" instead of "/usr". This is because "/usr/local" is default location for user-built packages. "/usr/local/" is fine if you are creating packages for yourself, but, for example, linuxpackages.net rejects packages that are not in "/usr". So if you want to distribute your packages, or submit them to linucpackages.net, then change installation location from "/usr/local" to "/usr" using --prefix configure option.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-1610473997101942790?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/1610473997101942790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/making-slackware-packages-from-source.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1610473997101942790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/1610473997101942790'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/making-slackware-packages-from-source.html' title='Making slackware packages from source without slackbuild'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4694652045435723378.post-8774349975363112664</id><published>2009-03-06T16:57:00.003+03:00</published><updated>2009-03-06T17:19:24.819+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='howto'/><category scheme='http://www.blogger.com/atom/ns#' term='forums'/><category scheme='http://www.blogger.com/atom/ns#' term='time'/><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><title type='text'>How to answer questions without wasting too much time</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;This text was originally posted on www.linuxquestions.org (&lt;a href="http://www.linuxquestions.org/blog/erv-329740/2008/11/30/how-to-answer-questions-without-wasting-too-much-time-1355/"&gt;here&lt;/a&gt;). It was created because there is already famous &lt;a href="http://www.catb.org/%7Eesr/faqs/smart-questions.html"&gt;&amp;quot;How to ask questions the right way&amp;quot;&lt;/a&gt;, but I don't remember any document for those answering questions.&lt;br /&gt;Information should be useful for people that hang out on various forums/newsgroups answering questions and solving other people problems (mostly useful for linux users).&lt;br /&gt;&lt;br /&gt;&lt;hr width="50%" align="center"&gt;&lt;br /&gt;&lt;br /&gt;Okay, I've just got through another flamewar, so I decided to write a some info about answering questions without wasting too much time in the process. The content is based on personal experience, my own point of view, and isn't supposed to be absolute truth or something. I also don't expect someone to agree with me. Recommendations are written in random order, and are supposed to prevent wasting too much time typing replies, or breaking your keyboard too quickly.&lt;br /&gt;Beware! Some people probably might find this thing offensive.&lt;br /&gt;&lt;br /&gt;The recommendations are based on following assumptions:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;  You want to help other people to solve their problem.&lt;/li&gt;&lt;li&gt;You don't want to spend many hours per day doing that.&lt;/li&gt;&lt;li&gt;You want to get satisfaction from giving out info - i.e. people should be grateful, or discussion should be interesting.&lt;/li&gt;&lt;li&gt;You do not want to live on the forum, just post answers to some threads.&lt;/li&gt;&lt;li&gt;You don't want to have a bad mood after helping someone.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Here are recommendations:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;  Always remember that you can ignore other people instead of trying to reason with them. By "ignoring" I mean ignore list, which is located at &lt;a href="http://www.linuxquestions.org/questions/profile.php?do=ignorelist"&gt;this page&lt;/a&gt; on linuxquestions and often present in other forums. Ignore list is a very handy feature.&lt;/li&gt;&lt;li&gt;Never participate in threads about religion. There were many of those, and when there is a clash between believers and atheists (or simply followers of different religions), no matter which side you take, you'll never prove to "them" that you are right. Also, your opponents will never prove you that you are wrong. The thread will eventually degrade into pillow-fight, and someone will close it.&lt;/li&gt;&lt;li&gt;Never post in "Linux vs Windows" threads. Yes, this is tempting, but should be avoided. Such threads either never ends or many of them eventually degrade into flamewar. Which side "wins" in case of flamewar depends on forum, but in most cases, moderators win. Providing non-biased info in such threads is difficult, and sometimes leads to disappointment - especially when you discover that someone asked the question you already answered in details one year ago in the same thread. &lt;/li&gt;&lt;li&gt;If are feeling too emotional while typing a reply, do not type a reply. If you were offended, report incident to moderators. If you are angry, go outside and take a walk. If you don't like someone, ignore him or her (by adding into ignore list). Being furious or simply emotional causes too much typing. And too much typing means too much time wasted.&lt;/li&gt;&lt;li&gt;When someone posts something that doesn't fit into your system of beliefs, and it enrages you, do not try to explain something to that guy/girl, ignore him/her. If he posted something gross, then report it to moderators. To my experience, trying to explain something to someone who don't want to listen is #1 cause of wasting time on the internet. This applies to the choice of distribution, operating system, religion, some questions about women, and so on. Same principle applies to trolls or any person that pisses your off.&lt;/li&gt;&lt;li&gt;Do not reply in the threads started by spammers. They don't read it. &lt;/li&gt;&lt;li&gt;When replying to "newbie" section, try to keep your replies extremely short, but informational. It is tempting to overwhelm newbie with the amount of things you know, but this guy might not need it. He might be simply interested how to watch DVD, and not in the mood for linux history lesson or detailed comparison of all available dvd-players.&lt;/li&gt;&lt;li&gt;When you realize that you started to type extremely long, detailed instructions about "how to do something in linux", stop, put keyboard away, take a deep breath, relax, and then try to find howto on the subject you were writing about. There is high chance that someone already wrote what you were going to write right now, so you'll be reinventing wheel. If there is a howto on the subject, post a link to it or quote it (but still provide link). This will make howto more widespread and will save time for other people.&lt;/li&gt;&lt;li&gt;When you found a good howto or manual, and want to put a link to them in reply, consider quoting them. Websites sometimes disappear, and seeing dead link 3 years later (and answering same thing again) isn't much fun. If the source of article doesn't look "stable" enough, quote good portion of it (but still provide link). If website is unlikely to disappear, then link should be enough.&lt;/li&gt;&lt;li&gt;If you really pissed someone off, and was unable to pacify that person within small amount of replies (1..3), consider ignoring that person. This is because when someone thinks that you are "evil person that hates all people" (no matter what were your intentions, what did you post, how friendly you were, people might think that about you), you can waste considerable amount of time reasoning with that person and explaining your position. If you started such "clarification conversation", observe person's reaction, and if person is unlikely to change attitude quickly, don't waste your time. Some people can be reasoned with, some can't.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;When you see newbie poster (which has 1 message on the forum) with a short question (literally short - one statement with poor punctuation, small amount of info, etc), and you want to write really long answer, stop, and think about it again. Poster might be "fly by homework question author" - i.e. he will ask question, and then mysteriously disappear, while other people will waste their time explaining things to him and writing huge replies for few weeks. Not all newbies magically disappear, but you should consider that possibility.&lt;/li&gt;&lt;li&gt;Don't do other people's homework, they normally won't truly appreciate it, and this will spoil your mood and take your time. I.e. if the guy asked how to make some script, do not engage in 3 hours of googling, researching and testing just to make that script for him, because in the end his "thanks" might not satisfy you. To my experience, answers that were written with little effort (link to howto, article) generate more positive emotional feedback (for you - i.e. you'll feel more happy) when people say "thanks" than answers where you spend hours to find solution. Making other people's homework makes sense only if the problem is extremely interesting for you and you really like to solve complicated problems. Notice, that even if you solved problem you still can choose not to provide info to the OP, if you think he is too lazy or didn't do his homework.&lt;/li&gt;&lt;li&gt;Do not live on the forums. If you are checking forums for new messages every 3 minutes and looking for _any_ discussion to participate in, and occasionally attempt to derail existing threads, then you should probably turn off computer and go jogging, watch the movie, take dog for a walk, or do anything that is fun, takes at least hour and doesn't involve computers. Helping people is fine, forums are good, but, unfortunately, for some people participating in such discussion is a bit addictive. And when you start spending too much time on the forums, quality of your answers decreases.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Now this is it. I hope this information will be useful for someone.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4694652045435723378-8774349975363112664?l=altctrlbackspace.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://altctrlbackspace.blogspot.com/feeds/8774349975363112664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-answer-questions-without-wasting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/8774349975363112664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4694652045435723378/posts/default/8774349975363112664'/><link rel='alternate' type='text/html' href='http://altctrlbackspace.blogspot.com/2009/03/how-to-answer-questions-without-wasting.html' title='How to answer questions without wasting too much time'/><author><name>SegFault</name><uri>http://www.blogger.com/profile/15188291661092699245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
