<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>debugging on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/debugging/</link>
    <description>Recent content in debugging on S Anand</description>
    <generator>Hugo -- 0.156.0</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 22 Jun 2025 09:52:29 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/debugging/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title></title>
      <link>https://www.s-anand.net/blog/codex-jules-vibe-coding/</link>
      <pubDate>Sun, 22 Jun 2025 09:52:29 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/codex-jules-vibe-coding/</guid>
      <description>&lt;p&gt;I use Codex and Jules to code while I walk. I&amp;rsquo;ve merged several PRs without careful review. This added technical debt.&lt;/p&gt;
&lt;p&gt;This weekend, I spent four hours fixing the AI generated tests and code.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;What mistakes did it make?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Inconsistency&lt;/strong&gt;. It flips between &lt;code&gt;execCommand(&amp;quot;copy&lt;/code&gt;&amp;quot;) and &lt;code&gt;clipboard.writeText&lt;/code&gt;(). It wavers on timeouts (50 ms vs 100 ms). It doesn&amp;rsquo;t always run/fix test cases.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Missed edge cases&lt;/strong&gt;. I switched &amp;lt;&lt;code&gt;div&lt;/code&gt;&amp;gt; to &amp;lt;&lt;code&gt;form&lt;/code&gt;&amp;gt;. My earlier code didn&amp;rsquo;t have a &lt;code&gt;type=&amp;quot;button&lt;/code&gt;&amp;quot;, so clicks reloaded the page. It missed that. It also left scripts as plain &amp;lt;&lt;code&gt;script&lt;/code&gt;&amp;gt; instead of &amp;lt;&lt;code&gt;script type=&amp;quot;module&lt;/code&gt;&amp;quot;&amp;gt; which was required.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Limited experimentation&lt;/strong&gt;. My failed with a HTTP 404 because the &lt;code&gt;common&lt;/code&gt;/ directory wasn&amp;rsquo;t served. I added &lt;code&gt;console.log&lt;/code&gt;s to find this. Also, &lt;code&gt;happy-dom&lt;/code&gt; won&amp;rsquo;t handle multiple &lt;code&gt;export&lt;/code&gt;s instead of a single &lt;code&gt;export&lt;/code&gt; { &amp;hellip; }. I wrote code to verify this. Coding agents didn&amp;rsquo;t run such experiments.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;What can we do about it?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Detailed coding rules&lt;/strong&gt;. E.g. &lt;em&gt;always&lt;/em&gt; run test cases and fix until they pass. Only use ESM. Always import from CDN via JSDelivr. That sort of thing.&lt;/p&gt;
&lt;p&gt;100% &lt;strong&gt;test coverage&lt;/strong&gt;. Ideally 100% of code and all usage scenarios.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Log everything&lt;/strong&gt;. My tests got a HTTP 404 because I was not serving the &lt;code&gt;common&lt;/code&gt;/ directory. LLMs couldn&amp;rsquo;t figure this out because it was not logged. Logging everything helps humans &lt;em&gt;and&lt;/em&gt; LLMs debug.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Wait&lt;/strong&gt;. LLMs and coding agents keep improving. A few months down the line, they&amp;rsquo;ll run more experiments themselves.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Was AI coding worth the effort&lt;/strong&gt;? Here, yes. The tools &lt;em&gt;worked&lt;/em&gt;. Codex saved me 90% effort. My code quality obsession reduced savings to ~70%. Still huge.&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://files.s-anand.net/images/2025-06-22-codex-jules-vibe-coding-linkedin.jpg&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.linkedin.com/feed/update/urn%3Ali%3Ashare%3A7342489647257632769&#34;&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Always use value= for dynamic HTML options</title>
      <link>https://www.s-anand.net/blog/always-use-value-for-dynamic-html-options/</link>
      <pubDate>Mon, 31 Jul 2023 06:45:48 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/always-use-value-for-dynamic-html-options/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;Always use value= for dynamic HTML options&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/html-code.webp&#34;&gt;&lt;/p&gt;
&lt;p&gt;Even after 30 years of HTML, I learn new things about it.&lt;/p&gt;
&lt;p&gt;This Monday morning, I woke up to a mail from &lt;a href=&#34;https://www.linkedin.com/in/sundeeprm/&#34;&gt;Sundeep&lt;/a&gt; saying requests for a &lt;code&gt;Data Engineer - AWS/Azure/GCP&lt;/code&gt; in our internal fulfilment portal raised an error.&lt;/p&gt;
&lt;p&gt;My guess was one of these:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &amp;ldquo;/&amp;rdquo; in the role is causing a problem. (Developer mistake.)&lt;/li&gt;
&lt;li&gt;The role exists in one table but not the other. (Recruitment team mistake.)&lt;/li&gt;
&lt;li&gt;The application wasn&amp;rsquo;t set up / restarted properly. (IT mistake.)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;All three were wrong&lt;/strong&gt;. So I dug deeper.&lt;/p&gt;
&lt;p&gt;The role was defined as &lt;code&gt;Data Engineer  - AWS/Azure/GCP&lt;/code&gt; (note the 2 spaces before the hyphen). But the form kept sending &lt;code&gt;Data Engineer - AWS/Azure/GCP&lt;/code&gt; (spaces were condensed).&lt;/p&gt;
&lt;p&gt;I swear there was &lt;strong&gt;NOTHING&lt;/strong&gt; in the code that changes the options. The relevant line just picked up the role and rendered it inside the &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;```markup
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;option&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;{{ row[&amp;#39;Role&amp;#39;] }}&lt;span class=&#34;p&#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;option&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I used the browser&amp;rsquo;s developer tools to inspect the &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; element. It showed the options with the 2 spaces:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-markup&#34; data-lang=&#34;markup&#34;&gt;&amp;lt;option&amp;gt;Data Engineer  - AWS/Azure/GCP&amp;lt;/option&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;But, when I selected it and printed the value, it had only one space.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;console&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;log&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;document&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;querySelector&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;#role&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;value&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;br&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Data Engineer - AWS/Azure/GCP&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s when it hit me. &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace&#34;&gt;HTML condenses whitespaces&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Till date, I only ever used &lt;code&gt;&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&lt;/code&gt; when specifying a value &lt;strong&gt;different&lt;/strong&gt; from what&amp;rsquo;s displayed. I never thought of using it to &lt;strong&gt;preserve&lt;/strong&gt; the value.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LESSON&lt;/strong&gt;: If you&amp;rsquo;re dynamically generating &lt;code&gt;&amp;lt;option&amp;gt;&lt;/code&gt;s, &lt;strong&gt;ALWAYS&lt;/strong&gt; use &lt;code&gt;value=&lt;/code&gt; with the same value as the text.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Error logging with Google Analytics</title>
      <link>https://www.s-anand.net/blog/error-logging-with-google-analytics/</link>
      <pubDate>Sat, 23 May 2009 19:29:01 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/error-logging-with-google-analytics/</guid>
      <description>&lt;p&gt;A quick note: I blogged earlier about &lt;a href=&#34;https://www.s-anand.net/blog/javascript-error-logging/&#34;&gt;Javascript error logging&lt;/a&gt;, saying that you can wrap every function in your code (automatically) in a &lt;code&gt;try{} catch{}&lt;/code&gt; block, and log the error message in the &lt;code&gt;catch{}&lt;/code&gt; block.&lt;/p&gt;
&lt;p&gt;I used to write the error message to a Perl script. But now I use &lt;a href=&#34;http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html&#34;&gt;Google’s event tracking&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;s&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;err&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;push&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;err&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;s&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;join&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;substr&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;500&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;pageTracker&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;_trackEvent&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Error&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;function_name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The good part is that it makes error monitoring a whole lot easier. Within a day of implementing this, I managed to get a couple of errors fixed that had been pending for months.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://thejeshgn.com&#34;&gt;Thejesh GN&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;29 May 2009 7:40 am&lt;/em&gt;:
That is a good tip. I can use the present infrastructure for error logging..&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Javascript error logging</title>
      <link>https://www.s-anand.net/blog/javascript-error-logging/</link>
      <pubDate>Tue, 25 Dec 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/javascript-error-logging/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;If something goes wrong with my site, I like to know of it. My top three problems are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://www.s-anand.net/blog/monitoring-site-downtime/&#34;&gt;The site is down&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.s-anand.net/blog/handling-missing-pages/&#34;&gt;A page is missing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#start3&#34;&gt;Javascript isn&amp;rsquo;t working&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is the last of 3 articles on these topics.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;I am a bad programmer&lt;/strong&gt;
I am not a professional developer. In fact, I&amp;rsquo;m not a developer at all. I&amp;rsquo;m a management consultant. (Usually, it&amp;rsquo;s myself I&amp;rsquo;m trying to convince.)
Since no one pays me for what little code I write, no one shouts at me for getting it wrong. So I have a happy and sloppy coding style. I write what I feel like, and publish it. I don&amp;rsquo;t test it. Worse, sometimes, I don&amp;rsquo;t even run it once. I&amp;rsquo;ve sent little scripts off to people which wouldn&amp;rsquo;t even compile. I make changes to this site at midnight, upload it, and go off to sleep without checking if the change has crashed the site or not.
&lt;strong&gt;But no one tells me so&lt;/strong&gt;
At work, that&amp;rsquo;s usually OK. On the few occasions where I&amp;rsquo;ve written Perl scripts or VB Macros that don&amp;rsquo;t work, people call me back within a few hours, very worried that THEY&amp;rsquo;d done something wrong. (Sometimes, I don&amp;rsquo;t contradict them.) It can be quite a stressful experience but good thing you can &lt;a href=&#34;https://www.exhalewell.com/cbd-flower/&#34;&gt;&lt;strong&gt;learn more here&lt;/strong&gt;&lt;/a&gt; on how to cope up with it.
On my site, I don&amp;rsquo;t always get that kind of feedback. People just click the back button and go elsewhere.
Recently, I&amp;rsquo;ve been doing more Javascript work on my site than writing stuff. Usually, the code works for me. (I write it for myself in the first place.) But I end up optimising for Firefox rather than IE, and for the plugins I have, etc. When I try the same app a few months later on &lt;a href=&#34;https://www.s-anand.net/blog/making-a-media-pc/&#34;&gt;my media PC&lt;/a&gt;, it doesn&amp;rsquo;t work, and shockingly enough, no one&amp;rsquo;s bothered telling me about it all these months. They&amp;rsquo;d just click, nothing happens, they&amp;rsquo;d vanish.
&lt;strong&gt;But their browsers can tell me&lt;/strong&gt;
The good part about writing code in Javascript is that I can catch exceptions. Any Javascript error can be trapped. So since the end of last year, I&amp;rsquo;ve started wrapping almost every Javascript function I write in a &lt;code&gt;try {} catch() {}&lt;/code&gt; block. In the &lt;code&gt;catch&lt;/code&gt; block, I send a log message reporting the error.
The code looks something like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;log&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;msg&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;msg&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Image&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;src&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;log.pl?m=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;encodeURIComponent&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;msg&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;abc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;k&#34;&gt;try&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// ... function code
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;catch&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;log&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;abc&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Any time there&amp;rsquo;s an error in &lt;code&gt;function abc&lt;/code&gt;, the &lt;code&gt;log&lt;/code&gt; function is called. It sends the function name (&lt;code&gt;&amp;quot;abc&amp;quot;&lt;/code&gt;) and the error details (the contents of the error event) to &lt;code&gt;log.pl&lt;/code&gt;, which stores the error, along with details like the URL, browser, time and IP address. This way, I know exactly where what error occurs.
This is a fantastic for a three reasons.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;It tells me &lt;strong&gt;when&lt;/strong&gt; I&amp;rsquo;ve goofed up&lt;/strong&gt;. This is instantaneous feedback. I don&amp;rsquo;t have to wait for a human. If you run my program on your machine, and it fails, &lt;strong&gt;I get to know immediately.&lt;/strong&gt; (Well, as soon as I read the error log, at least.)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It tells me &lt;strong&gt;where&lt;/strong&gt; I&amp;rsquo;ve goofed up&lt;/strong&gt;. The URL and the function name clearly indicate the point of failure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It tells me &lt;strong&gt;why&lt;/strong&gt; I&amp;rsquo;ve goofed up&lt;/strong&gt;. Almost. Using the browser name and the error message, I can invariably pinpoint the reason for the error. Then it&amp;rsquo;s just a matter of taking the time to fix it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;d think this sort of error reporting should be the norm for any software. At least for a web app, given how easy it is to implement.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CodeKitten&lt;/strong&gt; &lt;em&gt;25 Dec 2007 12:00 pm&lt;/em&gt;:
You should bind an onerror-triggered method to call your log method aswell :)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Danko Stojanovic&lt;/strong&gt; &lt;em&gt;10 May 2010 8:12 am&lt;/em&gt;:
I feel your pain. I also moved away from programming to management. I have to live with customers saying &amp;ldquo;It doesn&amp;rsquo;t work&amp;rdquo; and programmers &amp;ldquo;It works just fine when I test it&amp;rdquo;.
I so wish to know what is going on my client&amp;rsquo;s computer.
Thanks for this article. It helped me decide to pursue this further&lt;/li&gt;
&lt;li&gt;
&lt;h2 id=&#34;allan-ebdrup-13-nov-2011-723-amthe-onerror-event-is-a-great-way-to-start-logging-javascript-errors-more-people-should-use-it-javascript-errors-can-be-just-as-bad-as-a-webserver-that-is-down-you-really-need-to-log-those-errors-so-you-can-do-something-about-themonerror-is-quirky-it-does-not-fire-on-ipad-iphone-safari-and-some-other-browseres-to-catch-those-errors-you-have-to-insert-try-catches-arount-your-event-handlers-xhr-requests-and-some-other-places-this-will-also-let-you-get-more-detail-about-the-errror-call-stack-in-some-browsersbut-onerror-is-still-much-better-than-nothing&#34;&gt;&lt;strong&gt;&lt;a href=&#34;http://muscula.com&#34;&gt;Allan Ebdrup&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;13 Nov 2011 7:23 am&lt;/em&gt;:The onerror event is a great way to start logging JavaScript errors, more people should use it. JavaScript errors can be just as bad as a webserver that is down, you really need to log those errors so you can do something about them.onerror, is quirky. It does not fire on iPad, iPhone, Safari and some other browseres. To catch those errors you have to insert try-catch&amp;rsquo;es arount your event handlers, xhr-requests and some other places. This will also let you get more detail about the errror (call stack in some browsers).But onerror is still much better than nothing.&lt;/h2&gt;
We&amp;rsquo;ve solved a lot of these issues, with a solution that you install just like Google Analytics. Currently we are in a testing phase, private beta (free). To get an invite you can got to &lt;a href=&#34;http://muscula.com&#34;&gt;http://muscula.com&lt;/a&gt; and sign up.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kiawaki&lt;/strong&gt; &lt;em&gt;8 Jul 2011 5:45 am&lt;/em&gt;:
A question from somebody who is even less of a pro web developer: how exactly do you use this code? Do you put it before or after the script or both? Thanks!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://jserrlog.appspot.com&#34;&gt;Offbeatmammal&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;23 Sep 2011 12:48 am&lt;/em&gt;:
if you want a no-brain, minimal effort then have a look at jsErrLog &amp;hellip; a simple utility that does this and logs it to a remote AppEngine service (all for free, in an open source project) - check out &lt;a href=&#34;http://jsErrLog.appspot.com&#34;&gt;http://jsErrLog.appspot.com&lt;/a&gt; which links to the GitHub repository as well&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Excel - Avoid manual labour 4</title>
      <link>https://www.s-anand.net/blog/excel-avoid-manual-labour-4/</link>
      <pubDate>Wed, 21 Dec 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/excel-avoid-manual-labour-4/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Debugging in Excel&lt;/strong&gt; is another time consuming task. 80% of the trouble is identifying the problem (Error? What error? Where?) as opposed to fixing it (Why&amp;rsquo;s THAT cell showing THAT?). Most of my time is spent chasing three kinds of errors: wrong reference (leading to a #N/A or #REF!), wrong data input, or wrong formula.&lt;/p&gt;
&lt;p&gt;Wrong references are easy to spot. You&amp;rsquo;ll see a #N/A or a #REF! sticking out. But on large sheets, even that&amp;rsquo;s tough to spot. I always &lt;strong&gt;have a SUM (or some kind of total) function that covers EVERY cell in EVERY table&lt;/strong&gt;, even if I don&amp;rsquo;t need that information. If ther SUM shows a #N/A or #REF!, I can use Trace Error (Alt-T-U-E) to see where the problem is coming from.&lt;/p&gt;
&lt;p&gt;If you &lt;strong&gt;know&lt;/strong&gt; there&amp;rsquo;s a wrong reference in a cell (say A1), and want to ignore it, use a new cell with the formula =IF(ISERROR(A1),0,A1). You can substitute an entire row, column or table this way.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Wrong data input&lt;/strong&gt; is best avoided upfront. Before I hand my Excel sheets over for large scale data entry, I do three things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Let them enter data only in input areas&lt;/strong&gt;. Unprotect the cells the user can enter data in (Ctrl-1, Protection, remove the tick against &amp;lsquo;Locked&amp;rsquo;), and protect the whole sheet (Alt-T-P-P).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validate the data&lt;/strong&gt;. Turn on data validation (Alt-D-L) on &lt;strong&gt;all editable cells&lt;/strong&gt;, and specify the validation criteria.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make it easy to spot errors&lt;/strong&gt;. If there are percentages that should add to 100%, show the total in a cell that turns green if the total is 100%, and red otherwise. (Use conditional formatting - Alt-O-D). If data about 20 people must be entered, show the number of people about whom data is entered, and mark it red until it&amp;rsquo;s 20. Make sure &lt;strong&gt;all&lt;/strong&gt; criteria are captured. When the spreadsheet is filled, it should be impossible to make errors.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Wrong formulae (like + instead of -) are tough to spot. The best way to check for this is to &lt;strong&gt;do the same calculation &lt;strong&gt;in different ways&lt;/strong&gt;, and compare the results&lt;/strong&gt;. Whenever I create complex tables, I always have an error row at the bottom. I compare the totals on the table with the totals &lt;strong&gt;calculated in a simpler way&lt;/strong&gt; and check the difference. This warns me when I miss out some elements, or double count something, in the table.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rajlaxmi&lt;/strong&gt; &lt;em&gt;1 Jan 2006 5:08 pm&lt;/em&gt;:
great tutorial on excel..ready reckoner&amp;hellip;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;2 Jan 2006 9:42 pm&lt;/em&gt;:
Thanks!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Peter&lt;/strong&gt; &lt;em&gt;8 Mar 2007 11:31 pm&lt;/em&gt;:
Avoid Manual Labour: I just spent hours writing a VB script that does essentially what the &amp;lsquo;Conditional Formatting&amp;rsquo; feature does. Thanks for pointing it out!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://isomorphismes.tumblr.com&#34;&gt;isomorphismes&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;13 Mar 2013 5:26 pm&lt;/em&gt;:
That is a great idea.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>500 mile e-mail</title>
      <link>https://www.s-anand.net/blog/500-mile-e-mail/</link>
      <pubDate>Wed, 07 Dec 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/500-mile-e-mail/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.ibiblio.org/harris/500milemail.html&#34;&gt;500 mile e-mail&lt;/a&gt;: the story of a server that would not send e-mail beyond 500 miles.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Commenting is back</title>
      <link>https://www.s-anand.net/blog/commenting-is-back/</link>
      <pubDate>Mon, 07 Mar 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/commenting-is-back/</guid>
      <description>&lt;p&gt;I had disabled commenting for a while. It&amp;rsquo;s back on.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;TOPFRAME&lt;/strong&gt; &lt;em&gt;7 Mar 2005 9:48 am&lt;/em&gt;:
not working&amp;hellip;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;7 Mar 2005 10:31 am&lt;/em&gt;:
Try now. I think I&amp;rsquo;ve fixed the TOPFRAME problem as well.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jetru&lt;/strong&gt; &lt;em&gt;7 Mar 2005 6:39 pm&lt;/em&gt;:
oh, umm workin!!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jetru&lt;/strong&gt; &lt;em&gt;7 Mar 2005 7:05 pm&lt;/em&gt;:
isn&amp;rsquo;t working right&amp;hellip;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;8 Mar 2005 3:43 am&lt;/em&gt;:
Check now. Should be fine.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jetru&lt;/strong&gt; &lt;em&gt;8 Mar 2005 2:44 pm&lt;/em&gt;:
Cool! My name saves only 4 the session though. Based on IP?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;8 Mar 2005 3:13 pm&lt;/em&gt;:
Cookies, actually.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
  </channel>
</rss>
