<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0"><channel><title>Nir Levy - Eureka</title><link>http://nirlevy.blogspot.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/nirlevy" /><description>-- work overload --</description><language>en</language><managingEditor>noreply@blogger.com (Nir Levy)</managingEditor><lastBuildDate>Mon, 20 May 2013 22:53:46 PDT</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">51</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="nirlevy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>"Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract" While Adding Service Reference in VS2012</title><link>http://nirlevy.blogspot.com/2012/08/cannot-import-wsdl-porttypedetail.html</link><category>C#</category><category>Visual Studio</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 23 Aug 2012 05:14:33 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-4457997361222662110</guid><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-0AeF1HbzmJs/UDXhgojhsPI/AAAAAAAABik/axjsfx2MoFk/s1600/Cannot_import_wsdl.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/-0AeF1HbzmJs/UDXhgojhsPI/AAAAAAAABik/axjsfx2MoFk/s320/Cannot_import_wsdl.png" width="311" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Trying to add a service reference in Visual Studio 2012 to Bing Maps SOAP service I got the following error message:&lt;/p&gt;

&lt;br /&gt;
&lt;pre type="code"&gt;Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract
...
&lt;/pre&gt;
&lt;p&gt;Following &lt;a href="http://stackoverflow.com/questions/12069176/getting-recursive-collection-data-contract-when-referencing-a-wcf-service-with"&gt;Getting “Recursive collection data contract” when referencing a WCF service with a slightly complex method&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/11112960/visual-studio-2012-error-reference-svcmap-throwing-error"&gt;Visual Studio 2012 Error Reference.svcmap throwing Error&lt;/a&gt; I've had to change the "reuse types in referenced assemblies" from "all" to everything except &lt;code&gt;Newtonsoft.JSON&lt;/code&gt; and &lt;code&gt;RestSharp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Might not be something to write home about, but I'm sure I'll forget where it is was in a year or so.&lt;/p&gt;

&lt;p&gt;PS. This seems to be VS2012 only issue, VS2010 worked just fine.&lt;/p&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-23T15:14:33.414+03:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-0AeF1HbzmJs/UDXhgojhsPI/AAAAAAAABik/axjsfx2MoFk/s72-c/Cannot_import_wsdl.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total></item><item><title>Tech-Ed Eilat 2010</title><link>http://nirlevy.blogspot.com/2010/11/tech-ed-eilat-2010.html</link><category>SharePoint 2010</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Wed, 17 Nov 2010 23:37:06 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-6987025930022024836</guid><description>So happy to be presenting at Tech-Ed Eilat 2010.&lt;br /&gt;See you all at the Herods Hotel, Tue 30/11 at 11:15 where we would share our lessons from the field on enterprise web content management with SharePoint 2010.&lt;br /&gt;&lt;br /&gt;You can read more about our session at &lt;a href="http://www.realcommerce.co.il/blog/%D7%90%D7%96-%D7%9E%D7%94-%D7%96%D7%94-%D7%91%D7%9B%D7%9C%D7%9C-enterprise-web-content-management/"&gt;the realcommerce web site&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.microsoft.com/israel/TechEd2010/Tracks/OFC.aspx"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_tdZrSSGIPEc/TOTWjM3n0PI/AAAAAAAABWg/XP0OI7VuRfM/s1600/realcommerce-signature.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-18T09:37:06.823+02:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_tdZrSSGIPEc/TOTWjM3n0PI/AAAAAAAABWg/XP0OI7VuRfM/s72-c/realcommerce-signature.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>IIS JNLP 404 Problem</title><link>http://nirlevy.blogspot.com/2010/01/iis-jnlp-404-problem.html</link><category>java</category><category>iis</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Tue, 26 Jan 2010 02:18:59 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-365589999540514974</guid><description>If your IIS 6 returns a &lt;code&gt;404 Not Found&lt;/code&gt; when you request a Java Web Start &lt;code&gt;jnlp&lt;/code&gt; file, then you probably need to add the jnlp mime-type to the IIS configuration.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;IIS Settings -&amp;gt; Right click the machine -&amp;gt; mime-types -&amp;gt; new Extension: .jnlp MIME Type: application/x-java-jnlp-file&lt;/pre&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_tdZrSSGIPEc/S17BOhpDU9I/AAAAAAAABVk/8X22o9GWHaM/s1600-h/jnlp_iis.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="282" src="http://2.bp.blogspot.com/_tdZrSSGIPEc/S17BOhpDU9I/AAAAAAAABVk/8X22o9GWHaM/s400/jnlp_iis.JPG" width="400" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-26T12:18:59.000+02:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_tdZrSSGIPEc/S17BOhpDU9I/AAAAAAAABVk/8X22o9GWHaM/s72-c/jnlp_iis.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>How to do rewrites in an IIS ISAPI</title><link>http://nirlevy.blogspot.com/2009/10/how-to-do-rewrites-in-iis-isapi.html</link><category>ISAPI</category><category>C++</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Sun, 04 Oct 2009 03:13:38 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-6636011677324898588</guid><description>Note to self: If ever you need to do a &lt;b&gt;rewrite&lt;/b&gt; in an IIS ISAPI Filter you just need to re-set the &lt;code&gt;pHeaderInfo&lt;/code&gt;'s &lt;code&gt;url&lt;/code&gt; header. Something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="c:nogutter"&gt; &lt;br /&gt;pHeaderInfo-&gt;GetHeader(pCtxt-&gt;m_pFC,&lt;br /&gt;              "url",strUrl.GetBuffer(dwUrlSize+1),&amp;dwUrlSize);&lt;br /&gt;strUrl.ReleaseBuffer(); &lt;br /&gt;strNewUrl = GET_REWRITE_FOR_URL(strUrl); &lt;br /&gt;if ( strNewUrl.IsEmpty() == FALSE ) {  &lt;br /&gt;    pHeaderInfo-&gt;SetHeader(pCtxt-&gt;m_pFC, &lt;br /&gt;              "url", (LPTSTR)(LPCTSTR)strNewUrl);  &lt;br /&gt;} &lt;br /&gt;return SF_STATUS_REQ_NEXT_NOTIFICATION; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is working in IIS4 and above.&lt;br /&gt;&lt;br /&gt;Note that if you really need a good re-write/redirect filter for IIS you should look at &lt;a href="http://www.codeplex.com/IIRF"&gt;IIRF&lt;/a&gt; ,but since it's not working for IIS4 i had to do this manually</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-04T12:13:38.815+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>Bing, Google, Nutch and Canonical URLs</title><link>http://nirlevy.blogspot.com/2009/06/bing-google-nutch-and-canonical-urls.html</link><category>SEO</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 18 Jun 2009 01:10:38 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-2543276048509723354</guid><description>Google announced a few months back that they started &lt;a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html"&gt; supporting canonical urls&lt;/a&gt;. This is a great feature that we already adopted in a couple of sites (mostly to keep tracking codes from messing with our search engine results.&lt;br /&gt;&lt;br /&gt;Unfortunelty, altough Microsoft announced they &lt;a href="http://www.bing.com/community/blogs/webmaster/archive/2009/02/12/partnering-to-help-solve-duplicate-content-issues.aspx"&gt;will support this feature&lt;/a&gt; in Live, this was not yet implemented in Bing as of now (Jun 2009). &lt;br /&gt;&lt;br /&gt;Nutch, on the other hand, had this on thier &lt;a href="https://issues.apache.org/jira/browse/NUTCH-710"&gt;TODO list for 1.1&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Also, Google Search Appliance (GSA), is currently assumed by all to not support this (although nobody really knows if it does).&lt;br /&gt;&lt;br /&gt;More about canonical URLs:&lt;br /&gt;&lt;a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html"&gt;http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://searchengineland.com/canonical-tag-16537"&gt;http://searchengineland.com/canonical-tag-16537&lt;/a&gt;&lt;br /&gt;&lt;a href="http://janeandrobot.com/library/url-referrer-tracking"&gt;http://janeandrobot.com/library/url-referrer-tracking&lt;/a&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-18T11:10:38.909+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>many group by strategies to select single rows per group</title><link>http://nirlevy.blogspot.com/2009/06/many-group-by-strategies-to-select.html</link><author>noreply@blogger.com (Nir Levy)</author><pubDate>Sun, 14 Jun 2009 23:53:18 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-4610063108784925355</guid><description>Xaprb gives a good explanation for selecting a single row from a group: &lt;a href="http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/"&gt;How to select the first/least/max row per group in SQL at Xaprb&lt;/a&gt;.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-15T09:53:18.652+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>apc futex_wait lockdown make your apache freeze over</title><link>http://nirlevy.blogspot.com/2009/06/apc-futexwait-lockdown-make-your-apache.html</link><category>drupal</category><category>php</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Tue, 04 Aug 2009 00:46:51 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-3235587434123675028</guid><description>We had the typical LAMP setup going on, with &lt;a href="http://drupal.org"&gt;Drupal&lt;/a&gt; as the base CMS and &lt;a href="http://us.php.net/apc"&gt;APC&lt;/a&gt; for bytecode cache. We needed a good caching engine so I figured why not use APC's user cache. Well, we tried the &lt;a href="http://drupal.org/project/apc"&gt;APC Cache Drupal Module&lt;/a&gt; which, with minor fixes proved to work very nicely. That is, until we actually put this all thing on production.&lt;br /&gt;&lt;br /&gt;The first thing we had was having our apache hang and not respond to any user requests. We susspected network issues, especially since &lt;code&gt;netstat -na&lt;/code&gt; showed that all the apache processes were hanging on &lt;code&gt;SYN_WAIT&lt;/code&gt;. However, since apache restart solved the issue i started to suspect this was something else.&lt;br /&gt;&lt;br /&gt;To make a long (very long) story short, I got strace on our prod machines to find out that apache was either hanging on &lt;code&gt;futex_lock(....FUTEXT_WAIT...)&lt;/code&gt; or doing infinte loops on the same functions.&lt;br /&gt;&lt;br /&gt;To make even a longer story short, I got gdb installed on those machines and the backtrace clearly indicated that the locks were from APC user-cache calls.&lt;br /&gt;&lt;br /&gt;We decided to abandon APC user-cache and switch to &lt;a href="http://www.danga.com/memcached/"&gt;memcached&lt;/a&gt; which proved faster and had less lockdowns. &lt;br /&gt;&lt;br /&gt;The funny thing is that when we talked about this over dinner the same evening a developer from another team just pointed me to this article by one of the APC leaders: (or something) &lt;a href="http://t3.dotgnu.info/blog/php/user-cache-timebomb.html"&gt;How to Dismantle an APC Bomb&lt;/a&gt; which has been around for over a year. I am supprised and shocked that such a information is hidded so well and not mentioned anywere in the docs. Moreover, I went through the APC code again after reading this post (I went through it once when i started analysing the problem) and it seems that this is not even  close to being resolved. there are no patches and no TODOs and nothing of the sort. From reading the code the entire user-cache needs a major re-write. What gives?&lt;br /&gt;&lt;br /&gt;(this is a post i wrote a couple of months ago, never had time to finish it. &lt;strike&gt;Unfortunately this is still not fixed afaik&lt;/strike&gt;)&lt;br /&gt;EDIT (07/2009): &lt;a href="http://pecl.php.net/bugs/bug.php?id=15179"&gt;http://pecl.php.net/bugs/bug.php?id=15179&lt;/a&gt; reports this to be fixed. If anyone can confirm this please send me a note so that I could update this post</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-04T10:46:51.198+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><title>GA_googleAddAttr is not defined error</title><link>http://nirlevy.blogspot.com/2009/05/gagoogleaddattr-is-not-defined-error.html</link><category>Javascript</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 14 May 2009 02:10:20 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-5707244498878056226</guid><description>If you are using Google Ad Manager you can &lt;a href="http://www.google.com/support/admanager/publisher/bin/answer.py?hl=en&amp;answer=138487"&gt;define custom attributes for targeting&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;If you are getting a javascript error &lt;code&gt;GA_googleAddAttr is not defined&lt;/code&gt; just make sure to put the call(s) to GA_googleAddAttr in a seperate &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; line, after the &lt;code&gt;GS_googleEnableAllServices&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html"&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;GS_googleAddAdSenseService("ca-pub-0000000000"); &lt;br /&gt;GS_googleEnableAllServices();&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;GA_googleAddAttr("ATTRB1", "whatever");&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;GA_googleAddSlot("ca-pub-0000000000", "slotname_216x311");&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-14T12:10:20.459+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>V6 DECODE64 not working properly</title><link>http://nirlevy.blogspot.com/2009/03/v6-decode64-not-working-properly.html</link><category>Tcl</category><category>Vignette</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Mon, 23 Mar 2009 00:21:19 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-3720040680060952066</guid><description>It turns out that after all these years, V6's built-in &lt;code&gt;DECODE64&lt;/code&gt; and &lt;code&gt;ENCODE64&lt;/code&gt; actually do not work properly with some binary data. &lt;br /&gt;&lt;pre name="code" class="php"&gt;&lt;br /&gt;proc COMPARE_BASE64 {} {&lt;br /&gt; set code  {2lIU1ZNw5BYvKi79j4L/+GGmjAQK7uiBQG7elDdKZcE=}&lt;br /&gt; set vgn_result [DECODE64 $code];         #VGN built-in function&lt;br /&gt; set tcl_result [::base64::decode $code]; #TclLib tcl-only implementation &lt;br /&gt; return [join [list \\&lt;br /&gt;   [BIN2HEX $vgn_result] \\&lt;br /&gt;   [BIN2HEX $tcl_result] \\&lt;br /&gt;   [string compare $vgn_result $tcl_result ] \\&lt;br /&gt;  ] "\\r\\n"]&lt;br /&gt;}&lt;br /&gt;proc BIN2HEX { text }  { binary scan $text H* result; return $result }&lt;br /&gt;COMPARE_BASE64&lt;br /&gt;&lt;br /&gt;--- result ----&lt;br /&gt;da52145370e4162f2a2efd8f82fff861a68c040aeee881406e94374a65c1&lt;br /&gt;da5214d59370e4162f2a2efd8f82fff861a68c040aeee881406ede94374a65c1&lt;br /&gt;1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you need to encode/decode base64 for use in non-vignette systems make sure you use &lt;a href="http://tcllib.sourceforge.net/"&gt;tcllib&lt;/a&gt;'s base64.&lt;br /&gt;&lt;br /&gt;This was tested on Vignette's V6 but I am sure it's true for Storyserver 4.2 and V5 as well.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-23T09:21:19.599+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total></item><item><title>MySQL indexes behaving badly</title><link>http://nirlevy.blogspot.com/2009/03/mysql-indexes-behaving-badly.html</link><category>mysql</category><category>optimization</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 19 Mar 2009 14:15:08 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-3582981348471339442</guid><description>If you have a MySQL query that for no apparent reason stops working or no longer behaves as it used to, the first thing to do is &lt;code&gt;EXPLAIN&lt;/code&gt; it. If the explain is unreasonable (for example, using different indexes then it used to or using an index but still scanning millions or rows) then you should try to &lt;code&gt;CHECK TABLE&lt;/code&gt;. &lt;br /&gt;&lt;br /&gt;One thing that I accidently found out was that &lt;code&gt;CHECK TABLE&lt;/code&gt; also &lt;a href="http://dev.mysql.com/doc/refman/5.1/en/check-table.html"&gt;updates the key statistics&lt;/a&gt;. This made many problems magically disappear. &lt;br /&gt;&lt;br /&gt;A few things that should be noted:&lt;ol&gt;&lt;li&gt;&lt;code&gt;CHECK TABLE&lt;/code&gt; will only update key statistics for &lt;i&gt;MyISAM&lt;/i&gt; tables&lt;/li&gt;, for &lt;i&gt;InnoDB&lt;/i&gt; you must use &lt;code&gt;OPTIMIZE TABLE&lt;/code&gt;.&lt;br /&gt;&lt;li&gt;If you use &lt;code&gt;OPTIMIZE TABLE&lt;/code&gt; to update the key statistics you should be aware that &lt;code&gt;OPTIMIZE TABLE&lt;/code&gt; does other (good) things as well, so it usually takes much longer and &lt;b&gt;it locks your table while doing it&lt;/b&gt;. Also, for &lt;i&gt;InnoDB&lt;/i&gt; it actually &lt;a href="http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html"&gt;re-builds the table using &lt;code&gt;ALTER TABLE&lt;/code&gt;&lt;/a&gt;.&lt;br /&gt;&lt;li&gt;The &lt;code&gt;CHECK TABLE&lt;/code&gt; have several options. Only the &lt;code&gt;MEDIUM&lt;/code&gt; (the default) or &lt;code&gt;EXTENDED&lt;/code&gt; update the key statistics. (i think).&lt;/li&gt;&lt;/ol&gt;So, if your indexes stop working, or just mis-behave, try to check them.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-19T23:15:08.570+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Vista fast user switching disappeared</title><link>http://nirlevy.blogspot.com/2009/02/vista-fast-user-switching-disappeared.html</link><category>Windows</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Fri, 20 Feb 2009 11:46:51 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-2603035799555194907</guid><description>My fast user switching option in Vista Home machine suddenly disappeared. I remember it was there, then it was not. I don't know why this happened, but &lt;a href="http://blogs.microsoft.co.il/blogs/amitcb/archive/2008/02/20/switch-user-disappear.aspx"&gt;here is how to fix it&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;A rough translation:&lt;blockquote&gt;&lt;br /&gt;Run &lt;code&gt;regexit.exe&lt;/code&gt;&lt;br /&gt;Go to &lt;code&gt;HKEY_LOCAL_MACHINE &amp;gt; SOFTWARE &amp;gt; Microsoft &amp;gt; Windows &amp;gt; CurrentVersion &amp;gt; Policies &amp;gt; System&lt;/code&gt;&lt;br /&gt;Look for a key named &lt;code&gt;HideFastUserSwitching&lt;/code&gt;. If it exists, change it's value to &lt;code&gt;0&lt;/code&gt; (zero). If it does not exist create it as a &lt;code&gt;DWORD&lt;/code&gt; and set it to zero.&lt;br /&gt;You might need to log off before the change takes effect.&lt;br /&gt;&lt;/blockquote&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-20T21:46:51.742+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>utf8 and hebrew in tomcat</title><link>http://nirlevy.blogspot.com/2009/02/utf8-and-hebrew-in-tomcat.html</link><category>java</category><category>hebrew</category><category>tomcat</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Sun, 08 Feb 2009 07:24:47 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-1367811628153189055</guid><description>In tomcat 5.0 and above, if your UTF-8 request parameters are received as gibberish you might need to do the following:&lt;br /&gt;&lt;br /&gt;In your &lt;code&gt;server.xml&lt;/code&gt; add the &lt;code&gt;URIEncoding="UTF-8"&lt;/code&gt; and &lt;code&gt;useBodyEncodingForURI="true"&lt;/code&gt; to the &lt;code&gt;Connector&lt;/code&gt; tag(s):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    &amp;lt;Connector &lt;br /&gt;     &lt;font color='red'&gt;useBodyEncodingForURI="true" &lt;br /&gt;     URIEncoding="UTF-8" &lt;/font&gt;&lt;br /&gt;     acceptCount="100" &lt;br /&gt;     enableLookups="false" &lt;br /&gt;     maxSpareThreads="75" &lt;br /&gt;     maxThreads="150" &lt;br /&gt;     minSpareThreads="25" &lt;br /&gt;     port="8080" &lt;br /&gt;     redirectPort="8443" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This should make &lt;code&gt;GET&lt;/code&gt; requests work properly.&lt;br /&gt;&lt;br /&gt;For some reason the above does not work for &lt;code&gt;POST&lt;/code&gt; requests. If you ask the tomcat people they'll mumble something about W3C, RFC, and RTFM. The short way to have this work for &lt;code&gt;POST&lt;/code&gt; requests is to write a small filter to set the request encoding properly. We are using something similar to this:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;package com.realcommerce.filters;&lt;br /&gt;import javax.servlet.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;public class RequestEncodingFilter implements Filter  {&lt;br /&gt;    public void init(FilterConfig filterConfig) throws ServletException {&lt;br /&gt;         //Do Nothing&lt;br /&gt;    }&lt;br /&gt;    public void destroy() {&lt;br /&gt;        //Do Nothing&lt;br /&gt;    }&lt;br /&gt;    public void doFilter(ServletRequest request,ServletResponse response,&lt;br /&gt;        FilterChain chain) throws IOException, ServletException &lt;br /&gt;    {&lt;br /&gt;        request.setCharacterEncoding("UTF-8");&lt;br /&gt;        chain.doFilter(request, response);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This made &lt;code&gt;POST&lt;/code&gt; requests pass Hebrew (or any UTF-8) parameters properly.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-08T17:24:47.905+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">12</thr:total></item><item><title>slow lstat, slow php, slow drupal</title><link>http://nirlevy.blogspot.com/2009/01/slow-lstat-slow-php-slow-drupal.html</link><category>drupal</category><category>php</category><category>optimization</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Mon, 02 Feb 2009 04:27:17 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-1404551728186112409</guid><description>If you are short on time go to &lt;a href="#bottom_line"&gt;bottom line&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Ok, the &lt;code&gt;&lt;a href="http://www.opengroup.org/onlinepubs/009695399/functions/lstat.html"&gt;lstat()&lt;/a&gt;&lt;/code&gt; and &lt;code&gt;stat()&lt;/code&gt; system calls system call are not really slow per se. But take a look at an apache &lt;code&gt;strace -r&lt;/code&gt; dump from a drupal installation I was testing:&lt;br /&gt;&lt;pre name="code" class="php:nogutter"&gt;&lt;br /&gt;[user@host ~]# strace -o strace.load -r -s 256 -p &amp;lt;PID&amp;gt;&lt;br /&gt;...&lt;br /&gt;0.000081 getcwd("/mnt/var/www/html/drupal", 4096) = 32&lt;br /&gt;0.000048 lstat("/mnt", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.000805 lstat("/mnt/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.001596 lstat("/mnt/var/www", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.000104 lstat("/mnt/var/www/html", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0&lt;br /&gt;0.000362 lstat("/mnt/var/www/html/drupal", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0&lt;br /&gt;0.000804 lstat("/mnt/var/www/html/drupal/sites", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.057575 lstat("/mnt/var/www/html/drupal/sites/all", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.000297 lstat("/mnt/var/www/html/drupal/sites/all/modules", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0&lt;br /&gt;0.014762 lstat("/mnt/var/www/html/drupal/sites/all/modules/Internet", {st_mode=S_IFDIR|0755, st_size=4096,&lt;br /&gt;0.000214 lstat("/mnt/var/www/html/drupal/sites/all/modules/Internet/date", {st_mode=S_IFDIR|0755, st_size=4&lt;br /&gt;0.000112 lstat("/mnt/var/www/html/drupal/sites/all/modules/Internet/date/date.module", {st_mode=S_IFREG|064&lt;br /&gt;0.010816 open("/mnt/var/www/html/drupal/sites/all/modules/Internet/date/date.module", O_RDONLY) = 20&lt;br /&gt;0.000835 fstat(20, {st_mode=S_IFREG|0644, st_size=44118, ...}) = 0&lt;br /&gt;0.000069 lseek(20, 0, SEEK_CUR)    = 0&lt;br /&gt;0.000063 stat("././sites/all/modules/Internet/date/date.module", {st_mode=S_IFREG|0644, st_size=44118, ...}) = 0&lt;br /&gt;0.000159 close(20)                 = 0&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, for every file included in the system there are around 10-15 &lt;code&gt;lstat&lt;/code&gt; calls. this means that if we have ~200 files included we have ~2500 &lt;code&gt;lstat&lt;/code&gt; calls per page. A simple sum on the strace results gave me ~8 seconds per page of &lt;code&gt;lstat&lt;/code&gt; time, which was over a third of my test page time. see?&lt;br /&gt;&lt;pre name="code" class="php:nogutter"&gt;&lt;br /&gt;[user@host ~]# cat strace.single | awk '{printf " " $1 "\n " $2}' |sed 1d | sed \$d |awk '{printf $2 "+"}'  | sed s/.$/\\n/ | bc&lt;br /&gt;21.204960&lt;br /&gt;[user@host ~]# cat strace.single | awk '{printf " " $1 "\n " $2}' |sed 1d | sed \$d | fgrep lstat | awk '{printf $2 "+"}'  | sed s/.$/\\n/ | bc&lt;br /&gt;8.361994&lt;br /&gt;&lt;/pre&gt;&lt;small&gt;if you really want to understand this shell script let me know. It deserves a post by itself&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;Now we have 3 options: a) make &lt;code&gt;lstat()&lt;/code&gt; faster. b) make php stop doing all those &lt;code&gt;lstats()&lt;/code&gt;. c) make drupal include less files. &lt;br /&gt;&lt;br /&gt;Well, (a) is not an option as our infrastructure team (aka sysadmins) insist there is nothing wrong with the filesystem and nothing can be done to enhance it's performance. Since I gave up being a sysadmin when it was still call 'sysadmin' it would be hard for me to prove them wrong (especially since they might be are right).&lt;br /&gt;&lt;br /&gt;As (c) would require us to refactor most of our code in a very very 'not drupal way' and create very large php files, I was hoping to find a better solution.&lt;br /&gt;&lt;br /&gt;By a &lt;a href="http://prematureoptimization.org/blog/archives/33"&gt;rare chance of good fortune i came to learn about &lt;code&gt;realpath_cache_size&lt;/code&gt;&lt;/a&gt;. Once I changed the foolish default to a reasonable 1M in &lt;code&gt;php.ini&lt;/code&gt;, I lost most of the &lt;code&gt;lstat()&lt;/code&gt; calls and over 10 seconds of processing time.&lt;br /&gt;&lt;pre name="code" class="php:nogutter"&gt;&lt;br /&gt;[user@host ~]# cat strace.2.single | awk '{printf " " $1 "\n " $2}' |sed 1d | sed \$d |awk '{printf $2 "+"}'  | sed s/.$/\\n/ | bc&lt;br /&gt;9.752309&lt;br /&gt;[user@host ~]# cat strace.2.single | awk '{printf " " $1 "\n " $2}' |sed 1d | sed \$d | fgrep lstat | awk '{printf $2 "+"}'  | sed s/.$/\\n/ | bc&lt;br /&gt;.040935&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="bottom_line"&gt;&lt;/a&gt;Here is what to do in php.ini&lt;br /&gt;&lt;pre name="code" class="vb:nogutter"&gt;&lt;br /&gt;; ...php.ini...&lt;br /&gt;; Determines the size of the realpath cache to be used by PHP. This value should&lt;br /&gt;; be increased on systems where PHP opens many files to reflect the quantity of&lt;br /&gt;; the file operations performed.&lt;br /&gt; realpath_cache_size=1M&lt;br /&gt;&lt;br /&gt;; Duration of time, in seconds for which to cache realpath information for a given&lt;br /&gt;; file or directory. For systems with rarely changing files, consider increasing this&lt;br /&gt;; value.&lt;br /&gt;realpath_cache_ttl=300&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;&lt;br /&gt;For normal pages under normal load I was able to get a 10%-25% performance improvment. I think that's quite a bit for a configuration change.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-02T14:27:17.748+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total></item><item><title>IE6 freeze with MOSS 2007</title><link>http://nirlevy.blogspot.com/2009/01/ie6-freeze-with-moss-2007.html</link><category>Internet Explorer</category><category>MOSS 2007</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Wed, 31 Dec 2008 23:12:19 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-6781365062218032769</guid><description>emposha wrote about how to handle a situtation where &lt;a href="http://www.emposha.com/aspnet/sharepoint-moss-strange-ie6-freeze-on-preview-mode.html/" title="Who`s Emposha  - Blog Archive   - SharePoint Moss strange IE6 freeze on preview mode"&gt;IE6 chokes on MOSS preview pages&lt;/a&gt;.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-01T09:12:19.742+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Hebrew SEO: גוגל, עברית, וה"א הידיעה</title><link>http://nirlevy.blogspot.com/2008/12/blog-post.html</link><category>SEO</category><category>hebrew</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 11 Dec 2008 13:50:31 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-8833704791733176497</guid><description>&lt;div dir='rtl' style='text-align:right;font-family:arial'&gt;&lt;br /&gt;נראה ש-google לא מתייחס נכון ל&lt;a href="http://he.wikipedia.org/wiki/ה'_הידיעה"&gt;ה"א הידיעה&lt;/a&gt;. &lt;br /&gt;אם נחפש לדוגמא &lt;a href="http://www.google.co.il/search?hl=en&amp;rlz=1C1CHMG_enIL291IL303&amp;q=הממשלה&amp;btnG=Search"&gt;הממשלה &lt;/a&gt;נקבל בתוצאות את "פורטל השרותים של ממשלת ישראל" אבל גוגל מסמן בבולד רק את המילה &lt;span style="font-style:italic;"&gt;הממשלה &lt;/span&gt;ולא את המילים &lt;span style="font-style:italic;"&gt;ממשלה &lt;/span&gt;או &lt;span style="font-style:italic;"&gt;ממשלת &lt;/span&gt;שהן הטיות חוקיות לחלוטין. &lt;br /&gt;בכיוון ההפוך, אם נחפש &lt;a href="http://www.google.co.il/search?hl=en&amp;rlz=1C1CHMG_enIL291IL303&amp;q=ממשלה&amp;btnG=Search"&gt;ממשלה &lt;/a&gt;נקבל תוצאות אחרות לגמרי, כאשר המילים &lt;span style="font-style:italic;"&gt;ממשלת &lt;/span&gt;ו&lt;span style="font-style:italic;"&gt;ממשלה&lt;/span&gt; מודגשות אבל המילה &lt;span style="font-style:italic;"&gt;הממשלה &lt;/span&gt;אינה מוגדשת. &lt;br /&gt;לפי ההבדלים בתוצאות החיפוש נראה שהבעיה קיימת לא רק בהדגשה אלא גם באינדוקס.&lt;br /&gt;בדקתי גם בחיפוש לפי &lt;a href="http://www.google.co.il/search?hl=en&amp;rlz=1C1CHMG_enIL291IL303&amp;q=הילדים&amp;btnG=Search"&gt;הילדים &lt;/a&gt;מול &lt;a href="http://www.google.co.il/search?hl=en&amp;rlz=1C1CHMG_enIL291IL303&amp;q=ילדים&amp;btnG=Search"&gt;ילדים &lt;/a&gt;ומילים נוספות. הדבר נראה נכון גם לגבי live של מיקרוסופט (בלי לדבר על yahooשבכלל לא טרחו לתמוך במורפולוגיה עברית)&lt;br /&gt;המסקנה,לצרכי אופטימיזציה במנועי החיפוש של גוגל כדאי להגדיר את מילות המפתח של האתר עם ובלי ה"א הידיעה.&lt;br /&gt;&lt;br /&gt;&lt;a style='float:right' onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tdZrSSGIPEc/SUETPIR-9XI/AAAAAAAABRU/vA3R9YbTDgk/s1600-h/google_he_2.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 280px; ;" src="http://2.bp.blogspot.com/_tdZrSSGIPEc/SUETPIR-9XI/AAAAAAAABRU/vA3R9YbTDgk/s320/google_he_2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5278521388896810354" /&gt;&lt;/a&gt;&lt;a  style='float:left'  onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tdZrSSGIPEc/SUETPDwt5uI/AAAAAAAABRM/0eDhZ6DLgcM/s1600-h/google_he_1.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 280px; ;" src="http://1.bp.blogspot.com/_tdZrSSGIPEc/SUETPDwt5uI/AAAAAAAABRM/0eDhZ6DLgcM/s320/google_he_1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5278521387683538658" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-11T23:50:31.170+02:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_tdZrSSGIPEc/SUETPIR-9XI/AAAAAAAABRU/vA3R9YbTDgk/s72-c/google_he_2.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>drupal memcache items disappearing from the cache</title><link>http://nirlevy.blogspot.com/2008/11/drupal-memcache-items-disappearing-from.html</link><category>memcached</category><category>drupal</category><category>php</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 20 Nov 2008 14:21:14 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-5346176807043874644</guid><description>The scenario: you are using &lt;a href="http://www.danga.com/memcached/" target= _blank &gt;memcached&lt;/a&gt; as your &lt;a href="http://drupal.org" target=_blank&gt;Drupal&lt;/a&gt; cache system. You do a &lt;code&gt;cache_set&lt;/code&gt; for some item. You do a &lt;code&gt;cache_get&lt;/code&gt; for this item. The item is there. You do a &lt;code&gt;cache_get&lt;/code&gt; again after a few seconds/minutes, the item is not there.&lt;br /&gt;&lt;br /&gt;You might be experiencing &lt;a href="http://drupal.org/node/224772"&gt;this issue of the memcache module&lt;/a&gt;: In short it means that the memcache module flushes the entire cache cluster whenever someone does a wildcard &lt;code&gt;cache_clear_all&lt;/code&gt;. Since it's very likely that all your bins are in a single cluster you get to a situation that whenever someone-on-the-other-side-of-the-world does something that is probably completely unrelated to you, your item will still get flushed from the cache.&lt;br /&gt;&lt;br /&gt;Note that since &lt;code&gt;flush&lt;/code&gt; does not activly removes the items from the cache but rather marks them as expired you will not see any memcached stats that will hint to this issue.&lt;br /&gt;&lt;br /&gt;I &lt;a href="http://drupal.org/node/224772#comment-1118607"&gt;have commented on the issue.&lt;/a&gt; Here are some highlights:&lt;br /&gt;&lt;blockquote&gt;...we are currently using &lt;a href="http://drupal.org/node/224772#comment-799489"&gt;gaolei's patch&lt;/a&gt; which is fast albeit expensive. We are using it on a large production system that depends heavily on memcache and we did not see any problems yet. (thank you gaolei).&lt;br /&gt;&lt;br /&gt;We have tried to implement a lock-add-unlock scenario such as was suggested in several comments but this will be a definite nightmare for high-traffic/high-update sites...&lt;br /&gt;&lt;br /&gt;I would suggest letting the user choose which flush mechanism to use: the current one, or the salt one. I see no reason why the module's developers should decide for me. On a site with little updates and little memory i would prefer to have the whole memcache flush; On a site with many updates and tons of memory i'm willing to sacrifice space for the sake good performance. a simple memcache_flush_method variable would do the job just fine.&lt;/blockquote&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-21T00:21:14.979+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MYSQL Query Optimization: Avoiding ORs</title><link>http://nirlevy.blogspot.com/2008/11/mysql-query-optimization-avoiding-ors.html</link><category>mysql</category><category>optimization</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Mon, 10 Nov 2008 11:57:20 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-8600802743372495256</guid><description>So, you've probably heard that using &lt;code&gt;OR&lt;/code&gt;s in your queries is heavy and should be avoided when possible. Here is a live example. We had the following query running on a medium sized table in MYSQL (around 200K rows):&lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;SELECT count(*)  FROM interactions p&lt;br /&gt;   WHERE (&lt;br /&gt;       (p.employer = 69 AND p.flag1 = 1)&lt;br /&gt;       OR&lt;br /&gt;       (p.employee = 69 AND p.flag2 = 0)&lt;br /&gt;       )&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Let's think of &lt;code&gt;interactions&lt;/code&gt; as a table holding the interaction between employers and employees, and this query should tell the user the total number of interactions where user number 69 is involved.&lt;br /&gt;&lt;br /&gt;The query looked pretty innoccent on an idle MYSQL server taking around 200ms, but when the server got busy the query execution time was reaching 5-6 seconds.&lt;br /&gt;&lt;br /&gt;Altough we did have indexes on &lt;code&gt;interactions.employer&lt;/code&gt; and &lt;code&gt;interactions. employee&lt;/code&gt; doing &lt;code&gt;EXPLAIN&lt;/code&gt; showed that MYSQL was not using them.&lt;br /&gt;&lt;br /&gt;After some digging and fiddling and trying we ended up with:&lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;SELECT count(*) as count FROM (&lt;br /&gt;   SELECT 1  FROM interactions p&lt;br /&gt;       WHERE (p.employer = 69 AND p.flag1 = 1)&lt;br /&gt;   UNION ALL&lt;br /&gt;   SELECT 1  FROM privatemsg p&lt;br /&gt;       WHERE (p.employee = 69 AND p.flag2 = 0)&lt;br /&gt;) t2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This query took on the busy server less then 250 milliseconds and less then 80ms on the idle server. Doing &lt;code&gt;EXPLAIN&lt;/code&gt; showed that MYSQL was doing two queries, and using the correct index on each one.&lt;br /&gt;&lt;br /&gt;After some more digging we noticed that if we &lt;code&gt;EXPLAIN&lt;/code&gt; the &lt;b&gt;original&lt;/b&gt; query on the idle server the optimizer occasionally converts it to a &lt;code&gt;UNION&lt;/code&gt;, but for some reason this did not always happen and in any case took about twice the time then the UNION query.&lt;br /&gt;&lt;br /&gt;To sum up the results here is a simple table&lt;br /&gt;&lt;br /&gt;&lt;table width="60%" style="margin-top:0px"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Query type&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Server activity&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Query Time&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Using OR&lt;/td&gt;&lt;td&gt;Idle&lt;/td&gt;&lt;td&gt;200ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Using OR&lt;/td&gt;&lt;td&gt;Busy&lt;/td&gt;&lt;td&gt;5500ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Using UNION&lt;/td&gt;&lt;td&gt;Idle&lt;/td&gt;&lt;td&gt;78ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Using UNION&lt;/td&gt;&lt;td&gt;Busy&lt;/td&gt;&lt;td&gt;189ms&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Conclusion: always consider alternatives to &lt;code&gt;OR&lt;/code&gt;, but make sure you check them well against real-time examples.&lt;br /&gt;&lt;br /&gt;A Further Note: When timing queries in MYSQL alway use the optimizer hint &lt;code&gt;/*! SQL_NO_CACHE */ &lt;/code&gt; to make sure you are not getting results from the query cache (if you have one set up).</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-10T21:57:20.561+02:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Internet Explorer does not support http vary header</title><link>http://nirlevy.blogspot.com/2008/09/internet-explorer-does-not-support-http.html</link><category>Internet Explorer</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Wed, 10 Sep 2008 11:48:54 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-1416406925707760941</guid><description>It was always assumed, but I just saw this quote from &lt;a href="http://support.microsoft.com/kb/824847"&gt;Microsoft&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Internet Explorer does not fully implement the VARY header per Requests for Comments (RFC) 2616. The Internet Explorer implementation of VARY is that it does not cache any data except for Vary-Useragent&lt;br /&gt;&lt;/blockquote&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-10T21:48:54.112+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Internet explorer cannot open the internet site: operation aborted</title><link>http://nirlevy.blogspot.com/2008/09/internet-explorer-cannot-open-internet.html</link><category>Javascript</category><category>Internet Explorer</category><category>Firefox</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Wed, 10 Sep 2008 12:24:40 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-5765233658817521703</guid><description>During an integration with a third party provider we were unfortunate enough to get the error &lt;blockquote&gt;Internet explorer cannot open the internet site http://localhost: &lt;strong&gt;operation aborted&lt;/strong&gt;&lt;/blockquote&gt; Yes, we have read &lt;a href="http://support.microsoft.com/kb/927917"&gt;http://support.microsoft.com/kb/927917&lt;/a&gt; and did move the 3rd-party's script to be just before the &lt;code&gt;&amp;lt;/BODY&amp;gt;&lt;/code&gt; tag but to no avail.&lt;br /&gt;&lt;br /&gt;After a long and hard effort by this provider they pointed out that while the view-source indeed looked like the script is just before &lt;code&gt;&amp;lt;/BODY&amp;gt;&lt;/code&gt; when looking at the DOM itself (they used &lt;a href="http://www.ieinspector.com/"&gt;Dominspector&lt;/a&gt;, I used the IE Developer Toolbar) it showed that the script was inside a &lt;code&gt;&amp;lt;DIV&amp;gt;&lt;/code&gt; element.&lt;br /&gt;&lt;br /&gt;As it turns out there was some code on the page that wrote an unclosed &lt;code&gt;&amp;lt;DIV&amp;gt;&lt;/code&gt;. This made IE "fill in the blanks" and guess (wrongly) where it should place the closing &lt;code&gt;&amp;lt;/DIV&amp;gt;&lt;/code&gt; Fixing this javascript made the error go away on most pages. But not all.&lt;br /&gt;&lt;br /&gt;I found out that the broken pages used some JQuery plugins (tooltips, jqmodal, etc.) to produce fancy decorations and effects. These scripts attached to &lt;code&gt;$document.ready&lt;/code&gt; and did &lt;code&gt;$('body').appendTo(...)&lt;/code&gt;. This effectively added a couple of items to the DOM between the 3rd-party script and the &lt;code&gt;&amp;lt;/BODY&amp;gt;&lt;/code&gt;. I am still not quite sure why this should cause IE to choke but since we have a tight schedule we simply changed those scripts to add their stuff to some other elements. This indeed solved out problem.&lt;br /&gt;&lt;br /&gt;They funny (or maybe sad) thing was that on Firefox we did not get any error but the page simply disappeared. Chrome worked just fine.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-10T22:24:40.822+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Misplaced elements with position:relative</title><link>http://nirlevy.blogspot.com/2008/08/misplaced-elements-with.html</link><category>Internet Explorer</category><category>css</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Tue, 26 Aug 2008 23:34:37 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-7498601080437920458</guid><description>We had a situation where we had three &amp;lt;DIV&amp;gt; elements in a column and the middle element had content dynamically loaded into it after the page has completed loading. When the middle element finished loading, some of the content of the last element seemed to forget its parenthood and floated nicely over the second element.&lt;br /&gt;&lt;br /&gt;&lt;!--&lt;a href="http://4.bp.blogspot.com/_tdZrSSGIPEc/SLRBSa-YnLI/AAAAAAAAA5w/yoxwKnJKVCY/s1600-h/hasLayout.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_tdZrSSGIPEc/SLRBSa-YnLI/AAAAAAAAA5w/yoxwKnJKVCY/s400/hasLayout.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5238884051273161906" /&gt;&lt;/a&gt;--&gt;&lt;br /&gt;&lt;img src="http://javajavaproxy.googlepages.com/hasLayout2.gif" border="0" alt="elements with postion relative not placed properly after dynamic content loading"&gt;&lt;br /&gt;&lt;br /&gt;Naturally this only happened in Internet Explorer (what else).&lt;br /&gt;&lt;br /&gt;After a lot of digging we noticed that the misplaced content of &amp;lt;DIV&amp;gt;#3 had a &lt;code&gt;position:relative&lt;/code&gt; style (indicated as #4 in the image above). It is "well known" that IE does not handle relative positioning properly when the layout of the page change. &lt;br /&gt;&lt;br /&gt;Luckily I chanced upon an article by &lt;a href="http://positioniseverything.net/"&gt;Holly Bergevin&lt;/a&gt; et al. called &lt;i&gt;&lt;a href="http://www.satzansatz.de/cssd/onhavinglayout.html"&gt;On having layout&lt;/a&gt;&lt;/i&gt; which was enlightening. Understanding that IE will only respect the element's state if it have the &lt;code&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms533776.aspx"&gt;hasLayout&lt;/a&gt;&lt;/code&gt; property quickly solved the problem.&lt;br /&gt;&lt;br /&gt;In our specific case I used &lt;code&gt;display:inline-block&lt;/code&gt; to force &amp;lt;DIV&amp;gt;#3 to have &lt;code&gt;hasLayout&lt;/code&gt; set to true, which made IE respect the element's style and re-render the element's content (i.e. &amp;lt;DIV&amp;gt;#4) after re-positioning it. My only concern now is what effect this might have on rendering performance, but it will have to do for now.&lt;br /&gt;&lt;br /&gt;Tip: you can use &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;displaylang=en"&gt;IE Developer Toolbar&lt;/a&gt; to check if an element hasLayout. It will show the &lt;code&gt;hasLayout&lt;/code&gt; property as set to -1 if &lt;code&gt;hasLayout&lt;/code&gt; is true.&lt;br /&gt;&lt;br /&gt;Further credit is due to &lt;a href="http://www.satzansatz.de/"&gt;Ingo Chao&lt;/a&gt; who wrote &lt;a href="http://www.satzansatz.de/cssd/rpfloat.html"&gt;relatively positioned parent and floated child – disappearance&lt;/a&gt;.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-27T09:34:37.984+03:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_tdZrSSGIPEc/SLRBSa-YnLI/AAAAAAAAA5w/yoxwKnJKVCY/s72-c/hasLayout.gif" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Absolute vs. Relative URLs and SEO</title><link>http://nirlevy.blogspot.com/2008/07/absolute-vs-relative-urls-and-seo.html</link><category>SEO</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Tue, 26 Aug 2008 11:46:50 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-3184374528319999250</guid><description>I've seen several places where people suggest that one should use absolute URLs (http://domain.com/page) to do internal linking instead of relative URLs (/page). &lt;a href="http://forums.digitalpoint.com/showthread.php?t=225036"&gt;Those people&lt;/a&gt; relate to &lt;a href="http://sitemaps.blogspot.com/2006/05/few-questions-from-our-google-group.html"&gt;a google article&lt;/a&gt; where it is quoted that &lt;br /&gt;&lt;blockquote&gt;We also suggest you link to other pages of your site using absolute, rather than relative, links with the version of the domain you want to be indexed under. For instance, from your home page, rather than link to products.html, link to http://www.example.com/products.html . And whenever possible, make sure that other sites are linking to you using the version of the domain name that you prefer&lt;/blockquote&gt;&lt;br /&gt;This seems to me a classic example of &lt;b&gt;taking things out of context&lt;/b&gt;. If you read the entire article you can see that Ms. Fox is talking about a specific case where your site can be accessed by more then one domain name (e.g. http://www.domain.com and http://domain.com). &lt;br /&gt;&lt;br /&gt;There is nothing google ever wrote that i could find that say that absolute URLs are better if your site is only accessed by one domain name. &lt;br /&gt;&lt;br /&gt;There is one exception i can think of: if your domain is "coolstuff.com" for example and you do use absolute URLs, then the word "coolstuff" will appear in your pages alot. This &lt;b&gt;might&lt;/b&gt; be something that &lt;b&gt;may&lt;/b&gt; boost your ranking with regards the the word "coolstuff". But this is &lt;b&gt;just a guess&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;More reading: &lt;a href="http://groups.google.com/group/Google_Webmaster_Help-Indexing/browse_thread/thread/a1d2b6a6cf8d0a0d/341e71c1aebac416?"&gt;Google Canonicalization Problems? - Crawling, indexing, and ranking | Google Groups&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style='background-color:yellow'&gt;Please note: this is my personal opinion. I've had at least two SEO experts that claim that absolute URLs will give better performance on google ranking&lt;/strong&gt;. Since I'm strong-headed I will hold to my opinion until I'll be proven (with numbers) otherwise. Feel free to comment with supporting or conflicting opinions and data.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-26T21:46:50.655+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>Save binary file in Tcl under V6</title><link>http://nirlevy.blogspot.com/2008/07/how-to-save-binary-file-in-v6tcl.html</link><category>Tcl</category><category>Vignette</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Sun, 06 Jul 2008 02:36:43 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-7151815422071914503</guid><description>This issue pops up every couple of years. It's nothing new, but still worth documenting.&lt;br /&gt;&lt;br /&gt;The Challenge: To save a posted file to a file system, not using &lt;code&gt;SUBMIT_STATIC_FILE&lt;/code&gt;. &lt;br /&gt;&lt;br /&gt;The Problem: Vignette V6 pre-process the form submitted data so that any &lt;code&gt;&amp;lt;input type="file"&amp;gt;&lt;/code&gt; are encoded as an hex string. If you &lt;code&gt;ERROR_TRACE&lt;/code&gt; the variable for the file, you will see a string that looks like &lt;code&gt;0x1D00ABADD1D9...&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;The Solution: &lt;code&gt;binary format&lt;/code&gt; to the rescue. and with a bit of trimming, you get it all in a few lines:&lt;br /&gt;&lt;pre name="code" class="c:nogutter"&gt;&lt;br /&gt;proc save_files { } {&lt;br /&gt;#FileData,FileExtention,Field1 are posted from the &amp;lt;form&amp;gt;&lt;br /&gt;&lt;br /&gt;set filename [generate_filename]&lt;br /&gt;set bin_filename &amp;quot;${filename}.[SHOW FileExtention]&amp;quot;&lt;br /&gt;set xml_filename &amp;quot;${filename}.xml&amp;quot;&lt;br /&gt;&lt;br /&gt;### This will save a binary file.&lt;br /&gt;set file [open $bin_filename &amp;quot;w&amp;quot;]&lt;br /&gt;fconfigure $file -translation binary&lt;br /&gt;puts -nonewline $file [binary format H* [string range [SHOW FileData] 2 end-1]]&lt;br /&gt;close $file&lt;br /&gt;&lt;br /&gt;### This will save a utf-8 xml (text) file&lt;br /&gt;set file [open $xml_filename &amp;quot;w&amp;quot;]&lt;br /&gt;fconfigure $file -encoding &amp;quot;utf-8&amp;quot;&lt;br /&gt;puts $file &amp;quot;&amp;lt;?xml version='1.0' encoding='utf-8' ?&amp;gt;&amp;quot;&lt;br /&gt;puts $file &amp;quot;&amp;lt;formdata&amp;gt;&amp;quot;&lt;br /&gt;puts $file &amp;quot;&amp;lt;Field1&amp;gt;[HTML_ESCAPE [SHOW Field1]]&amp;lt;/Field1&amp;gt;&amp;quot;&lt;br /&gt;#...more fields...&lt;br /&gt;$puts $file &amp;quot;&amp;lt;Attachment&amp;gt;$bin_filename&amp;lt;/Attachment&amp;gt;&amp;quot;&lt;br /&gt;puts $file &amp;quot;&amp;lt;/formdata&amp;gt;&amp;quot;&lt;br /&gt;close $file&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;* Remember to use &lt;code&gt;H*&lt;/code&gt; and not &lt;code&gt;h*&lt;/code&gt;.&lt;br /&gt;* The example above also saves a text file in utf-8 with extra data from the form&lt;br /&gt;* Make sure your form is &lt;a href="http://www.w3.org/TR/html401/interact/forms.html#adef-enctype"&gt;&lt;code&gt;enctype=multipart/form-data&lt;/code&gt;&lt;/a&gt;&lt;br /&gt;* This will not work in Storyserver 4.2.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-06T12:36:43.527+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Make a Footer Stick to the Bottom of the Page</title><link>http://nirlevy.blogspot.com/2008/06/make-footer-stick-to-bottom-of-page.html</link><category>css</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Thu, 05 Jun 2008 12:32:29 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-3819548089062295349</guid><description>Ryan Fait wrote a great piece of code that &lt;a href="http://ryanfait.com/resources/footer-stick-to-bottom-of-page/"&gt;makes a footer stick to the bottom of the page&lt;/a&gt; with css only. no javascript, no hassle. genius, absolutly genius.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-05T22:32:29.320+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Apache Rewrites and SetEnv</title><link>http://nirlevy.blogspot.com/2008/06/apache-rewrites-and-setenv.html</link><category>apache</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Mon, 02 Jun 2008 10:21:49 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-6179780977919224618</guid><description>It seems that variables set with Apache's &lt;code&gt;SetEnv&lt;/code&gt; (and hence &lt;code&gt;SetEnvIf&lt;/code&gt; and &lt;code&gt;BrowserMatch&lt;/code&gt;) are being ignored by &lt;code&gt;RewriteRule&lt;/code&gt; and &lt;code&gt;RewriteCond&lt;/code&gt;. The &lt;a href="http://mail-archives.apache.org/mod_mbox/httpd-users/200406.mbox/&amp;lt;20040602080459.00004da4@fe-pc-092&amp;gt;" traget="_new"&gt;rumor&lt;/a&gt; has it to be a design issue. The only way i could find around this problem is to use the &lt;code&gt;[E=&lt;/code&gt; rewrite rule directive.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class='Xml'&gt;#Use RewriteRule &amp;amp; RewriteCond as a replacment for SetEnv and BrowserMatch&lt;br /&gt;#SetEnv browser="-ie"&lt;br /&gt;RewriteRule ^(.*)$ - [E=browser:-ie]&lt;br /&gt;#BrowserMatch "IE7" browser="-ie7"&lt;br /&gt;RewriteCond %{HTTP_USER_AGENT} "MSIE 7"&lt;br /&gt;RewriteRule ^(.*)$ - [E=browser:-ie7]&lt;br /&gt;#BrowserMatch "Firefox" browser="-moz"&lt;br /&gt;RewriteCond %{HTTP_USER_AGENT} "Firefox"&lt;br /&gt;RewriteRule ^(.*)$ - [E=browser:-moz]&lt;br /&gt;&lt;br /&gt;RewriteCond %{DOCUMENT_ROOT}/cache/index%{ENV:browser}.html -f&lt;br /&gt;RewriteRule ^(.*)$ cache/index%{ENV:browser}.html [L]&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;PS. If you need to debug rewrite rules you can add the following lines to your &lt;code&gt;httpd.conf&lt;/code&gt;:&lt;code&gt;&lt;br /&gt;RewriteLog logs/rewrite.log&lt;br /&gt;RewriteLogLevel 5&lt;/code&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-02T20:21:49.353+03:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Annoying FireBug Bug</title><link>http://nirlevy.blogspot.com/2008/05/annoying-firebug-bug.html</link><category>Javascript</category><category>Firefox</category><author>noreply@blogger.com (Nir Levy)</author><pubDate>Mon, 08 Dec 2008 23:53:40 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6254648781068875224.post-4241349826634844108</guid><description>&lt;a href="http://2.bp.blogspot.com/_tdZrSSGIPEc/SCsiv3lBSsI/AAAAAAAAAx0/L7Ki1_lVo7Q/s1600-h/Clipboard26.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_tdZrSSGIPEc/SCsiv3lBSsI/AAAAAAAAAx0/L7Ki1_lVo7Q/s320/Clipboard26.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5200288400497789634" /&gt;&lt;/a&gt;I came across an annoying bug in &lt;a href="http://www.getfirebug.com/" target="_new"&gt;firebug&lt;/a&gt;. If there is a global variable with the same name as a local variable then firebug does not correctly show the value of the local variable in the tooltips and the watch window.&lt;br /&gt;&lt;br /&gt;The most annoying thing is that it &lt;a href="http://code.google.com/p/fbug/issues/detail?id=353&amp;q=variable"&gt;has been reported&lt;/a&gt; several months ago, but still no fix.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UPDATE:&lt;/b&gt; Confirmed &lt;a href="http://code.google.com/p/fbug/issues/detail?id=353"&gt;Fixed&lt;/a&gt; in 1.2 on FF3.</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-09T09:53:40.829+02:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_tdZrSSGIPEc/SCsiv3lBSsI/AAAAAAAAAx0/L7Ki1_lVo7Q/s72-c/Clipboard26.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item></channel></rss>
