<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/feed_style.xsl" type="text/xsl"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="https://www.rssboard.org/media-rss"><channel><title>litlighilit Blog Site</title><link>/</link><description>Recent content on litlighilit Blog Site</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 06 Nov 2025 21:38:58 +0800</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><icon>/img/icon.svg</icon><item><title>Notes</title><link>/notes/</link><pubDate>Thu, 06 Nov 2025 21:38:58 +0800</pubDate><guid>/notes/</guid><description><![CDATA[<blockquote>
<p>Click &ldquo;&hellip;&rdquo; within and there is &ldquo;View original page&rdquo;</p></blockquote>
<iframe src='https://litlighilit.notion.site/ebd/note' width="100%" height="600" frameborder="0" allowfullscreen/>

]]></description></item><item><title>Polyglot</title><link>/posts/nim.vs.py/polyglot/</link><pubDate>Mon, 08 Sep 2025 20:03:11 +0800</pubDate><guid>/posts/nim.vs.py/polyglot/</guid><description><![CDATA[<p>While <a href="https://nimpylib.org">nimpylib</a>(<a href="https://github.com/nimpylib/nimpylib">repo</a>)
is handy to write Python code in Nim,</p>
<p>what if writing polyglot code,
which is runnable in both Nim and Python?</p>
<blockquote>
<p><a href="https://github.com/nimpylib/NPython/blob/5dffaea5daef781fb55154e7768ea614af08d113/Modules/unicodedata/test_decimalAndSpace.nim">An example (NPython&rsquo;s test_decimalAndSpace.nim)</a> using such polyglot</p></blockquote>
<hr>
<h2 id="how-to">How to</h2>
<p>We simply write two parts:</p>
<ul>
<li>run in both languages (thanks to their similar syntax)</li>
<li>snippets run in only one, ignored by another</li>
</ul>
<p>Many parts of syntax of they two are similar, so we don&rsquo;t
discuss such here</p>
<p>and what&rsquo;s more important is that
how to make some code ignored by specified one language</p>
<h3 id="cheat-nim-to-ignore-some-python-code">Cheat Nim to ignore some Python code</h3>
<p>Let&rsquo;s start with the easier one.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Python" data-lang="Python"><span style="display:flex;"><span><span style="color:#75715e">#[</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;</span>Python code here<span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>[
</span></span><span style="display:flex;"><span>]<span style="color:#75715e">#</span>
</span></span></code></pre></div><h3 id="explain">Explain</h3>
<p>Python regards it as:</p>
<ul>
<li>Comment <code>[</code></li>
<li><code>&lt;Python code here&gt;</code></li>
<li>An empty list literal <code>[]</code></li>
<li>Comment <code>&lt;empty&gt;</code></li>
</ul>
<p>But in Nim <code>#[</code> starts a multiline comment and <code>]#</code> ends it.</p>
<h3 id="restriction">Restriction</h3>
<p>No more needed to mention but
the restriction is <code>&lt;Python code here&gt;</code> cannot contain <code>]#</code>.</p>
<p>If any, simply rewrite as <code>] #</code> like <code>[1,2,3] # xxx</code></p>
<h3 id="cheat-python-to-ignore-some-nim-code">Cheat Python to ignore some Nim code</h3>
<p>This part is harder.</p>
<p>I&rsquo;d like to give my solution:</p>
<h3 id="steps">steps</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Nim" data-lang="Nim"><span style="display:flex;"><span><span style="color:#e6db74">&#34;&#34;&#34;\&#34;&#34;&#34;</span>.`<span style="color:#f92672">!=</span>`(<span style="color:#e6db74">&#34;&#34;</span>).assert
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;</span>Nim code here<span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">discard</span> <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#f92672">!=</span> <span style="color:#e6db74">&#34;&#34;&#34;&#34;_&#34;&#34;&#34;</span>
</span></span></code></pre></div><blockquote>
<p>You can also use <code>assert</code> over <code>discard</code> on the last line, which is easier to remember.</p></blockquote>
<h3 id="restriction-1">Restriction</h3>
<p>The only restriction is that <code>&lt;Nim code here&gt;</code> cannot contain <code>&quot;&quot;&quot;</code>.</p>
<p>If any, &hellip;consider to split into single line string literals.</p>
<h4 id="explain-1">Explain</h4>
<p>This trick takes advantage of some difference between Nim and Python when
parsing multiline string literal node.</p>
<p>Here are their parsing results:</p>
<h5 id="nim">Nim:</h5>
<p>-&gt;</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Nim" data-lang="Nim"><span style="display:flex;"><span>assert <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#f92672">!=</span> (<span style="color:#e6db74">&#39;</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">&#39;</span> <span style="color:#f92672">&amp;</span> <span style="color:#e6db74">&#39;&#34;&#39;</span>)
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;</span>Nim code here<span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">discard</span> <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#f92672">!=</span> (<span style="color:#e6db74">&#39;</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">&#39;</span> <span style="color:#f92672">&amp;</span> <span style="color:#e6db74">&#39;_&#39;</span>)
</span></span></code></pre></div><p>dumpTree:</p>
<pre tabindex="0"><code>  Command
    Ident &#34;assert&#34;
    Infix
      Ident &#34;!=&#34;
      StrLit &#34;&#34;
      TripleStrLit  &#34;\\\&#34;&#34;  # `\&#34;`
  &lt;Nim code here&gt;
  DiscardStmt
    Infix
      Ident &#34;!=&#34;
      StrLit &#34;&#34;
      TripleStrLit  &#34;\&#34;_&#34;   # `\_`
</code></pre><h5 id="python">Python:</h5>
<p>-&gt;</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Python" data-lang="Python"><span style="display:flex;"><span><span style="color:#e6db74">&#34;&#34;&#34;</span><span style="color:#ae81ff">\&#34;</span><span style="color:#e6db74">&#34;&#34;.`!=`(&#34;&#34;).assert
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">&lt;Nim code here&gt;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">discard &#34;&#34; != &#34;&#34;&#34;</span> <span style="color:#e6db74">&#34;_&#34;</span> <span style="color:#e6db74">&#34;&#34;</span>
</span></span></code></pre></div><p>-&gt;</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Python" data-lang="Python"><span style="display:flex;"><span><span style="color:#e6db74">&#34;&#34;&#34;</span><span style="color:#ae81ff">\&#34;</span><span style="color:#e6db74">&#34;&#34;.`!=`(&#34;&#34;).assert
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">&lt;Nim code here&gt;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">discard &#34;&#34; != _&#34;&#34;&#34;</span>
</span></span></code></pre></div><p>-&gt;</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Python" data-lang="Python"><span style="display:flex;"><span><span style="color:#e6db74">&#39;&#39;&#39;&#34;&#34;&#34;.`!=`(&#34;&#34;).assert
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">&lt;Nim code here&gt;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">discard &#34;&#34; != _&#39;&#39;&#39;</span>
</span></span></code></pre></div>]]></description></item><item><title>Unicode Space</title><link>/posts/unicode-space/</link><pubDate>Sun, 16 Feb 2025 18:17:24 +0800</pubDate><guid>/posts/unicode-space/</guid><description><![CDATA[<h2 id="introducion">Introducion</h2>
<p>Some online chat clients, like WhatsApp, WeChat and Identity V, reject empty as well as
space message.</p>
<p>But once you wanna send blank message,
there&rsquo;s a workaround for WhatsApp and WeChat: just use Unicode Spaces</p>
<h2 id="workaround">Workaround</h2>
<p>That&rsquo;s due to WeChat&rsquo;s <code>isspace</code> only checks ASCII space (U+0020) but not others.</p>
<p>One of the most commonly used is U+2000 (&quot;\u2000&quot; in <code>python</code>):
<button onclick="navigator.clipboard.writeText('\\u2000')">click me to copy</button></p>
<blockquote>
<p>not worked for Identity V</p></blockquote>
<p>&hellip;</p>
<h2 id="a-full-list">A full list</h2>
<table>
  <thead>
      <tr>
          <th>Unicode</th>
          <th>HTML</th>
          <th>Description</th>
          <th>Example</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>U+0020</td>
          <td>&amp;#32</td>
          <td>Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+00A0</td>
          <td>&amp;#160</td>
          <td>No-Break Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2000</td>
          <td>&amp;#8192</td>
          <td>En Quad</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2001</td>
          <td>&amp;#8193</td>
          <td>Em Quad</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2002</td>
          <td>&amp;#8194</td>
          <td>En Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2003</td>
          <td>&amp;#8195</td>
          <td>Em Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2004</td>
          <td>&amp;#8196</td>
          <td>Three-Per-Em Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2005</td>
          <td>&amp;#8197</td>
          <td>Four-Per-Em Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2006</td>
          <td>&amp;#8198</td>
          <td>Six-Per-Em Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2007</td>
          <td>&amp;#8199</td>
          <td>Figure Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2008</td>
          <td>&amp;#8200</td>
          <td>Punctuation Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2009</td>
          <td>&amp;#8201</td>
          <td>Thin Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+200A</td>
          <td>&amp;#8202</td>
          <td>Hair Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+2028</td>
          <td>&amp;#8232</td>
          <td>Line Separator</td>
          <td>[]</td>
      </tr>
      <tr>
          <td>U+205F</td>
          <td>&amp;#8287</td>
          <td>Medium Mathematical Space</td>
          <td>[ ]</td>
      </tr>
      <tr>
          <td>U+3000</td>
          <td>&amp;#12288</td>
          <td>Ideographic Space</td>
          <td>[　]</td>
      </tr>
  </tbody>
</table>
<p>ref <a href="https://emptycharacter.com/">https://emptycharacter.com/</a></p>
]]></description></item><item><title>Hello2025</title><link>/posts/hello2025/</link><pubDate>Tue, 28 Jan 2025 23:48:42 +0800</pubDate><guid>/posts/hello2025/</guid><description><![CDATA[<h1 id="hello-new-year-2025">Hello New Year 2025</h1>
<p>Happy China New Year!</p>
<p>Everyone!</p>
<blockquote>
<p>In my opinion, the very part of this new year to commemorate is
&ldquo;It&rsquo;s Python Year&rdquo;</p></blockquote>
<p>Yep. Have fun.</p>
]]></description></item><item><title>Hello</title><link>/posts/hello/</link><pubDate>Mon, 13 Jan 2025 04:53:05 +0800</pubDate><guid>/posts/hello/</guid><description><![CDATA[<h1 id="hello-welcome">Hello, Welcome</h1>
<h2 id="welcome-to-u">Welcome to u!</h2>
<p>Here&rsquo;s my blog website, where I&rsquo;d like to share
somthing about my daily experiement as well as my notes.</p>
]]></description></item></channel></rss>