<?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>engin aydogan</title>
	<atom:link href="http://ea.tl/feed/" rel="self" type="application/rss+xml" />
	<link>http://ea.tl</link>
	<description>&#039;s journal</description>
	<lastBuildDate>Sun, 17 Mar 2013 18:12:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>STM8 Notes</title>
		<link>http://ea.tl/2013/03/17/stm8-notes/</link>
		<comments>http://ea.tl/2013/03/17/stm8-notes/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 18:12:56 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=753</guid>
		<description><![CDATA[STM8
- program memory bus 32-bit, can fetch 1 or 2 instructions at once
- instruction pipeline: fetch, decode, execute, write operations overlap for the next instruction, so while decoding n-th instruction, CPU is fetching n+1-th instruction and so on.
- stack is decremented
- timer interrupt can  [...]]]></description>
				<content:encoded><![CDATA[<p>STM8<br />
- program memory bus 32-bit, can fetch 1 or 2 instructions at once<br />
- instruction pipeline: fetch, decode, execute, write operations overlap for the next instruction, so while decoding n-th instruction, CPU is fetching n+1-th instruction and so on.<br />
- stack is decremented<br />
- timer interrupt can be as late as 15 cycles. executing instruction can take 1-6 cycles, and context save is fixed 9 cycles.<br />
- 0xXX0000 &#8211; 0xXXFFFF is a section where XX is section number<br />
- 0xXXXX00 &#8211; 0xXXXXFF is a page where XXXX is page number<br />
- CALL, CALLR, RET can be used in the same section only. This stores PH and PL into the stack. !!NOT VERY CLEAR section 4.1.!!<br />
- JPF, CALLF, RETF can be used to jump to any place &#8212; F is far. This stores whole PE, PH, PL &#8211; 24-bit PC into stack.<br />
- As SP is 16-bit, it has to be in the section 0.<br />
- Interrupt vector is at 0&#215;8000 with 32 4 byte data. Where MSB is reserved 0&#215;82 opcode and the remaining 24-bit is the address of the interrupt routine<br />
- STM8 uses Hardware Architecture and has two busses; program and data memory.<br />
- STM8 has a 3 stage pipeline Fetch, Decode, Execute. PC always points to the instruction in the decode stage.<br />
- Any instruction bigger than 4-bytes requires 2 fetches<br />
- Flash fetches are 4-byte aligned<br />
- Flash bus is 32 bit where RAM bus is 8 bit.. Hence program execution from RAM is slower.<br />
- Opcode is 1-2 byte, data/operand 0-3 bytes<br />
- reg-to-reg operation can be 1 byte in total&#8230; LD A, XH is 0&#215;95 as opcode and no data/operand at all.<br />
- if an instruction is spread over an alignment boundary, two fetches will be required<br />
- for indirect access CPU is stalled during fetching the pointer value from memory<br />
- if two stages (decode, execute) tries to access to same memory region, decode is halted until execution releases the memory resource.<br />
- Jumps flush pipeline</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2013/03/17/stm8-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php default_charset and header enforcement on charsets</title>
		<link>http://ea.tl/2013/02/12/php-default_charset-and-header-enforcement-on-charsets/</link>
		<comments>http://ea.tl/2013/02/12/php-default_charset-and-header-enforcement-on-charsets/#comments</comments>
		<pubDate>Tue, 12 Feb 2013 18:08:50 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=748</guid>
		<description><![CDATA[I had the following snippetheader('Content-type: application/json; charset=utf-8');Then I noticed what it was actually giving in response was charset=utf8 (note the missing dash).
I wouldn&#8217;t have noticed it until my application failed in Internet Explorer &#8212; while working perfectly in all other  [...]]]></description>
				<content:encoded><![CDATA[<p>I had the following snippet</p><pre class="crayon-plain-tag">header('Content-type: application/json; charset=utf-8');</pre><p>Then I noticed what it was actually giving in response was charset=utf8 (note the missing dash).</p>
<p>I wouldn&#8217;t have noticed it until my application failed in Internet Explorer &#8212; while working perfectly in all other browsers.</p><pre class="crayon-plain-tag">SCRIPT58734: Could not complete the operation due to error c00ce56e. angular.min.js, line 98 character 124</pre><p>It turns out Internet Explorer is very picky on the charset and givent the fact that PHP was not actually sending the charset I&#8217;m telling it to, I had to resort to modify php.ini</p><pre class="crayon-plain-tag">default_charset = "UTF-8"</pre><p>Above charset enforces the proper charset.</p>
<p>I haven&#8217;t thoroughly examined what lead PHP to ignore my explicit headers but this sure fixed it.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2013/02/12/php-default_charset-and-header-enforcement-on-charsets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book Review: So Good They Can&#8217;t Ignore You</title>
		<link>http://ea.tl/2013/01/11/book-review-so-good-they-cant-ignore-you/</link>
		<comments>http://ea.tl/2013/01/11/book-review-so-good-they-cant-ignore-you/#comments</comments>
		<pubDate>Fri, 11 Jan 2013 03:20:50 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[psychology]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=728</guid>
		<description><![CDATA[What&#8217;s this book about ?
Study how to get a good job and love what you do.
Written by Cal Newport.
One Sentence Summary
Good jobs are rare and to get something that is rare and you have to provide something that is valuable (rare) which is your expertise in that particular field gained  [...]]]></description>
				<content:encoded><![CDATA[<h1>What&#8217;s this book about ?</h1>
<p>Study how to get a good job and love what you do.</p>
<p>Written by <a href="http://www.calnewport.com/books/sogood.html">Cal Newport.</a></p>
<h1>One Sentence Summary</h1>
<p>Good jobs are rare and to get something that is rare and you have to provide something that is valuable (rare) which is your expertise in that particular field gained through years of rigorous<strong> </strong>hard working.</p>
<h1>Summary</h1>
<p>Author is trying to answer the questions; how to get a good job and love what you do.</p>
<p>He starts by refusing the widely accepted career advice &#8220;following your passion&#8221;. According to author, there&#8217;s no one magical single true job waiting for you somewhere in the wild, instead, you grow to like your job as you get good at it. He presents scientific evidence that shows the likelihood of loving what you do correlates with how much time you spent on it. That&#8217;s, the longer time you spent on a job, the more you like it as you become competent on it. <strong>This is rule #1</strong>. Author claims that there are MANY jobs that you can be passionate about once you are competent on it.</p>
<p>To answer the question &#8220;how to get a good job&#8221;, however, we obviously first need to define what a good job is.</p>
<p>Author defines the <strong>traits of a good job</strong> as<br />
- <strong>Creativity </strong>: Being able to be creative at the job.<br />
- <strong>Impact </strong>: Make positive difference in the world.<br />
- <strong>Control </strong>: The amount of control you have in your daily life like when you wake up, when you can take a time off.</p>
<p>Then, author tells how all these traits are hard to find in jobs, which, in practice makes good jobs a rare commodity. In economics, supply and demand model dictates that if supply is low (good jobs are rare) and demand is high (everybody wants them) then the price will be high. Which, in practice, means that you have to offer a very good value to get these good jobs.</p>
<p>Offering good value to get a good job is attributed to &#8220;career capital&#8221;. <strong>Career capital</strong> is your accumulated expertise in your field that you can offer to get that good job. <strong>This is rule #2</strong>.</p>
<p>After acquiring career capital, author says you can trade them with traits which makes a job great. For instance, if you prove to be an indispensable employee, you can demand less working hours &#8212; <strong>control</strong>.</p>
<p>Author goes on to describe what is the most efficient way to acquire career capital, and that is deliberate practice. <strong>Deliberate practice</strong> is defined as always getting a bit out of your comfort zone and pushing your skills forward.</p>
<p>Even though there are three traits for making a job great, author emphasizes control trait the most and <strong>rule #3</strong> is that you should spend the career capital you gained for control on your daily life.</p>
<p>In the final rule, <strong>rule #4</strong>, the author starts mentioning a new concept: mission. Author claims that mission is one of the most important traits you can trade with your career capital for a compelling career. To acquire a mission however, you must be cutting edge in your field, so that you can see the next big thing and make that your mission. According to author, missions are tricky, so you must make little bets for reaching your missions. Such as monthly projects which attempts to solve one little piece at a time. If it fails move on, if it yields good results keep on.</p>
<h1>Criticism</h1>
<p>I found the book thought provoking.</p>
<p>Even though the traits of a good job are merely opinions and not a result of scientific study, I agree with them. Like many of the texts you&#8217;d find in this field of writing &#8212; that is self improvement, maybe ? &#8212; you often find very obvious answers to questions and this book is no exception. It says that you have to work real hard for real long time to get a good job. Obvious right ? Right. But it goes in detail to give you the grounds to realize what you are doing wrong.</p>
<p>For instance, I really could relate myself to many things written in the book. Like hitting the a performance plateau. I really started to avoid deliberate practice as I progressed in my professional career and that made me hit the performance plateau. Before reading this book, I have already started to realize this, so I was putting myself outside of my comfort zone to try to improve the quality of code I&#8217;m producing but this book made it very clear for how common and important a problem is this . These problems have been studied by performance scientists mentioned in the book.</p>
<p>So, generally, I came to agree with most of the conclusions drawn by the author.</p>
<p>Though, I think the book lacks scientific evidence on some of the theories it is suggesting, rendering them merely opinions. Also, in some occasions very little sample pool is used to draw conclusions (page 37).</p>
<p>Author makes some assumptions from his personal opinions of the concepts which is the very core of the book and builds the book on top of them but soon becomes a prisoner of these assumptions he made himself and religiously defends them. This reminded me of the term &#8220;intelligence trap&#8221; as defined by Edward de Bono.</p>
<p>He goes on to rule &#8220;follow your passion&#8221; advice out completely and defend this thought whatsoever. I think this is not a black and white area and we should be more open. For instance check this bit.</p>
<p>In the book, there&#8217;s a story of a musician named Jordan Tice. Author explains how hard Tice worked to get to the point where he is now.</p>
<blockquote><p>It asks you to leave behind self-centered concerns about whether your job is &#8220;just right&#8221;, and instead put your head down and plug away at getting really damn good.</p></blockquote>
<p>The author suggests Tice didn&#8217;t question if being a musician is the right job for him or not, he put his head down and worked his ass of regardless and once he got competent on it he became passionate.</p>
<p>Author, immediately quotes one of the many similar arguments he heard from his readers against this theory.</p>
<blockquote><p>Tice is willing to grind out long hours with little recognition, but that&#8217;s because it&#8217;s in service to something he&#8217;s obviously passionate about and has been for a long time. He&#8217;s found that one job that&#8217;s right for him.</p></blockquote>
<p>He defends his stands with:</p>
<blockquote><p>I don&#8217;t buy it.<br />
First, let&#8217;s dispense with the notion that performers like Jordan Tice or Steve Martin are perfectly secure in their knowledge that they&#8217;ve found their true calling.</p></blockquote>
<p>I think the fact that they were insecure does not mean that they were not passionate. I believe, they kept bettering themselves against all the odds because they were passionate about what they do. <strong>The thing we should study here is <em>what is it that ignites the passion in the first place.</em></strong></p>
<p>Author is also a amateur musician and compares himself to Tice:</p>
<blockquote><p>To the high school version of myself, the idea of learning complicated lead parts by ear would have been way past my threshold of mental strain and patience. But Jordan came to enjoy this labor.</p></blockquote>
<p>But skips to study the reason why Jordan enjoyed that labor. I call it passion.</p>
<h2>Conclusion</h2>
<p>I took what I could to the best of my ability from the book and enlightened in some ways but, to be honest, I do think the thoughts presented in the book are not of book quality yet as they are often opinions rather than scientific facts. They might be accurate or not but I expect a more scientific approach in books.  But that might be just me.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2013/01/11/book-review-so-good-they-cant-ignore-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Internet Book</title>
		<link>http://ea.tl/2013/01/05/the-internet-book/</link>
		<comments>http://ea.tl/2013/01/05/the-internet-book/#comments</comments>
		<pubDate>Sat, 05 Jan 2013 15:55:00 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=722</guid>
		<description><![CDATA[I had this idea of making an animated and narrated documentary of how internet (word wide web) works. It&#8217;s a phenomenon we use daily, yet, very few people appreciate what&#8217;s going on during that few seconds while a page is being retrieved from a server thousands of kilometers away.
I had to start  [...]]]></description>
				<content:encoded><![CDATA[<p>I had this idea of making an animated and narrated documentary of how internet (word wide web) works. It&#8217;s a phenomenon we use daily, yet, very few people appreciate what&#8217;s going on during that few seconds while a page is being retrieved from a server thousands of kilometers away.</p>
<p>I had to start from somewhere, so, I start writing a mini book about how world wide web works.</p>
<p>Please feel free to contribute.</p>
<p><a href="https://github.com/engina/the-internet-book">https://github.com/engina/the-internet-book</p>
<p></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2013/01/05/the-internet-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design approaches to web applications revisited</title>
		<link>http://ea.tl/2012/12/11/design-approaches-to-web-applications-revisited/</link>
		<comments>http://ea.tl/2012/12/11/design-approaches-to-web-applications-revisited/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 14:00:45 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=670</guid>
		<description><![CDATA[Traditional Way
Traditional web applications consist of several &#8220;pages&#8221;. Each page requires external resources such as CSS, Javascript and image files to be fetched. Every time we load a web page those resources are also loaded with it. So whenever you navigate from one page to another, all these  [...]]]></description>
				<content:encoded><![CDATA[<h1>Traditional Way</h1>
<p>Traditional web applications consist of several &#8220;pages&#8221;. Each page requires external resources such as CSS, Javascript and image files to be fetched. Every time we load a web page those resources are also loaded with it. So whenever you navigate from one page to another, all these resources are loaded again and most of these resources are static. They are always the same, yet, they are reloaded every time you navigate in the web site.</p>
<p>Implementations and specifications are evolved to remedy these design problems. Each resource was retrieved by a separate connection in HTTP 1.0, it was only since HTTP 1.1, we started to re-use existing connections to retrieve additional resources. Even then, to be a good network citizen, browsers only open limited number of connections to an origin, so additional resources are queued and fetched in serial fashion anyway.</p>
<p>Additionally, we started to use HTTP caching directive headers aggressively to avoid re-fetching of the resources.</p>
<p>Furthermore, we enabled gzip compression to compress textual data in the server before sending it to the browsers which support it.</p>
<p>But no matter what you do, even if you avoid re-fetching resources completely, the browsers reloads them from its cache. This means they are processed again and cause visual imperfection, as you can notice the page is being re-rendered.</p>
<p>Furthermore when we reload the page, it is a challenge to keep the state of all the visual components. This is basically due to HTTP is being an inherently stateless design.</p>
<p>This is, obviously, a severely broken way. Web&#8217;s needs have changed and this design is clearly far from ideal for today&#8217;s scenarios.</p>
<h1>A more modern approach</h1>
<p>For the past few years, I&#8217;ve adopted another design approach which today&#8217;s web giants such as Facebook, Twitter and finally Google too have adopted to some degree.</p>
<p>Even though it has existed before that, a new technique called Ajax emerged around 2005 which is basically just a feature that you can use to send web requests in the background without reloading the web page and get the result back. So, with this technique, you could retrieve new information, such as live stock data, in the background and update some part of the page without reloading it completely.</p>
<p>This was actually a ground braking approach. It remedies most of the flaws of the traditional way of web application development. Yet, it took quite some time for people adopt and really use it. For instance, Google Ajaxified Youtube&#8217;s comment system just a few years ago. Even though, Facebook used Ajax for many of its tasks for a very long time, Facebook recently Ajaxified most of its interface, such as when you click on a photo, it just pops up a dialog right now instead of sending you to another page &#8212; which was the case about a year ago.</p>
<p>I do believe that ideal web application is just a single static web page which can be served with very high speed, redundant technologies such as CDN servers which have no dynamic page creation ability. After the web application is loaded, it&#8217;ll communicate with the back-end server via Ajax requests in the background. I&#8217;ve used this technique successfully and the result was amazing, it was the fastest user experience I&#8217;ve ever seen in a web page. I&#8217;ve engineered whole thing to be as fast as possible.</p>
<p>Try it for yourselves, I was playing with a toy project which is now in hiatus status, which is hosted at <a href="http://beta.gettingback.at/">http://beta.gettingback.at/</a>. Go ahead and test the speed for yourselves. Once, it is cached, It takes 600 ms for the whole page to be loaded and rendered completely, from a server which is 2600 km away. Clicking on any link on the page just pops up another dialog to show you the information you are requesting. If you design your application smarter, you can fetch-ahead some of the data user is most likely to click so the experience can get even more faster. The responsiveness and perceived speed is outstanding.</p>
<h1>A single static web application</h1>
<h1>Benefits</h1>
<p>- <strong>Lower requirements.</strong> You can serve the UI file with the dummiest web servers available even with the lowest technology CDN servers.<br />
- <strong>Minimal bandwidth usage.</strong> As all the communication is done over Ajax and all transferred information is strictly data and no repetitive, redundant information (such as the presentation logic &#8212; i.e. html).  This cuts cuts bandwidth costs.<br />
- <strong>Minimal server load, distributed computing.</strong> As presentation logic is completely on the client, server does not need to fiddle with templates and all sort of stuff which has a computational expense. Hence, in a sense, you are distributing computing expenses to the clients.<br />
- <strong>Optimizable</strong>. Single static web page proved to be easier to optimize &#8212; more on that later.</p>
<h1>Problems</h1>
<p>- <strong>Lack of frameworks.</strong> Since this approach is not widely adopted there are lack of frameworks that dictate best practices.<br />
- <strong>Back and forward buttons.</strong> As this approach keeps the user in one single page back and forward buttons&#8217; job is rendered useless. Luckily enough, this was the first problem noticed with Ajax and had been worked on for a long time and solutions exist.</p>
<h1>What&#8217;s the best way to communicate with the API ?</h1>
<p>So, how should we design our API ? We most probably want our API to be accessible by the world as 3rd party developers will use it. This means cross-domain communication. If our API is at http://api.foo.com and another page such as http://static.foo.com tries to access it, it will be a cross domain communication.</p>
<p>What are our options for cross domain communication ?</p>
<p>I&#8217;ve studied the subject in my post <a href="http://ea.tl/2010/03/31/cross-domain-data-push-methods-compared/">Cross-domain data-push methods compared</a> <strong>two years ago</strong>. Back then, using a transparent Flash as cross-domain communication proxy seem like the way to go to me. Mainly because:</p>
<p>- Flash can maintain a single connection and many request-response on it<br />
- Flash has raw TCP connection so you can freely implement a bandwidth efficient protocol.<br />
- Flash was a very ubiquitous technology which was available in %99 of the browsers &#8212; making it the most cross-browser method.</p>
<p>Though it proved to have some<a href="http://ea.tl/2010/04/15/externalinterface-performance-on-different-browsers/"> performance challenges</a>.</p>
<p>Other dominant competing methods was JSONP and XHR.</p>
<p>JSONP is inherently cross-domain compatibly while XHR had cross-domain communication support with the introduction of <a href="http://www.w3.org/TR/access-control/">CORS</a> and IE introduced CORS support in IE8. Back at the time I wrote above comparison article IE6 and IE7 market share was %19,6 according to <a href="http://www.w3schools.com/browsers/browsers_explorer.asp">statistics</a> hence rendering the XHR CORS method not available in at least %19,6 of the market. Now, things has changed and IE6 and IE7 market share dropped to %1.5 as of October 2012.</p>
<p>This makes XHR with CORS compatible with the vast majority of the market, most likely above %95. So, XHR is a serious choice again.</p>
<p>JSONP virtually has 100% browser compatibility.</p>
<p>Furthermore, JSONP and XHR are mobile device friendly unlike Flash. This leaves us two serious competitors for modern times, JSONP and XHR.</p>
<table border="1">
<tbody>
<tr>
<td></td>
<td style="text-align: center;"><strong>JSONP</strong></td>
<td style="text-align: center;"><strong>XHR CORS</strong></td>
</tr>
<tr>
<td><strong>Browser compatibility</strong></td>
<td style="text-align: center;">%100</td>
<td style="text-align: center;">%95 (roughly according to <a href="http://www.w3schools.com/browsers/browsers_stats.asp">statistics</a>)</td>
</tr>
<tr>
<td><strong>Error handling (failed requests)</strong></td>
<td style="text-align: center;">Poor</td>
<td style="text-align: center;">Built-in</td>
</tr>
<tr>
<td><strong>Ability to upload data without 2kb limit</strong></td>
<td style="text-align: center;">NO (As it only supports GET method)</td>
<td style="text-align: center;">YES</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong>I believe it is justified to chose XHR technology for cross domain communication today.</strong></p>
<p>YouTube API already has XHR support with this new access control specification. Though, Facebook still uses JSONP internally for most of its communication, probably because it is working just fine.</p>
<h1>Caveats of XHR CORS</h1>
<p>From now on, I&#8217;ll refer to XHR assuming it has CORS implementation.</p>
<p>Now, there are at least two types of XHR requests defined as I&#8217;ve already wrote about <a href="http://ea.tl/2010/01/25/cross-domain-xhr-access-control-preflight/">here</a>.</p>
<p>- <strong>Simple requests</strong>: These are the requests with HTTP methods GET, POST or HEAD and have no custom HTTP headers in it.<br />
- <strong>Not so simple requests</strong>:  Any request who does not fit into above criteria is not a simple request and requires a preflight request (explained below). So, this renders strictly RESTful APIs which rely on PUT and DELETE methods less robust.</p>
<p><strong>What is a preflight request ?</strong></p>
<p>If browser decides it requires a preflight request, it first sends an HTTP request with method OPTIONS to ask if the server allows you to do cross domain requests to her then the actual request is executed. So a preflight request means doubling your number of requests for a resource. If you keep asking for the same resource (URL part before that #) preflight cache will be used and you&#8217;ll spare subsequent OPTIONS requests. But if you ask for different resources (foo.php?q=a and foo.php?q=b) then each of these requests will require preflight requests.</p>
<p><strong>So what can be do about preflight requests ?</strong></p>
<p>- We can use a simple requests which does not require preflight requests at all &#8212; that is only GET, POST, HEAD methods with no custom headers.</p>
<p>If that is not an option and we inevitably need preflight requests &#8212; for instance because we need to add custom HTTP headers to our request:</p>
<p>- We can use a single entry point to our api (api.php) and pass all the parameters via POST to keep the URL fixed hence there will only be one preflight request. Basically, we&#8217;ll just have http://api.foo.com/api.php and send all the parameters to that very same resource with POST parameters hence require only one single preflight request.</p>
<p>Sometimes, the JS libraries we use send custom headers by default. For instance ExtJS, Dojo and Prototype JS libraries were sending custom HTTP headers without consulting the developer, rendering a simple request complex one and hence requiring a preflight request. Maybe some of those libraries have some ways to stop this behavior, I haven&#8217;t check.</p>
<p>For instance, with ExtJS you can stop it using custom headers with the following  property.</p><pre class="crayon-plain-tag">Ext.Ajax.useDefaultXhrHeader = false;
Ext.Ajax.request({url: ............... });</pre><p>Note that, this API is not documented for normal ExtJS as it is marked as a private API but it is documented in ExtJS Touch API.</p>
<h1>Conclusion for server-side designs</h1>
<p>You have two options</p>
<h5>1) Single entry point API handler</h5>
<p>I believe the most robust way is to have a single entry point and encourage using POST method only. All interaction will be done on your entry point so even if preflight is required, it will be done only once.</p>
<p>HTTP <strong>POST</strong> your parameters, such as <strong>{controller: user, method: search, query: foo}</strong> to <strong>http://foo.com/api.php</strong>. Note, that you are always interacting with the same URL. POST method is chosen over GET because it can reliably send more data than GET method.</p>
<p>This pattern contradicts with most of the server-side you&#8217;ll find today as they adopt MVC pattern with pretty URLs as their design choice.</p>
<h5>2) Pretty URLs with strictly simple requests</h5>
<p>The frameworks out there which adopted MVC pattern and preferred pretty URLs create many resources. This might have an impact on the performance as they might require separate preflight request for each resource such as <strong>http://api.foo.com/post/5</strong> and <strong>http://api.foo.com/post/8</strong> are both different resources and require separate preflight requests &#8212; unless they are strictly simple requests.</p>
<p>So, if we want to use multiple resource APIs, we should make sure our clients are sending simple requests. Otherwise we&#8217;ll perform poorly as a preflight will be required for each resource.</p>
<h1>Final thoughts for server-side design</h1>
<p>In many scenarios the only difference between the implementation of two options listed above is an HTTP rewriting module in the web server. As you can rewrite <strong>http://api.foo.com/user/add</strong> into <strong>http://api.foo.com/?c=user&amp;m=add</strong> anyway. Their implementations are pretty much the same but the way they perform in different scenarios are different &#8212; as one of them would require preflight and the other won&#8217;t.</p>
<p>As for the CORS specification. I couldn&#8217;t figure out, why the CORS specifications require separate preflight requests per resource. I believe a domain/path wide access-control policy would be more robust.</p>
<p>If particular resources need special restrictions they could still do it, as each HTTP request has an <em>origin</em> header in it, per resource restrictions might be applied too.</p>
<p>I don&#8217;t know why it hasn&#8217;t been designed this way.</p>
<h1>Client-side design</h1>
<p>Everything is fine, we pretty much decided how should our API ideally be designed. Now, what ?</p>
<p>With the new web application design, server-side is just for data retrieval, so we need a powerful ways of designing our user experience in the client side.</p>
<p>There are many Javascript libraries out there, such as venerable jQuery but rarely they provide high quality UI components. Windows provides many controls, similarly, other frameworks such as Qt also provides tons of widgets that we can assemble together to build an application but Javascript ecosystem is just catching up.</p>
<p>If you don&#8217;t need many UI components such as Grids, Panels and layout managers you should definetely go with jQuery, it is a very innovative and intuitive library that would dramatically make your work simpler.</p>
<p>But if you need a more corporate-like professional applications, you want a consisten look among all your UI components and a big collection of components to chose from. In that respect, ExtJS comes into play. They provide a very high quality JS library. Yet, they naturally, have a much more steep learning curve.</p>
<p>&nbsp;</p>
<h1>How to glue client-side and server side</h1>
<p>Most of the time you have to glue them together manually. This is one department we have to work on. I&#8217;m speculating ideas about to generate a JS API on the fly by server via Refletion APIs of the server-side languages. In fact, I&#8217;m playing with a server side framework idea does generate an API specification automatically, as you add more services to it. Here&#8217;s a sample output.</p><pre class="crayon-plain-tag">{
  "Project":{
    "test":{
      "parameters":{
        "name":{
          "optional":false,
          "type":{
            "name":"String"
          }
        },
        "surname":{
          "optional":false,
          "type":{
            "name":"String"
          }
        }
      }
    }
  },
  "Session":{
    "status":{
      "parameters":[

      ]
    },
    "create":{
      "parameters":[

      ]
    }
  },
  "User":{
    "getStatus":{
      "parameters":[

      ]
    }
  }
}</pre><p>&nbsp;</p>
<p>In the mean time, ExtJS acted quicker and they propose a solution to this problem with <a href="http://docs.sencha.com/ext-js/4-1/#!/api/Ext.direct.Manager">Ext.Direct</a>. I&#8217;ll study its design and probably write about it soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/12/11/design-approaches-to-web-applications-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Modeling Language</title>
		<link>http://ea.tl/2012/12/07/simple-modeling-language/</link>
		<comments>http://ea.tl/2012/12/07/simple-modeling-language/#comments</comments>
		<pubDate>Fri, 07 Dec 2012 15:54:05 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=629</guid>
		<description><![CDATA[I&#8217;ve wrote about the State of the ORMs and how it is essential to have a well defined model first.
When I was looking for ways to design my models, I was quite surprised that it is such a pain in the ass. There&#8217;s a huge demand for this and a tremendous amount of work has been done but they all seem  [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve wrote about the <a href="http://ea.tl/2012/12/07/state-of-the-orms/">State of the ORMs</a> and how it is essential to have a well defined model first.</p>
<p>When I was looking for ways to design my models, I was quite surprised that it is such a pain in the ass. There&#8217;s a huge demand for this and a tremendous amount of work has been done but they all seem unintuitive and overly complicated.</p>
<p>For instance take a look at propel&#8217;s modeling language</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;database name="bookstore" defaultIdMethod="native"&gt;
  &lt;table name="book" phpName="Book"&gt;
    &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/&gt;
    &lt;column name="title" type="varchar" size="255" required="true" /&gt;
    &lt;column name="isbn" type="varchar" size="24" required="true" phpName="ISBN"/&gt;
    &lt;column name="publisher_id" type="integer" required="true"/&gt;
    &lt;column name="author_id" type="integer" required="true"/&gt;
    &lt;foreign-key foreignTable="publisher" phpName="Publisher" refPhpName="Book"&gt;
      &lt;reference local="publisher_id" foreign="id"/&gt;
    &lt;/foreign-key&gt;
    &lt;foreign-key foreignTable="author"&gt;
      &lt;reference local="author_id" foreign="id"/&gt;
    &lt;/foreign-key&gt;
  &lt;/table&gt;
  &lt;table name="author" phpName="Author"&gt;
    &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/&gt;
    &lt;column name="first_name" type="varchar" size="128" required="true"/&gt;
    &lt;column name="last_name" type="varchar" size="128" required="true"/&gt;
  &lt;/table&gt;
  &lt;table name="publisher" phpName="Publisher"&gt;
   &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /&gt;
   &lt;column name="name" type="varchar" size="128" required="true" /&gt;
  &lt;/table&gt;
&lt;/database&gt;</pre><p>And I&#8217;m just ranting how it could be defined, just bare with me.</p><pre class="crayon-plain-tag">&lt;book&gt;
  &lt;title max="255"/&gt;
  &lt;isbn:int len="13"/&gt;
  &lt;publisher:publisher/&gt;
  &lt;author:author/&gt;
&lt;/book&gt;

&lt;author&gt;
  &lt;first_name max="128"/&gt;
  &lt;last_name max="128"/&gt;
  &lt;books:book[]/&gt;
&lt;/author&gt;

&lt;publisher&gt;
  &lt;name max="128"/&gt;
  &lt;books:book[]/&gt;
&lt;/publisher&gt;</pre><p>I think any programmer who is familiar with array accessor operator [] would immediately understand what about model means exactly.</p>
<p>Defaults</p>
<p>* Each table has a INT PK AI (Primary Key, Auto Increment)</p>
<p>* Each field is required=true and type=text. I put the max=&#8221;128&#8243; just to represent as much information as the original XML does.</p>
<h1>Defining cardinality (relationship association types)</h1>
<h5>one-to-one</h5>
<p>Imagine each book can has only one author and each author can only have one book.</p><pre class="crayon-plain-tag">&lt;book&gt;
  ...
  &lt;author:author/&gt;
&lt;/book&gt;

&lt;author&gt;
  ...
  &lt;book:book/&gt;
&lt;/author&gt;</pre><p>This should generate either <strong>author_id</strong> field in the <strong>book</strong> entity <span style="text-decoration: underline;">OR</span> <strong>book_id</strong> in the <strong>author</strong> entity.</p>
<p>Note that this schema is also applies for one-to-many. If enforcing one is required, then a <strong>unique index</strong> can be created for <strong>author_id</strong> or <strong>book_id</strong> field.</p>
<h5>one-to-many</h5>
<p>Imagine each author can have many books (naturally).</p><pre class="crayon-plain-tag">&lt;book&gt;
  ...
  &lt;author:author/&gt;
&lt;/book&gt;

&lt;author&gt;
  ...
  &lt;book:book[]/&gt;
&lt;/author&gt;</pre><p>This will generate <strong>author_id</strong> in the <strong>book</strong> entity and that&#8217;s it.</p>
<h5>many-to-many</h5>
<p>It is perfectly possible for one book to have many authors, so here&#8217;s what we do.</p><pre class="crayon-plain-tag">&lt;book&gt;
  ...
  &lt;author:author[]/&gt;
&lt;/book&gt;

&lt;author&gt;
  ...
  &lt;book:book[]/&gt;
&lt;/author&gt;</pre><p>Then, we should generate a <strong>book_author</strong> entity with fields <strong>book_id</strong>, <strong>author_id</strong>. Then we can insert as many book-author links as we want.</p>
<p>There might be cases which this syntax fail to define which I can&#8217;t think of right now.</p>
<h1>Syntax</h1>
<p>We can use verbose element attributes such as</p><pre class="crayon-plain-tag">&lt;title type="string" required="true" len="10" index="true"/&gt;</pre><p>Or we can extract common properties of each element and innovate a shorthand syntax for them.</p>
<p>field[*?][:type[(min,max)]] [|validator_function]</p>
<table border="1" cellspacing="0" align="center">
<tbody>
<tr>
<td style="text-align: center; width: 100px;"><strong>Example</strong></td>
<td style="text-align: center; width: 100px;"><strong>Hint</strong></td>
<td style="text-align: center;"><strong>Description</strong></td>
</tr>
<tr>
<td style="text-align: center;">&lt;name/&gt;</td>
<td style="text-align: center;">Default text</td>
<td>Name field of type <em>text</em>.</td>
</tr>
<tr>
<td style="text-align: center;">&lt;name*/&gt;</td>
<td style="text-align: center;">Index</td>
<td>Name field of type <em>text</em> and <em>indexed</em> if possible (if allowed by underlying repository technology)</td>
</tr>
<tr>
<td style="text-align: center;">&lt;name?/&gt;</td>
<td style="text-align: center;">Nullable</td>
<td>Name field of type <em>text</em> and <em>accepts empty values</em>.</td>
</tr>
<tr>
<td style="text-align: center;"> &lt;name*?/&gt;</td>
<td style="text-align: center;">Indexable, Nullable</td>
<td>Name field of type <em>text</em> which accepts <em>empty values</em> and</td>
</tr>
<tr>
<td style="text-align: center;"> &lt;age:int/&gt;</td>
<td style="text-align: center;">Data types</td>
<td>Age field of type <em>int</em>.</td>
</tr>
<tr>
<td style="text-align: center;"> &lt;age:int(18,100)/&gt;</td>
<td style="text-align: center;">Minimum and maximum ranges</td>
<td>Age field of type <em>int</em> where accepted values are <em>between 18 and 100.</em></td>
</tr>
<tr>
<td style="text-align: center;"> &lt;name:text(3,32)/&gt;</td>
<td style="text-align: center;"> Minimum and maximum length</td>
<td>Name field which must be <em>at least 3 characters and at most 32 characters.</em></td>
</tr>
<tr>
<td style="text-align: center;"> &lt;license|uk_license_validator/&gt;</td>
<td style="text-align: center;">Validators</td>
<td>License field of type <em>text</em> and will be <em>validated</em> with a function called <em>uk_license_validator</em> whom stub will be created.</td>
</tr>
<tr>
<td style="text-align: center;">&lt;phone*?:text(7,12)|phone_validator&gt;</td>
<td style="text-align: center;">Mixing up stuff</td>
<td>Phone field of type <em>text</em> whom length can be <em>between 7 and 12</em> and will be <em>validated</em> with <em>phone_validator</em>.</td>
</tr>
</tbody>
</table>
<h1>Data Types</h1>
<p>Known data type with built-in validators</p>
<p>&nbsp;</p>
<table style="width: 500px;" border="1">
<tbody>
<tr>
<td style="text-align: center;"><strong>Data Types</strong></td>
<td style="text-align: center;"><strong>Special attributes</strong></td>
</tr>
<tr>
<td>text</td>
<td></td>
</tr>
<tr>
<td>int</td>
<td></td>
</tr>
<tr>
<td>float</td>
<td>m: digits before the dot d: digits after the dot</td>
</tr>
<tr>
<td>email</td>
<td></td>
</tr>
<tr>
<td>uri</td>
<td>schemas</td>
</tr>
<tr>
<td>Other Models</td>
<td></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/12/07/simple-modeling-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>State of the ORMs</title>
		<link>http://ea.tl/2012/12/07/state-of-the-orms/</link>
		<comments>http://ea.tl/2012/12/07/state-of-the-orms/#comments</comments>
		<pubDate>Fri, 07 Dec 2012 09:21:14 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=618</guid>
		<description><![CDATA[Today, we build applications which talk to each other over (web) services. In fact, we go one step further and separate our one single application into many components (MVC) that talk to each other. We call this abstraction approach, Separation of Concerns (SoC). In the past 10 years, we&#8217;ve seen  [...]]]></description>
				<content:encoded><![CDATA[<p>Today, we build applications which talk to each other over (web) services. In fact, we go one step further and separate our one single application into many components (MVC) that talk to each other. We call this abstraction approach, <a href="http://en.wikipedia.org/wiki/Separation_of_concerns">Separation of Concerns</a> (SoC). In the past 10 years, we&#8217;ve seen many frameworks adopted <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model View Controller</a> (MVC) pattern. Remember when <a href="http://en.wikipedia.org/wiki/Qt_(framework)">Qt4</a> was released in 2005 ? Most hyped feature was the MVC pattern.</p>
<p>These principles and patterns makes the code easier to maintain and test. Furthermore, these separations gave us other opportunities. It showed us once you had your model ready, there are a lot of repeated work to be done.</p>
<ol>
<li>Building a <a href="http://en.wikipedia.org/wiki/Data_access_layer">Data Access Layers</a> (DAL) to persist and manipulate the objects programatically.</li>
<li>Building the graphical user interfaces (GUI) to let users manipulate the objects &#8212; and god&#8230; validate the input data.</li>
<li>Building an application programming interface (API) to let other programs manipulate the objects &#8212; and again&#8230; validate the input data.</li>
</ol>
<p>These tasks have a base no-brainer code to be prepared all the time. Worse, you need to update all these codes when you update your model. If you do not automate this process, you will be reluctant to make any changes to your program because it is such a pain in the ass &#8212; not to mention all the errors you&#8217;d make.</p>
<p>So, it is inevitable that programmers all around the world will find ways to generate code for above tasks. The first one of the above tasks is called <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">Object Relational Mapping</a> (ORM) and there are countless projects available to do that. ORM is basically generating code that does <a href="http://en.wikipedia.org/wiki/CRUD">Create Read Update Delete</a> (CRUD) operations.</p>
<p>Even though most of the ORM projects achieves same goal, they do have different design choices</p>
<h4>ORM Design Choices</h4>
<h6><span style="line-height: 18px;">1. Generation of </span><span style="line-height: 18px;">type safe</span><span style="line-height: 18px;"> strong interfaces</span></h6>
<p>Strong interfaces and <a href="http://en.wikipedia.org/wiki/Type_safety">type safety</a> are inherently available in many platforms like C# and Java and you can&#8217;t go wrong with them but ORM is often used with dynamic languages which lacks many of these features, so ORM projects must take extra cautions. <a href="http://cakephp.org/">CakePHP</a> is not just an ORM framework but a complete solution which can dramatically speed up development time for many scenarios. Though, I do not agree with some of their design choices. For instance CakePHP&#8217;s ORM generates Models with weak interfaces.</p><pre class="crayon-plain-tag">// Instead of doing this
class StrongInterfaceBook
{
    public function getTitle();
    public function setTitle($str);
    public function getAuthor();
    public function setAuthor(Author $author);
}

// CakePHP generates code like this
class WeakInterfaceBook
{
    public function __call($name, $arguments)
    {
         // Figurative code
         $_fieldsToBeUpdate[$name] = $arguments[0];
    }
}

// So, when you call
$c = new WeakInterfaceBook();
// Not the intentional erros in the following line
$c-&gt;setTilte('Foo');
// Your code will execute just fine ignoring the Title field, as it does not exist.

// If you do that with strong interface
$c = new StrongInterfaceBook();
$c-&gt;setTilte('Foo'); // Raises a compile time error.</pre><p>Furthermore, generating strong interfaces help your IDE to auto-complete your code, as the interface can actually be indexed.</p>
<p>I, also, believe that generated code should catch your errors as soon as possible and shouldn&#8217;t allow any silent errors as in the above example. Imagine you&#8217;ve changed your model and renamed a field. Weak interfaces won&#8217;t catch the errors and where a strong interface will raise an error as soon as it is compiled.</p>
<p>For PHP, <a href="http://www.doctrine-project.org/">Doctrine</a> and <a href="http://propelorm.org/">propel</a> generates strongly typed, strong interfaces.</p>
<p>For .NET environment, sqlmetal, which is the code generation utility of Microsoft, generates strongly typed interfaces with an ground braking API (LINQ) which has been inspired many frameworks such as propel. Once you know the caveats of LINQ, it is the ultimate DAL.</p>
<p>CakePHP is also not designed to regenerate your model code all the time &#8212; as it overwrite generated model code in each execution, so you have to merge your changes from your version controlling system back to regenerated code.</p>
<p>In other frameworks, you usually derive from the generated code</p><pre class="crayon-plain-tag">public class BookBase
{
    public string Title
    {
         get
         {
              return m_title;
         }
         set
         {
              validateTitle(value);
              m_title = value;
         }
}

public class Book : BookBase
{
    // Add additional functionality here, so code generated overwrites does not affect you
}</pre><p>Microsoft&#8217;s and propel&#8217;s code generation tools use this design pattern when generating code.</p>
<h6><span style="line-height: 18px;">2. Utilizing data types and model relationships</span></h6>
<p>Models can define some basic things about its fields, such as minimum, maximum values and length which can be easily checked. If the field is of enum type then allowed values are strictly defined so invalid inputs are easy to catch.</p>
<h6><span style="line-height: 18px;">3. Performance</span></h6>
<p>This is least of my concerns, any widely used framework will be well optimized. IMHO, best approach is to generate as much strongly typed code as possible. Even if you rely on runtime introspection, caching will save the performance penalty anyway.</p>
<h4>ORM approaches</h4>
<p>In my humble opinion, models are the core of any design. Once you have defined  your model you can get save yourself the trouble of writing boilerplate code all over.</p>
<h6>1. Code first</h6>
<p>You code your classes, most probably with some extra meta data which is called annotations in Java and attributes in C#. And PHP has a fake annotations which is implemented by extracting meta data from documentation blocks via reflection API.</p>
<p>Some framework such as Doctrine and CakePHP does not allow you to export this model to a easy to read file but they provide extensive introspection API which you can extract all the information from the models.</p>
<p>I, personally, do not like this approach as it does not feel intuitive to me. It is a different way you have to define your model in each platform.</p>
<p>There are many solutions which use this approach such as Java&#8217;s Hibernate and PHP&#8217;s Doctrine. Each project claims to support Database First approach too but they do not favor it and it is not well documented.</p>
<h6>2. Model first</h6>
<p>You define your model here and then generate SQL code to generate the schema in your preferred data base, generate DAL code, or even a REST API complete with documentation and test cases.</p>
<p>I think this is a very good way to start to your project but making changes to your model after you get started (which is inevitable) would require you to sync your database schema with the new model. I&#8217;ve used tools which does this before but I&#8217;m not familiar with how Model First ORM frameworks hand database syncing yet.</p>
<h6>2. Database first</h6>
<p>You create your database schema and extract your model from there. I find this approach fine, as there are many tools to let you design your database easily and most likely with the aid of graphical tool. It is like designing your model in SQL and then converting the model from there. Also by changing your schema on the database eliminates syncing your database with the model problem.</p>
<h4>Conclusion</h4>
<p>I favor the code first approach the least but as long as they export the model information in a concise manner, I&#8217;m fine with with either of the approach.</p>
<p>Once you have extracted  or designed your Model. There are endless possibilities.</p>
<p>1. You can generate DAL</p>
<p>2. You can generate web services to expose your objects</p>
<p>3. You can generate <a href="http://www.sencha.com/products/extjs">ExtJS</a> models so that ExtJS can communicate with your services</p>
<p>4. You can generate ExtJS UIs</p>
<p>And what&#8217;s better is, once you changed the model, your changes will be propagated in all your frameworks, given you have followed proper design patterns.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/12/07/state-of-the-orms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Eclipse PDT + xdebug + external browser</title>
		<link>http://ea.tl/2012/11/21/eclipse-pdt-xdebug-external-browser/</link>
		<comments>http://ea.tl/2012/11/21/eclipse-pdt-xdebug-external-browser/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 20:05:16 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=577</guid>
		<description><![CDATA[Long story short
Eclipse PDT does not allow you to use external browser. You can work around this though.
Add these two lines to your php.inixdebug.remote_autostart = true
xdebug.idekey="ECLIPSE_DBGP"
Keep reading for details
Xdebug works like this: Debugger listens for incoming connections and  [...]]]></description>
				<content:encoded><![CDATA[<h1>Long story short</h1>
<p>Eclipse PDT does not allow you to use external browser. You can work around this though.</p>
<p>Add these two lines to your php.ini</p><pre class="crayon-plain-tag">xdebug.remote_autostart = true
xdebug.idekey="ECLIPSE_DBGP"</pre><p></p>
<h1>Keep reading for details</h1>
<p>Xdebug works like this: Debugger listens for incoming connections and whenever you send a HTTP request to server, the server itself tries to connect to the debugger client.</p>
<p>To achieve this, Eclipse PDT opens a page in the internal browser with some parameters appended to the URL. These parameters tell PHP interpreter that a debug session is desired.</p><pre class="crayon-plain-tag">http://localhost:81/eclipse/cake/caketest/?XDEBUG_SESSION_START=ECLIPSE_DBGP&amp;KEY=13535270012515</pre><p>When opening from an external browser you don&#8217;t have this, in an autmated manner. So, we use <em><strong>xdebug.remote_autostart</strong></em> parameter in php.ini. With the parameter every HTTP request you send to your server which invokes PHP interpreter makes the server try to connect to remote debugger automatically. So you are supposed to not to need the parameters in the URL above.</p>
<p>But it didn&#8217;t work. So I enabled <em><strong>xdebug.remote_log</strong></em> and saw the following:</p><pre class="crayon-plain-tag">Log opened at 2012-11-21 19:57:02
I: Connecting to configured address/port: 127.0.0.1:9000.
I: Connected to client. :-)
-&gt; &lt;init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///C:/Users/Engin/Code/PHP/eclipse/cake/caketest/webroot/index.php" language="PHP" protocol_version="1.0" appid="11472" idekey="ENGIN-VAIO$"&gt;&lt;engine version="2.2.1"&gt;&lt;![CDATA[Xdebug]]&gt;&lt;/engine&gt;&lt;author&gt;&lt;![CDATA[Derick Rethans]]&gt;&lt;/author&gt;&lt;url&gt;&lt;![CDATA[http://xdebug.org]]&gt;&lt;/url&gt;&lt;copyright&gt;&lt;![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]&gt;&lt;/copyright&gt;&lt;/init&gt;

-&gt; &lt;response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"&gt;&lt;/response&gt;

Log closed at 2012-11-21 19:57:02</pre><p></p>
<p>Then I watched the log for a successful debug session with the internal Eclipse browser.</p>
<p></p><pre class="crayon-plain-tag">Log opened at 2012-11-21 19:58:46
I: Connecting to configured address/port: 127.0.0.1:9000.
I: Connected to client. :-)
-&gt; &lt;init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///C:/Users/Engin/Code/PHP/eclipse/cake/caketest/webroot/index.php" language="PHP" protocol_version="1.0" appid="2324" idekey="ECLIPSE_DBGP"&gt;&lt;engine version="2.2.1"&gt;&lt;![CDATA[Xdebug]]&gt;&lt;/engine&gt;&lt;author&gt;&lt;![CDATA[Derick Rethans]]&gt;&lt;/author&gt;&lt;url&gt;&lt;![CDATA[http://xdebug.org]]&gt;&lt;/url&gt;&lt;copyright&gt;&lt;![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]&gt;&lt;/copyright&gt;&lt;/init&gt;

&lt;- feature_set -i 86 -n show_hidden -v 1
-&gt; &lt;response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="86" feature="show_hidden" success="1"&gt;&lt;/response&gt;

&lt;- feature_set -i 87 -n max_depth -v 3
-&gt; &lt;response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="87" feature="max_depth" success="1"&gt;&lt;/response&gt;

...</pre><p></p>
<p>As you can see <em><strong>idekey</strong></em> is different. Hence we also used <em><strong>xdebug.ide_key</strong></em> and it all works out. Finally&#8230;</p>
<p>For the sake of completeness, here&#8217;s my whole xdebug configuration from php.ini</p>
<p></p><pre class="crayon-plain-tag">zend_extension = "c:\Users\Engin\bin\LAMP\php-5.4.8\xdebug\php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.default_enable=0
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart = true
xdebug.remote_log="c:\Users\Engin\bin\LAMP\php-5.4.8\xdebug\log"
xdebug.idekey="ECLIPSE_DBGP"
xdebug.dump_globals=1
xdebug.dump=COOKIE,FILES,GET,POST,REQUEST,SERVER,SESSION
xdebug.dump.SERVER=REMOTE_ADDR,REQUEST_METHOD,REQUEST_URI
xdebug.show_local_vars=1
xdebug.show_mem_delta=1
xdebug.collect_includes=1
xdebug.collect_vars=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.auto_trace=0
xdebug.trace_options=0
xdebug.trace_format=0
xdebug.trace_output_dir="c:\Users\Engin\bin\LAMP\php-5.4.8\xdebug\trace"
xdebug.trace_output_name="trace.%t"
xdebug.profiler_enable=0
xdebug.profiler_append=1
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir="c:\Users\Engin\bin\LAMP\php-5.4.8\xdebug\profiler"
xdebug.profiler_output_name="cachegrind.out.%s.%t"</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/11/21/eclipse-pdt-xdebug-external-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New toy domain; ea.tl</title>
		<link>http://ea.tl/2012/11/12/new-toy-domain-ea-tl/</link>
		<comments>http://ea.tl/2012/11/12/new-toy-domain-ea-tl/#comments</comments>
		<pubDate>Mon, 12 Nov 2012 21:56:00 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ea.tl/?p=566</guid>
		<description><![CDATA[My new toy domain ea.tl is now working and my beloved old domain just does a permanent redirect to the new host from now on. Fancy shit, eh ? I know. I&#8217;m curious how soon Google will realize this new situation and update its indices. With this new very short vanity domain, I also set up a new email  [...]]]></description>
				<content:encoded><![CDATA[<p>My new toy domain <strong>ea.tl</strong> is now working and my beloved old domain just does a permanent redirect to the new host from now on. Fancy shit, eh ? I know. I&#8217;m curious how soon Google will realize this new situation and update its indices. With this new very short vanity domain, I also set up a new email for myself&#8230; <strong><span id="eatlintro"></span></strong><br />
<script>
jQuery(document).ready(function(){jQuery('#eatlintro').html(['e','@', 'e', 'a', '.', 't', 'l'].join(''));});
</script></p>
<p>To do the permanent redirect from my old domain to new one, Apache HTTPD has this awesome feature, check this out:</p>
<p></p><pre class="crayon-plain-tag">&lt;VirtualHost *:80&gt;
        ServerName www.bzzzt.biz
        ServerAlias bzzzt.biz *.bzzzt.biz
        Redirect permanent / http://ea.tl/
&lt;/VirtualHost&gt;</pre><p></p>
<p>Mind the trailing /, at the end of ea.tl, that matters.</p>
<p>Cheers&#8230; I&#8217;m just getting more awesome day by day.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/11/12/new-toy-domain-ea-tl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>suphp SoftException in Application.cpp:299: Script &#8220;foo&#8221; resolving to &#8220;foo&#8221; not within configured docroot</title>
		<link>http://ea.tl/2012/11/07/suphp-softexception-in-application-cpp299-script-foo-resolving-to-foo-not-within-configured-docroot/</link>
		<comments>http://ea.tl/2012/11/07/suphp-softexception-in-application-cpp299-script-foo-resolving-to-foo-not-within-configured-docroot/#comments</comments>
		<pubDate>Wed, 07 Nov 2012 18:45:28 +0000</pubDate>
		<dc:creator>engin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://engin.bzzzt.biz/?p=559</guid>
		<description><![CDATA[Recently I&#8217;ve switched to suphp from regular mod_php to support one application (wordpress) better and for obvious security benefits. Though, one of my application worked flawlessly, another one failed with the following error message in the log.
Actual error:[Wed Nov 07 19:35:27 2012] [error]  [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I&#8217;ve switched to suphp from regular mod_php to support one application (wordpress) better and for obvious security benefits. Though, one of my application worked flawlessly, another one failed with the following error message in the log.</p>
<p>Actual error:</p><pre class="crayon-plain-tag">[Wed Nov 07 19:35:27 2012] [error] [client 78.171.237.162] SoftException in Application.cpp:299: Script "/home/engin/www/api.php" resolving to "/home/engin/www/api.php" not within configured docroot</pre><p>It&#8217;s easy to think that this is related to Apache vhost configuration&#8217;s DocumentRoot but it is not.</p>
<p>My application which is working was located in <strong>/home/usera/public_html</strong> and the failing one was in <strong>/home/userb/www</strong>. Now check the <strong>/etc/suphp/suphp.conf</strong>&#8216;s <strong>docroot</strong> variable:</p><pre class="crayon-plain-tag">docroot=/var/www:${HOME}/public_html</pre><p>As you see, <strong>${HOME}/public_html</strong> is in the docroot, hence one of my application was working and the other one was not. I moved www to public_html and all is fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://ea.tl/2012/11/07/suphp-softexception-in-application-cpp299-script-foo-resolving-to-foo-not-within-configured-docroot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
