<?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>source-code on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/source-code/</link>
    <description>Recent content in source-code on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 08 Jan 2021 09:37:52 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/source-code/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to extend Markdown with custom blocks</title>
      <link>https://www.s-anand.net/blog/how-to-extend-markdown-with-custom-blocks/</link>
      <pubDate>Fri, 08 Jan 2021 09:37:48 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/how-to-extend-markdown-with-custom-blocks/</guid>
      <description>&lt;p&gt;One problem I&amp;rsquo;ve had in Markdown is rendering a content in columns.&lt;/p&gt;
&lt;p&gt;On Bootstrap, the markup would look like this:&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;div class=&amp;#34;row&amp;#34;&amp;gt;
  &amp;lt;div class=&amp;#34;col&amp;#34;&amp;gt;...&amp;lt;/div&amp;gt;
  &amp;lt;div class=&amp;#34;col&amp;#34;&amp;gt;...&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;How do we get that into Markdown without writing HTML?&lt;/p&gt;
&lt;p&gt;On Python, the &lt;a href=&#34;https://python-markdown.github.io/extensions/attr_list/&#34;&gt;attribute lists extension&lt;/a&gt; lets you add a class. For example:&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-markdown&#34; data-lang=&#34;markdown&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;This is some content
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;{: .row}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&amp;hellip; renders &lt;code&gt;&amp;lt;p class=&amp;quot;row&amp;quot;&amp;gt;This is some content&amp;lt;/p&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But I can&amp;rsquo;t do that to multiple paragraphs. Nor can I next content, i.e. add a &lt;code&gt;.col&lt;/code&gt; inside the &lt;code&gt;.row&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Enter &lt;a href=&#34;https://pypi.org/project/markdown-customblocks/&#34;&gt;markdown-customblocks&lt;/a&gt;. It&amp;rsquo;s a Python module that extends &lt;a href=&#34;https://python-markdown.github.io/&#34;&gt;Python Markdown&lt;/a&gt;. This lets me write:&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-markdown&#34; data-lang=&#34;markdown&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: row
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: col
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Content in column 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: col
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Content in column 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: row
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: col
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Content in column 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;::: col
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Content in column 2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This translates to:&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;div class=&amp;#34;row&amp;#34;&amp;gt;
  &amp;lt;div class=&amp;#34;col&amp;#34;&amp;gt;Content in column 1&amp;lt;/div&amp;gt;
  &amp;lt;div class=&amp;#34;col&amp;#34;&amp;gt;Content in column 2&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Better yet, we can create our own custom HTML block types. For example, this code:&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-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;markdown&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Markdown&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;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;customblocks&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;CustomBlocksExtension&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;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;audio&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ctx&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;src&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;type&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;audio/mp3&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;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;sa&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&amp;#39;&amp;lt;audio src=&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;src&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#34; type=&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;type&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#34;&amp;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;s1&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ctx&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;content&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s1&#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;s1&#34;&gt;    &amp;lt;/audio&amp;gt;&amp;#39;&amp;#39;&amp;#39;&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;n&#34;&gt;md&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Markdown&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;extensions&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;n&#34;&gt;CustomBlocksExtension&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;generators&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;s1&#34;&gt;&amp;#39;audio&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;audio&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;&amp;hellip; lets you convert this piece of Markdown:&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-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;md&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;convert&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;#34;&amp;#34;
&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;s2&#34;&gt;::: audio src=&amp;#34;mymusic.ogg&amp;#34; type=&amp;#34;audio/ogg&amp;#34;
&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;s2&#34;&gt;    Your browser does not support `audio`.
&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;s2&#34;&gt;&amp;#34;&amp;#34;&amp;#34;&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;&amp;hellip; into this HTML:&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;audio src=&amp;#34;mymusic.ogg&amp;#34; type=&amp;#34;audio/ogg&amp;#34;&amp;gt;
  Your browser does not support &amp;lt;code&amp;gt;audio&amp;lt;/code&amp;gt;.
&amp;lt;/audio&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href=&#34;https://pypi.org/project/markdown-customblocks/&#34;&gt;markdown-customblocks&lt;/a&gt; is easily the most useful Python module I discovered last quarter.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Google code search hacks</title>
      <link>https://www.s-anand.net/blog/google-code-search-hacks/</link>
      <pubDate>Wed, 04 Oct 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/google-code-search-hacks/</guid>
      <description>&lt;p&gt;Jason Kottke finds interesting &lt;a href=&#34;http://www.kottke.org/06/10/google-code-search&#34;&gt;code search hacks&lt;/a&gt;, ranging from the WinZip key generation algorithm to programmers who want a new job.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Krugle</title>
      <link>https://www.s-anand.net/blog/krugle/</link>
      <pubDate>Wed, 12 Jul 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/krugle/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://krugle.com/&#34;&gt;Krugle&lt;/a&gt; is a code search engine.&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;sheikh&lt;/strong&gt; &lt;em&gt;14 Dec 2006 3:08 pm&lt;/em&gt;:
Thank you anand, It was very useful&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Microsoft not opening more source code</title>
      <link>https://www.s-anand.net/blog/microsoft-not-opening-more-source-code/</link>
      <pubDate>Thu, 10 Feb 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/microsoft-not-opening-more-source-code/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://it.slashdot.org/article.pl?sid=05/02/10/005206&amp;amp;from=rss&#34;&gt;Why is Microsoft not opening more source code&lt;/a&gt;?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Apparently inappropriate code comments is one of the reasons according to this story. I wonder what kind of things developers put in comments that would be so bad for the rest of us to see?&lt;/p&gt;
&lt;/blockquote&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;sathish&lt;/strong&gt; &lt;em&gt;10 Feb 2005 12:00 pm&lt;/em&gt;:
checking if the contact name is coming properly..&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Venkat&lt;/strong&gt; &lt;em&gt;10 Feb 2005 12:00 pm&lt;/em&gt;:
GMaP is cool! Better than mappy. Do we have something like this for India?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>New commenting system 2</title>
      <link>https://www.s-anand.net/blog/new-commenting-system-2/</link>
      <pubDate>Tue, 01 Feb 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/new-commenting-system-2/</guid>
      <description>&lt;p&gt;My new commenting system is based on the principle of &amp;ldquo;scribbling on the margin&amp;rdquo;. If you&amp;rsquo;re interested, have a look at the source code for this page. It is as clear as mud, so best of luck!&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;Ammadio&lt;/strong&gt; &lt;em&gt;1 Feb 2005 12:00 pm&lt;/em&gt;:
Where do these comments get stored&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Navneet&lt;/strong&gt; &lt;em&gt;1 Feb 2005 12:00 pm&lt;/em&gt;:
Nice commenting system. A couple of points though&amp;hellip;It took me a while to figure out how to post the comment :). Maybe a note on that somewhere would help.. Also the text colour when I&amp;rsquo;m typing in the comment is almost invisible.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;1 Feb 2005 12:00 pm&lt;/em&gt;:
I fixed those two. Is it OK? Anything else?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TOPFRAME&lt;/strong&gt; &lt;em&gt;1 Feb 2005 12:00 pm&lt;/em&gt;:
Good to see you back, Anand. :)&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Microsoft will reveal Windows source</title>
      <link>https://www.s-anand.net/blog/microsoft-will-reveal-windows-source/</link>
      <pubDate>Tue, 06 Aug 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/microsoft-will-reveal-windows-source/</guid>
      <description>&lt;p&gt;At last, Microsoft will be &lt;a href=&#34;http://money.cnn.com/2002/08/05/technology/microsoft/index.htm&#34;&gt;revealing its Windows source&lt;/a&gt;. Parts of it.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>I opted out of many popup ads</title>
      <link>https://www.s-anand.net/blog/i-opted-out-of-many-popup-ads/</link>
      <pubDate>Mon, 14 Jan 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/i-opted-out-of-many-popup-ads/</guid>
      <description>&lt;p&gt;I &lt;a href=&#34;http://technoerotica.net/mylog/optouts.html&#34;&gt;opted out of many popup ads&lt;/a&gt;. Not that I particularly mind them&amp;hellip; I just wanted to test out the code.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Windows CE source code</title>
      <link>https://www.s-anand.net/blog/windows-ce-source-code/</link>
      <pubDate>Sat, 11 Aug 2001 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/windows-ce-source-code/</guid>
      <description>&lt;p&gt;I&amp;rsquo;d missed this earlier. Microsoft has released its &lt;a href=&#34;http://www.microsoft.com/windows/embedded/ce/tools/source/default.asp&#34;&gt;Windows CE source code&lt;/a&gt; to the public!&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Cracking DVDs</title>
      <link>https://www.s-anand.net/blog/cracking-dvds/</link>
      <pubDate>Fri, 16 Mar 2001 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/cracking-dvds/</guid>
      <description>&lt;p&gt;Two MIT students have written a 7-line program that &lt;a href=&#34;http://www.zdnet.com/zdnn/stories/news/0,4586,2693768,00.html&#34;&gt;unscrambles protected DVDs&lt;/a&gt;. It&amp;rsquo;s &lt;a href=&#34;http://www.cs.cmu.edu/~dst/DeCSS/Gallery/&#34;&gt;downloadable&lt;/a&gt;. The legal issue is whether source code deserves protection on par with freedom of expression.&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
