<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Reactor</title>
	<atom:link href="http://www.codereactor.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codereactor.net</link>
	<description>The best of modern Web development</description>
	<lastBuildDate>Sun, 01 Apr 2012 21:35:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Drop-in fix for &#8216;placeholder&#8217; attribute of input tags in Internet Explorer (even IE9)</title>
		<link>http://www.codereactor.net/drop-in-fix-for-placeholder-attribute-of-input-tags-in-internet-explorer-even-ie9/</link>
		<comments>http://www.codereactor.net/drop-in-fix-for-placeholder-attribute-of-input-tags-in-internet-explorer-even-ie9/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 21:35:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=280</guid>
		<description><![CDATA[I&#8217;ve been using this drop-in replacement for adding the placeholder support for some time now, but now I noticed that it doesn&#8217;t work as expected in IE9. What is worse is that it creates problems: while the placeholder functionality works as advertised, it touches inputs that have no placeholder attribute set and creates all sort [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.cssnewbie.com/cross-browser-support-for-html5-placeholder-text-in-forms/" target="_blank">this</a> drop-in replacement for adding the placeholder support for some time now, but now I noticed that it doesn&#8217;t work as expected in IE9. What is worse is that it creates problems: while the placeholder functionality works as advertised, it touches inputs that have no placeholder attribute set and creates all sort of havoc. (In my case users could not log in because the script removed the username from forms just because that input did not have it&#8217;s placeholder attribute set.)</p>
<p>Nevertheless, here is the revised version that does work as expected even in IE9: (still requires jQuery)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	jQuery.<span style="color: #660066;">support</span>.<span style="color: #660066;">placeholder</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	test <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span> <span style="color: #000066; font-weight: bold;">in</span> test<span style="color: #009900;">&#41;</span> jQuery.<span style="color: #660066;">support</span>.<span style="color: #660066;">placeholder</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>$.<span style="color: #660066;">support</span>.<span style="color: #660066;">placeholder</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #003366; font-weight: bold;">var</span> active <span style="color: #339933;">=</span> document.<span style="color: #660066;">activeElement</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> 
			<span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hasPlaceholder'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> 
			<span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'string'</span><span style="color: #009900;">&#41;</span> 
			<span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">||</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'placeholder'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hasPlaceholder'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span>active<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.hasPlaceholder'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/drop-in-fix-for-placeholder-attribute-of-input-tags-in-internet-explorer-even-ie9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ninite: aptitude install for windows</title>
		<link>http://www.codereactor.net/ninite-aptitude-install-for-windows/</link>
		<comments>http://www.codereactor.net/ninite-aptitude-install-for-windows/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 23:33:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Administration]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=272</guid>
		<description><![CDATA[While there are arguably both advantages and disadvantages with the debian package system (or any linux package system for that matter), it is certainly usefull to be able to &#8220;aptitude install whatever&#8221; by basically only having to know the name of the program you wish to install. I don&#8217;t think that windows will ever have [...]]]></description>
			<content:encoded><![CDATA[<p>While there are arguably both advantages and disadvantages with the debian package system (or any linux package system for that matter), it is certainly usefull to be able to &#8220;aptitude install whatever&#8221; by basically only having to know the name of the program you wish to install.</p>
<p>I don&#8217;t think that windows will ever have quite as big library of automatically installed programs, but <a title="Ninite" href="http://ninite.com/" target="_blank">Ninite</a> certainly does create that feeling, as it is one of most successful and user-friendly attempts to do automatic installing in Windows.</p>
<p>It is an automatic and customizable installer of mostly used programs for windows. After configuration, it will automatically download latest versions of the software such as Skype, Open Office, Mozilla software, other browsers, messengers and such and such, automatically click away all adware/toolbars. It is mostly useful on new installations, but it can also keep your usual software up to date. It is of course completely free, definitely worth a try if you haven&#8217;t already!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/ninite-aptitude-install-for-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All the Visual Studio color themes you will ever need</title>
		<link>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/</link>
		<comments>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 22:55:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=261</guid>
		<description><![CDATA[Combining two great concepts in programming world &#8211; color themes and the StackOverflow engine, http://studiostyl.es gives you a one-stop place for all the nice Visual Studio color themes. No more searching &#8220;the ogl&#8221; for themes and typing them in manually into the settings window. All the themes can be downloaded for all the latest versions of VS, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codereactor.net/wp-content/uploads/2012/01/vsthemes.jpg"><img class="alignright size-full wp-image-262" title="vsthemes" src="http://www.codereactor.net/wp-content/uploads/2012/01/vsthemes.jpg" alt="" width="295" height="86" /></a></p>
<p>Combining two great concepts in programming world &#8211; color themes and the StackOverflow engine, <a href="http://studiostyl.es/">http://studiostyl.es</a> gives you a one-stop place for all the nice Visual Studio color themes. No more searching &#8220;the ogl&#8221; for themes and typing them in manually into the settings window.</p>
<p>All the themes can be downloaded for all the latest versions of VS, however it is still not particularly user friendly to install them, at least not in VS2008. I hope their coders are at least a little bit ashamed, but hey, it&#8217;s not like this is the primary point of VS.</p>
<p>In VS2008, you just download the file, and in Options &gt; Environment &gt; Import And Export Settings point the &#8220;team settings file&#8221; to the file you&#8217;ve downloaded. If you already had a team setting file, I can&#8217;t really help you, but the settings are just an XML so you could easily migrate them into your personal settings file using your favorite text editor.</p>
<p>(Update: found it, it is much simpler to install those using Tools &gt; Import And Export Settings.)</p>
<p>(Yet Another Update: here is where I took my theme needs before the studiostyl.es came along: <a href="http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx">http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/all-the-visual-studio-color-themes-you-will-ever-need/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some MS-lovin</title>
		<link>http://www.codereactor.net/some-ms-lovin/</link>
		<comments>http://www.codereactor.net/some-ms-lovin/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 00:46:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=243</guid>
		<description><![CDATA[Aah, good old MS api class for representing the &#8220;system enclosure&#8221;, ie, what type of computer you have. Except: 1 Other 2 Unknown 3 Desktop 4 Low Profile Desktop 5 Pizza Box 6 Mini Tower 7 Tower 8 Portable 9 Laptop 10 Notebook 11 Hand Held 12 Docking Station 13 All in One 14 Sub [...]]]></description>
			<content:encoded><![CDATA[<p>Aah, good old MS api class for representing the &#8220;system enclosure&#8221;, ie, what type of computer you have. Except:</p>
<p>1<br />
Other<br />
2<br />
Unknown<br />
3<br />
Desktop<br />
4<br />
Low Profile Desktop<br />
5<br />
Pizza Box<br />
6<br />
Mini Tower<br />
7<br />
Tower<br />
8<br />
Portable<br />
9<br />
Laptop<br />
10<br />
Notebook<br />
11<br />
Hand Held<br />
12<br />
Docking Station<br />
13<br />
All in One<br />
14<br />
Sub Notebook<br />
15<br />
Space-Saving<br />
16<br />
Lunch Box<br />
17<br />
Main System Chassis<br />
18<br />
Expansion Chassis<br />
19<br />
SubChassis &#8230;</p>
<p>Pizza Box!? Lunch box!?</p>
<p>&#8220;Missing good old 80es when you ran dos on a pizza box&#8230;</p>
<p>(as seen on http://msdn.microsoft.com/en-us/library/Aa394474 and http://stackoverflow.com/questions/2837152/how-can-i-tell-if-a-user-is-using-a-laptop</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/some-ms-lovin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardcore debugging crashes in C++ release builds in Visual Studio and StackWalker</title>
		<link>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/</link>
		<comments>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/#comments</comments>
		<pubDate>Mon, 30 May 2011 20:47:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=220</guid>
		<description><![CDATA[Ever encountered an error which just shows up in a release build? And when you are debugging everything is just fine? Don&#8217;t those errors just make you happy and loving the programming, computers, the world and everything in it? So, long story short, I had to come up with some reliable debugging methods for the [...]]]></description>
			<content:encoded><![CDATA[<p>Ever encountered an error which just shows up in a release build? And when you are debugging everything is just fine? Don&#8217;t those errors just make you happy and loving the programming, computers, the world and everything in it? <img src='http://www.codereactor.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>So, long story short, I had to come up with some reliable debugging methods for the release builds, and there are quite a few.<br />
<span id="more-220"></span></p>
<h2>Internal methods</h2>
<p>Well, just to mention, of course, there is logging. However, my error was producing a nice and loud access violation and quitting, so instead of starting to log everything that happens I wanted to start working from that AV. But do not undermine the power</p>
<p><strong>Try/catch</strong></p>
<p>Firs on my list is the good old c++ try/catch blocks. In case of debugging crashes you can use them by just putting the main() or WinMain in one big try/catch, and get the exception object in the catch and start working from there. Based on that object you can deduce the exact error, line, sometimes even the callstack (probably the single most valuable piece of information about a crash). Nothing out of the ordinary, plain and simple.</p>
<p>However, this method will only catch c++ exceptions, not the hardware errors or even things like bad pointers, which is quite a pity because most of bugs lead just to those.</p>
<p>wait, what?- you say, try does not catch all the errors? What is the point then?</p>
<p>Well, basically, there are two kinds of exceptions in C++. First one is</p>
<ol>
<li> C++ exceptions. These are the errors the code is sort of throwing itself. For example, you download a library for opening image files, and calling a function for opening a jpeg. However it cannot open the file, and uses c++ Throw() to throw an exception, to report that something went wrong and processing of that function has stopeed.<br />
The control now goes back to your innermost try/catch block and you get your exception there.<br />
These errors are always thrown by the code itself. It may not be your code, but somewhere there is a Throw() that wants to signal that something went wrong, but it knows about it.<br />
So these errors are handled in the c++ code, basically by the compiler, and even though they are errors, they are sort of already managed, at least partly. Because somwhere there is a throw, and its purpose is to manage an error.<br />
These errors a pretty high-level compared to the SEH exceptions, can basically be used as a valid control structure, not only as a fail-safe mechanism. You are free to use try/catch blocks to catch these exceptions through arbitrary calling levels, cycles, and so on. The compiler will automatically free all the memory when it unwinds the call stack to get to your innermost catch block.</li>
<li>SEH exceptions. (and this is windows-specific)<br />
Now, let&#8217;s say you are doing a simple *i = 1;, where i is a pointer that for some reason is pointing to null. This means your program will try to access memory at the very beginning (0) of the address space, and that memory is very reserved, so the operation is invalid.<br />
But what happens? You have obviously not written any code to Throw() an exception to manage this error. In fact, if you were aware of that this could happen, you could&#8217;ve just checked if i is equal to 0, and not assign a value in that case.<br />
Of course, other scenarios are possible, but bottomline is that sometimes there are operations that produce errors on the assembly level. The bugs (poorly designed code) probably happen before, and lead to these situations, but nevertheless, when this happens, neither the compiler nor the processor know what to do, they cannot analyze the code for you, they just see that something is wrong. Which brings us to</li>
</ol>
<p><strong>_try/_except</strong></p>
<p>To handle these low-level errors, MS gave us a non-standard extesion to C++, which can be used in visual C++: __try and __except. The OS itself of course has a mechanism for handling these errors, otherwise any poor-written program would be able to cause havoc. There are WINAPI functions for setting SEH exception handlers, getting information about the error and so on. And in Visual C++ we can catch these errors using __try. (If you are on other platforms or other compilers, this section might be of no use to you).</p>
<p>Now, you might ask why isn&#8217;t this a standard C++ thing, these are still errors? The usual argumentation is that while C++ exceptions might be thrown by design (instead of constructing a lot of if&#8217;s, an author of a problematic function just put a throw() and was done with it), SEH errors often represent serious bugs in the program, and the chance is not big that the program will be able to recover from it, and this is why simply putting a try/catch around a SEH exception and trying to mask it is much more dangerous than doing so with a C++ exception. (For example it could cause a damaged information to be written to disk, instead of just being damaged in a memory)</p>
<p>This is of course, true to some extent, but hey, as long as you know where and how to use it, an error log during debugging is much better than just a binary dump saved by Windows&#8217; default error mechanism.</p>
<p>Basically, if you put a try/catch block around your error, but it doesn&#8217;t catch it, try _try/_except. But you will need some other things to make it useful, for example StackWalker, a class to parse all the information from the SEH handler and print it to a nice readable stack trace. (Even with line numbers! And even in release builds! It is very simple to use and all the examples are provided in http://www.codeproject.com/KB/threads/StackWalker.aspx, so I am not going to cite them here.)</p>
<p>Just before we continue, there are some specialties in how VC++ compiles, first which errors are catched by normal try/catch can depend on whether you are building a debug or a release build, this is supposedly a bug in an older version of the compiler. Secondly, there are some compiler switches to make try/catch catch *all* errors in all types of builds (/EH{s|a}[c][-], http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.71).aspx), but there are a ton of information about this around the google and StackOverflow&#8230;</p>
<p>&nbsp;</p>
<h2>Proper IDE-debugging</h2>
<p>A very important fact that you may or may not know is that debugging  in an IDE does not actually require the binary to be built in any special way (i.e. debug configuration). The  debugger could go into any userlevel program and start stepovering and  stepintoing, except in some very special cases. So what is the debug configuration really good for, except slowing down the program you ask? Well I wonder that too sometimes, but basically it adds some extra checks for things that can go wrong (a LOT of checks in STL for example), which can sometimes get you a more comprehend-able error than without those checks. Nevertheless, it is in now way a *requisite* to IDE debugging.</p>
<p>But what is an (almost) requisite are the symbols. The symbols are human-readable markers of things in your binary, like functions and c++ lines. When debugging, it is a lot easier to understand what is going on if the debugger tells you that you are in function suchAndSuch(), on line 342, instead of &#8220;You are at location 0x00400F3d&#8221;.</p>
<p>Those symbols are saved in a separate file (.pdb), and saving them contra not saving them does not modify the  binary itself, so it will run exactly like a binary without those debug  symbols, and will most probably crash at the same place (which is what  you want to debug).</p>
<p>Long story short, you will need these settings:<br />
1) C/C++ &gt; Debug Information Format: /Zi or /ZI, chances are you won&#8217;t have to change this from the default value.<br />
2) Linker &gt; Debugging &gt; Generate Debug Info : YES /DEBUG<br />
3) Linker &gt; Optimization &gt; References: Eliminate Unreferenced Data (/OPT:REF) and Linker &gt; Optimization &gt; Enable COMDAT Folding &gt; Remove Redundant COMDATs (/OPT:ICF). Without going into too much detail about these options, when you set the /DEBUG option, that modifies the default behavior of the linker regarding comdats and references, and by setting these two options you modify those behavior back to the way it is without the /DEBUG option, thus making sure your binary will be the same.</p>
<p>The symbols file will be saved by default in some intermediate directory for your project. While debugging, the IDE will have to find that file.</p>
<p>An interesting fact: by default, Visual Studio stores absolute path to your symbols file in your binary. This is good for debugging on the same machine, because no matter where you start your binary from, if it is debugged in Visual Studio, it will always find the symbols, but if you need to debug on different machines or just think that it is not in any way pro to ship your binaries with absolute paths to things on your development machine in them (like me), you can make it store the relative path with an undocumented command line switch: &#8220;/pdbpath:none &#8220;. (source: http://groups.google.com/group/microsoft.public.vc.debugger/browse_thread/thread/abbbdead63dfe5ac?pli=1)</p>
<p>&nbsp;</p>
<p>So that basically should get you started on debugging release builds, for more info, google is always your dearest friend!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/hardcore-debugging-crashes-in-c-release-builds-in-visual-studio-and-stackwalker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook PHP compiler</title>
		<link>http://www.codereactor.net/facebook-php-compiler/</link>
		<comments>http://www.codereactor.net/facebook-php-compiler/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 23:16:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=211</guid>
		<description><![CDATA[More and more php compilers are emerging, and it now finally looks like there are a number of decent ones out there. Just a couple of years ago, there only were bcompiler, eaccelerator and perhaps some others, but none really good. Eaccelerator would be sensitive to server environment and only work under certain conditions, and [...]]]></description>
			<content:encoded><![CDATA[<p>More and more php compilers are emerging, and it now finally looks like there are a number of decent ones out there.</p>
<p>Just a couple of years ago, there only were bcompiler, eaccelerator and perhaps some others, but none really good. Eaccelerator would be sensitive to server environment and only work under certain conditions, and even have special problems with different php programs, and others had similair problems.</p>
<p>But now it seems like there are 5-10 different compilers, and all seem to work really nice. An especially interesting one is HipHop for PHP &#8211; a php compiler written by facebook to run in their own servers. The ultimate goal of all compilers is the SPEED (and, hwell, perhaps, obsfucation too), and I can only imagine what kind of speed problems the facebook experiences, with all their traffic, so if hiphop is good for them, then it should be too for the rest of the normal mortal aplications out there.</p>
<p>One important thing to know though is that hiphop for PHP is not an opcode cacher or a JIT. It is actually a compiler, and produces binary code as such. Probably because of that it has problems with eval() and some other dynamic features of PHP. If that is the case with your application, then it&#8217;s probably not for you, but how often does one really use eval?</p>
<p>Definetely check it out if you are looking to speed up your php application without changing a line of code. ﻿<a href="http://developers.facebook.com/blog/post/358/">http://developers.facebook.com/blog/post/358/</a></p>
<p><a href="http://developers.facebook.com/blog/post/358/"></a>Github: <a href="https://github.com/facebook/hiphop-php/wiki/">https://github.com/facebook/hiphop-php/wiki/</a></p>
<p><a href="https://github.com/facebook/hiphop-php/wiki/"></a>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/facebook-php-compiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymity in 2010</title>
		<link>http://www.codereactor.net/anonymity-in-2010/</link>
		<comments>http://www.codereactor.net/anonymity-in-2010/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 17:43:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=142</guid>
		<description><![CDATA[A great podcast/presentation that has started to circulate around the blogosphere, about how the internet and the progress is affecting our anonymity. Steve Rambam (who is/was a private investigator, and ironically looks very much like one, thou also like an italian mafia boss) takes on many interesting things in this 3 hour long talk, including [...]]]></description>
			<content:encoded><![CDATA[<p>A great podcast/presentation that has started to circulate around the blogosphere, about how the internet and the progress is affecting our anonymity.</p>
<p>Steve Rambam (who is/was a private investigator, and ironically looks very much like one, thou also like an italian mafia boss) takes on many interesting things in this 3 hour long talk, including<br />
- What information we are putting in &#8220;The Database&#8221; ourselves and how the way people are disclosing information about themselves changed over the past 10 years.<br />
- Just how much information does a mobile phone broadcast about its owner.<br />
- How easy it is nowadays for a detective to find out anything about you without leaving his or her desk.<br />
- What kind of databases are being put together, sold and used, and what kind of information can be found there.<br />
- A couple of interesting sites for information hunting.</p>
<p><object id="VideoPlayback" style="width: 400px; height: 326px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://video.google.com/googleplayer.swf?docid=3079242748023143842&amp;hl=ru&amp;fs=true" /><param name="allowfullscreen" value="true" /><embed id="VideoPlayback" style="width: 400px; height: 326px;" type="application/x-shockwave-flash" width="100" height="100" src="http://video.google.com/googleplayer.swf?docid=3079242748023143842&amp;hl=ru&amp;fs=true" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/anonymity-in-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tolua++ windows precompiled binary exe file download and more instructions on tolua++.</title>
		<link>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/</link>
		<comments>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 02:23:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=161</guid>
		<description><![CDATA[So, since the last post, I have started embedding lua and has had some minor problems. First I tried using luabind, which didn&#8217;t work at all for me. I didn&#8217;t want to include and build both luabind and boost (which it requires), and all of the precompiled solutions didn&#8217;t work either on my setup for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codereactor.net/wp-content/uploads/2010/10/logo.gif"><img class="alignleft size-full wp-image-172" title="logo" src="http://www.codereactor.net/wp-content/uploads/2010/10/logo.gif" alt="" width="128" height="128" /></a>So, since the last post, I have started embedding lua and has had some minor problems.</p>
<p>First I tried using luabind, which didn&#8217;t work at all for me. I didn&#8217;t want to include and build both luabind and boost (which it requires), and all of the precompiled solutions didn&#8217;t work either on my setup for different reasons, plus I just didn&#8217;t have time nor motivation to spend an hour trying to setup paths, projects, solutions, includes and so on for a library which should be precompiled.</p>
<p>So I thought screw luabind and I will go with tolua++. Which does almost the same thing but in a different way. Basically, luabind is like a library with a lot of macros, which you use to define your bindings in certain way in your code, and when the macros get expanded before compilation, the bindings start working. Tolua++ (and its predecessor tolua) on the other hand, only includes a very small runtime library, and most of the work is done before compilation by an external command line tool. It takes in special header files which you must write for your bindings and converts them to cpp files which you then include into your project like any other cpp file, and all the bindings are defined there. (This step is automated of course, you only define the special header and include the output file once).</p>
<p>tolua++ doesn&#8217;t require boost, which would mean less trouble compiling it, and also I thought that the exe file itself would be just downloadable precompiled.</p>
<p>However it wasn&#8217;t. But now after some time figuring out the compilation routine, I have compiled it and thought that I can put it out here for everyone who wants to save an hour or so by just fetching the file which should have been available from the author&#8217;s site from the beginning.</p>
<p>Anyways, here is the binary. It is for win32 and is tolua++ 1.0.93:</p>
<p><a href="/files/tolua++.zip" target="_blank">tolua++ 1.0.93 compiled binary (exe)</a>.</p>
<p>When compiling this, I have had a great help from this guide: <a href="http://lua-users.org/wiki/CompilingToluappWithoutScons">http://lua-users.org/wiki/CompilingToluappWithoutScons</a></p>
<p>Although some things in that guide seemed to be incorrect, so here is my modified version: <a href="http://www.codereactor.net/?p=163">Tolua++ compilation guide</a>.</p>
<p>As for actually using the tolua++, here is another awesome guide which should get you started: <a href="http://www.icynorth.com/forums/viewtopic.php?t=301">http://www.icynorth.com/forums/viewtopic.php?t=301</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/tolua-windows-precompiled-binary-exe-file-download-and-more-instructions-on-tolua/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Tolua++ 1.0.93 without SCons (updated)</title>
		<link>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/</link>
		<comments>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 02:22:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=163</guid>
		<description><![CDATA[This guide is based on the http://lua-users.org/wiki/CompilingToluappWithoutScons I just have modified some things in the Visual Studio part, because in the original, the steps didn&#8217;t work for me. So, needless to say, most credit goes for the author of the original guide, I have just modified some stuff! I wanted to post this on the [...]]]></description>
			<content:encoded><![CDATA[<p>This guide is based on the http://lua-users.org/wiki/CompilingToluappWithoutScons<br />
I just have modified some things in the Visual Studio part, because in the original, the steps didn&#8217;t work for me.</p>
<p>So, needless to say, most credit goes for the author of the original guide, I have just modified some stuff!</p>
<p>I wanted to post this on the tolua++ site but they dont have a wiki.</p>
<p>The tolua++ INSTALL file lets you figure out how to compile it without SCons. Its easy enough, but I wanted to save the people the 5 ( err&#8230; 15 ) minutes they need to figure this out.</p>
<h3>Using GCC/Mingw</h3>
<p>I am using gcc 3.4.2, on a mingw installation. But I think this should work for most people, at least those using gcc, with minor modifications.</p>
<p>The commands used are :<br />
tolua++_1.0.5\src\lib&gt; gcc -shared -o tolua++.dll *.c<br />
\Lua502.dll -I..\..\include -I<br />
\include<br />
- This will create the dynamic library tolua++.dll in the src\lib directory.<br />
tolua++_1.0.5-1\src\lib&gt; gcc -c *.c  -I..\..\include -I<br />
\include<br />
tolua++_1.0.5-1\src\lib&gt; ar rcsv libtolua++.a *.o<br />
- This will create the static linking library in the src\lib dir.<br />
tolua++_1.0.5\src\bin&gt; gcc tolua.c toluabind.c -I..\..\include -I<br />
\include<br />
\Lua502.dll -L..\lib\ -ltolua++<br />
- This creates the tolua++ executable in the src\bin dir, assuming the libtolua++.a was created in the src\lib dir.</p>
<p>Note1: If you are linking against the lua static library instead of the dynamic library, replace<br />
\Lua502.dll with -L<br />
\lib -llua .</p>
<h3>Using Visual Studio 2003</h3>
<p><strong>Library (.DLL/.lib)</strong></p>
<p>Open the &#8220;File-&gt;New Project&#8221; menu. From the project types listbox, select &#8220;Visual C++ Projects-&gt;Win32&#8243;. From the Templates listbox, select &#8220;Win32 project&#8221;. For a project name, type in &#8220;tolua++&#8221;.</p>
<p>When the wizard opens, select &#8220;Application Settings&#8221; on the right hand side. Choose &#8220;DLL&#8221; and click &#8216;Finish&#8217;. If you want to compile to a static library, choose Static Library (.lib)</p>
<p>In the Solution Explorer right click on &#8220;source files&#8221; and select &#8220;Add-&gt;Existing Item&#8221;. Browse to the location of the tolua++\src\lib directory. Highlight all .c and .h files and add them to the project. You may also optionally want to add the tolua++.h file from the include directory into the &#8220;header files&#8221; folder.</p>
<p>Right click on the tolua++ project in the Solution Explorer and select &#8220;Properties&#8221;.</p>
<p>Under the &#8220;C/C++ -&gt; General&#8221; section select the &#8220;Additional include directories&#8221; option. Navigate to the location of your Lua include files.</p>
<p>Under the &#8220;C/C++ -&gt; Preprocessor&#8221; section add the following: TOLUA_API=extern __declspec(dllexport) Under the &#8220;C/C++ -&gt; Precompiled headers&#8221; section, turn off precompiled headers. Under the &#8220;Linker -&gt; General&#8221; section select the &#8220;additional library directories&#8221; option and navigate to the location of your Lua .lib library files. Under the &#8220;Linker -&gt; Input&#8221; section add lua.lib and lualib.lib (assuming those are your lua libraries).<br />
In more recent versions of lua there is just one library, for example &#8220;lua5.1.lib&#8221;. In that case, just include that.</p>
<p>Compiling the project should result in a tolua++.dll. or tolua++.lib, whichever you chose in the project settings.</p>
<p><strong>Executable (.exe)<br />
</strong></p>
<p>Now, to build the executable, you must first build the library. And even thou there is probably some way to do this using the .dll for of the library, it&#8217;s easier to do it with a static one. So before compiling the executable, first compile the library as a static library (not as .dll (project settings)), to get a proper .lib file.</p>
<p>To create tolua++.exe, open the &#8220;File-&gt;New Project&#8221; menu, select Visual C++-&gt; Win32 -&gt; Win32 console project. Add the files &#8220;tolua.c&#8221;, &#8220;toluabind.c&#8221; and &#8220;toluabind.h&#8221; to the project. (NOT toluabind_default.*)</p>
<p>Similarly to the previous step, add the lua .lib include directory (in project settings &#8211; linker &#8211; additional library directories) and the lib itself (project settings &#8211; linker &#8211; input (just write the library filename there (no path)))</p>
<p>If you have listened to my advice and linked the tolua++ library statically, don&#8217;t add anything in the &#8220;C/C++ -&gt; Preprocessor&#8221; section. If you went with dll, you will probably have to add<br />
&#8220;TOLUA_API=extern __declspec(dllimport)&#8221;</p>
<p>(NOTE: this is not the same line as in previous step. That one was with dllEXPORT).</p>
<p>Note that for v1.0.92, I had to remove the TOLUA_API that appears in toluabind.c:<br />
int TOLUA_API tolua_tolua_open (lua_State* tolua_S)<br />
becomes<br />
int tolua_tolua_open (lua_State* tolua_S)</p>
<p>Update: For 1.0.93 with static linking, I didn&#8217;t have to remove anything like that. So don&#8217;t worry about this unless you get compiler errors.</p>
<h3>Using Visual Studio 2005</h3>
<p>The same comments as above (for vs2003) generally apply, although some minor tweaks need to be made.</p>
<p>Note that, due to VS&#8217; poor c99 support, &#8216;toluabind.c&#8217; in the &#8220;EXE&#8221; build will not compile. There are many lines that look like:</p>
<p>&#8230; int top; top = lua_gettop(tolua_S); static unsigned char B[] = { &#8230;</p>
<p>These need to be changed to:</p>
<p>&#8230; int top = lua_gettop(tolua_S); static unsigned char B[] = { &#8230;</p>
<p>or similar.</p>
<p>Tested with vs2005 (no service packs) and tolua++ 1.0.91.</p>
<p>Codereactor update: Had no problems like this in VS2008, so maybe this is not the problem at all anymore.</p>
<p>You can also download the precompiled executable from here: <a href="/?p=161">tolua++.exe precompiled executable download</a>.</p>
<p>As for the precompiled library, I advice you not to bother. Tolua++ is just a couple of c files, just include them into the sources in your project, and forget about all that library inclusion hassle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/compiling-tolua-1-0-93-without-scons-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding a scripting language in your own C++ programs</title>
		<link>http://www.codereactor.net/embedding-scripts-in-c-programs/</link>
		<comments>http://www.codereactor.net/embedding-scripts-in-c-programs/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 21:48:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codereactor.net/?p=136</guid>
		<description><![CDATA[One of my current projects has gained the critical mass complexity that can justify an embedding of a scripting language, so that some parts of the projects can be flexibly scripted instead of being hardcoded into the C++ code and thus require a time-consuming compilation every time anything changes. After reading a little about this, [...]]]></description>
			<content:encoded><![CDATA[<p>One of my current projects has gained the critical mass complexity that can justify an embedding of a scripting language, so that some parts of the projects can be flexibly scripted instead of being hardcoded into the C++ code and thus require a time-consuming compilation every time anything changes.</p>
<p>After reading a little about this, I found out that there are a lot of options, and most of them are really easy!</p>
<p>My first idea was to have two different programs, one in C++ and the other one in PHP (but any other multipurpose script language would suffice), and make them communicate with each other. The best choice for communication would the TCP/IP sockets, and interface could be coded pretty easily. Each function that needed to be exported, could easily be mapped through the network code. Two different programs could even be located on different machines and easily connect through the net.</p>
<p>This solution is possible, and is not that bad actually, but it can get pretty annoying to have two different programs to run and maintain.</p>
<p>So there I came upon the Real solution.</p>
<p>The two script embedding options I liked the most were Lua and JavaScript engine spidermonkey.</p>
<p>Lua is an opensource scripting language, which is very easy to embed and is being used worldwide mostly in games to script the gaming logic. It&#8217;s biggest advantage is the speed. By checking different benchmarks, I found out that lua code can be just around 30 times slower than c++ code, which is VERY fast for a scripting language. (For comparison, php is like 300-400 times slower, perl is something like 100-300 times, and Java approx. 10 times).</p>
<p>With this speed, some pretty complex calculations could be easily done in lua, instead of being hardcoded. The other advantage is that lua is semantically extensible, which means that it has very few features out of the box, but you could easily implement almost any paradigm or design pattern, whichever is most suitable for your application.</p>
<p>For example, there are no classes in their usual meaning in lua, they are instead &#8220;implemented&#8221; in code. When using lua, you are not only writing programs, but also sort of create your own language as you go.</p>
<p>As for embedding, with a small additional opensource library (of mostly macros) Luabind, binding functions and classes of your c++ program to lua becomes a piece of cake. It almost comes down to 1 extra line of code per mapped function, really smooth.</p>
<p>The second option I am considering is JavaScript spidermonkey, which is an embeddable JavaScript engine from Mozilla.</p>
<p>It would be great to have JavaScript in my project, since it&#8217;s awesomely flexible, wide-spread and very easy to code in, having a common syntax. Also, for most web developers, JavaScript is a language where you know every class and every function already.</p>
<p>The downside is the speed (approx. 300-400 times slower than native) and the complexity. Also, since the language itself is much more complex than barebone lua, embedding it to applications and mapping functions and classes from c++ can sometimes be tricky and bloated with type conversions and argument checks.</p>
<p>So this seems to be the pro way to do it, so that&#8217;s what I am gonna do.  (This time it&#8217;s gonna be lua but I am eager to try the spidermonkey some time also).</p>
<p>PS. It&#8217;s a pity I have overlooked this at first, but apparently, boost (which you should use most of the time anyway, cz its awesome) has built-in python bindings which work almost as easy (sometimes even easier) than luabind. So that&#8217;s a great alternative also, especially if you are a python fan.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codereactor.net/embedding-scripts-in-c-programs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

