<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/feed.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Locria&apos;s random thoughts</title>
  <link rel="alternate" href="https://www.1a-insec.net/frag/"/>
  <link rel="self" href="https://www.1a-insec.net/frag.atom.xml"/>
  <updated>2026-07-21T12:00:00Z</updated>
  <author>
    <name>Locria Cyber</name>
  </author>
  <id>urn:uuid:22e8faa2-b4d6-4693-935b-e73130cba690</id>
  <icon>/images/favicon.webp</icon>

  <entry>
    <id>https://www.1a-insec.net/frag/44-svg-has-no-hinting/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/44-svg-has-no-hinting/"/>
    <title>SVG does not have hinting</title>
    <published>2024-07-14T12:00:00Z</published>
    <updated>2024-07-14T12:00:00Z</updated>
    <category term="comp"/>
    <category term="vector_graphics"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/44-svg-has-no-hinting/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Using SVG for vector icons is meh.</p>
<p>With hinting (as text): <img src="as-text.png" alt="" class="inline"/></p>
<p>Without hinting (as SVG): <img src="as-svg.png" alt="" class="inline"/></p>
<p>Hinting is also mentioned in <a href="https://css-tricks.com/fontello-past-future-icon-font-service/">https://css-tricks.com/fontello-past-future-icon-font-service/</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/43-refactorer/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/43-refactorer/"/>
    <title>A Profession to Solve Problems With Software In Everyday Life</title>
    <published>2024-07-09T12:00:00Z</published>
    <updated>2024-08-02T12:00:00Z</updated>
    <category term="tech"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/43-refactorer/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Seeing people who have problem with software that I can solve easily yet they struggle with has made me think about ways to solve it entirely.</p>
<p>Option A: educate everyone on the basics of information handling. Teaching this does not need actual computers.<br/>
Option B: educate every software engineer on the basics of software engineering. I have a feeling that this is harder than Option A; much harder, in fact.<br/>
Option C: create a new profession.<br/>
</p>
<p>This article is about Option C.</p>
<p>So I see some have physical shops to repair hardware. What if we can do the same but with software? As information handlers, we can offer services such as looking up certain information and making that into a one-click application (making custom software), printing out maps and other info, installing OS, m.. you get the idea. Having a physical shop is important because&#x2026; E-mail. It&#x2019;s not made of paper. It&#x2019;s like &#x2026; uh &#x2026; do you know what a file is? No? Nevermind then.</p>
<p>How much pay is in this profession? I don&#x2019;t know. Who set up websites for individuals as a profession is close to this line of work. Doing this also requires a physical store front. About renting it&#x2026; I&#x2019;d rather not rent one.</p>
<p>How much respect will you get? You fix problems for the commons that nobody can, cared to fix for them before, so, major respect.</p>
<hr/>
<p>Update 2024-08-02:</p>
<p>I have thought more about this.</p>
<p>What will mend the relation between those who don&#x2019;t know tech and those that do? Electronic gadget manufacturers care about themselves and nothing else.</p>
<p>Creating a hardware company might help. It is of utmost importance that I play by my own terms, or there is no point in working towards the goal.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/42-data-trx-energy-trx/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/42-data-trx-energy-trx/"/>
    <title>Data Transmission via Energy Transmission</title>
    <published>2024-07-06T12:00:00Z</published>
    <updated>2024-07-06T12:00:00Z</updated>
    <category term="comp"/>
    <category term="eco"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/42-data-trx-energy-trx/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This idea occured to me when watching <em>Wind Breaker</em>, a show about people beating each other up.</p>
<p>Wherever energy flows, you can encode info by modulating that energy.</p>
<p>I think I may have taken this idea too seriously.</p>
<p>A lethal amount of energy transmission for some can be communication for others. I know plants do this, but seeing it between people is kind of funny.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/41-on-computing-and-tech/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/41-on-computing-and-tech/"/>
    <title>Thoughts on Computing and the tech industry</title>
    <published>2024-07-03T12:00:00Z</published>
    <updated>2024-07-03T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/41-on-computing-and-tech/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>The discipline of Computing is more about how to think, not who or what is thinking.</p>
<p>The majority of people who trade software are in it because they want to make money. That&#x2019;s their main motivation. It&#x2019;s rare to see those who enjoy engineering and want to make money on the side.</p>
<p>I guess this isn&#x2019;t a problem. When commercialization meets passion, commercialization is not even trying.</p>
<p>It is a problem, though, that consumers of commercial software suffer from it. I&#x2019;ve observed that the technical literate and the technical illiterate lived in two different worlds. If we connect the two worlds together, the problem would be solved. This is not particularly hard to do; it requires some thinking. There is ego in the solution, which I had to deal with it myself.</p>
<p>I don&#x2019;t think I can explain the solution in text well. Hope&#x2019;s that I will be able to show by example soon.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/40-more-about-society/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/40-more-about-society/"/>
    <title>I think I understand a bit more about society</title>
    <published>2024-06-28T12:00:00Z</published>
    <updated>2024-06-28T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/40-more-about-society/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I have observed that social stratas exist because people don&#x2019;t want to move (this alone has veto power on the existence of social stratas).</p>
<p>I have realized that poverty is artificial. The real issue lies in the fact that people cannot reach their full potential because they are resource-constrained (a.k.a. poverty). This is an unfulfilled need they want to solve - a genuine social problem. Giving people money is an instrumental goal. Maybe we can work around it?</p>
<p>Being able to manipulate the economy is important in solving poverty, so I looked at <a href="https://en.wikipedia.org/wiki/Quantitative_analysis_(finance)">a type of numbers related to economy</a>. It&#x2026; doesn&#x2019;t feel real. I&#x2019;ll look for a way to feel how money flows with little to no abstractions on top. Sucks to be me. XD</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/39-on-popularity-and-knowledge/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/39-on-popularity-and-knowledge/"/>
    <title>On Software Popularity And Knowledge</title>
    <published>2024-05-21T12:00:00Z</published>
    <updated>2024-05-29T12:00:00Z</updated>
    <category term="soc"/>
    <category term="vent"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/39-on-popularity-and-knowledge/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I hear some people say, &#x201c;Label your open-source project as (A)GPL or corporations will steal it from you&#x201d;. For most open-source projects (those are small), this is not true. Most for-profit companies will only use projects that are successful (read: popular) or have good marketing (read: perceived popular). They don&#x2019;t really care about quality. If some software&#x2019;s home page has a word that matches what they think they need, they will use it; otherwise no.</p>
<p>I think <a href="/blog/40-capital-hype-scheme/">my warning</a> will mostly fall on deaf ears for those who do not pursue knowledge.</p>
<p>I consider the following advice to be the most valuable thing on this website:</p>
<p>process every piece of information that you encounter<br/>
you might find what you don&#x2019;t know that you needed</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/38-freebsd-10k-fail/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/38-freebsd-10k-fail/"/>
    <title>Failing At The 100k Problem On FreeBSD</title>
    <published>2024-05-20T12:00:00Z</published>
    <updated>2024-05-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/38-freebsd-10k-fail/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I had the billiant idea of running 100k processes at once on FreeBSD.</p>
<p>So, I tried to patch the kernel.</p>
<pre><code class="language-shell">cd /usr/src/
# patch the kernel here (see below)
make buildkernel KERNCONF=GENERIC
</code></pre>
<p>The patch on <code>sys/proc.h</code></p>
<pre><code class="language-c">-#define PID_MAX         99999
-#define NO_PID          100000
+#define PID_MAX         (2147483647-1) 
+#define NO_PID          (PID_MAX+1) 
</code></pre>
<p>As it turns out, the FreeBSD kernel is structured in a way that there are bitarrays keeping track of every PID possible, making this configuration not compile-able.</p>
<p>So, I reverted to using the following script to stress test the system.</p>
<pre><code class="language-c">#include &lt;unistd.h&gt;
#include &lt;stdio.h&gt;
#include &lt;sys/wait.h&gt;

int main() {
    long int count = 0;
    while (1) {
        int pid = rfork(RFPROC|RFTHREAD);
        if (pid &lt; 0) break;
        int sig;
        if (pid == 0) {
            count += 1;
            if (count % 1000 == 0) printf(&quot;%ld\n&quot;, count);
        }
        else (void)wait(&amp;sig);
    }
    return 0;
}
</code></pre>
<p>It got stuck at 12000 and froze the whole system. Changing <code>rfork</code> to <code>fork</code> didn&#x2019;t seem to change anything. I think the OS ran out of memory but I can&#x2019;t tell because all processes freeze when there are 12000 processes, including tools like <code>top</code>.</p>
<p>Recalling from memory, I have been able to run 40000+ process on Linux with the same amount of memory plus some simply application logic, and the system is still lively with GUI interactable. I guess Linux is still the most efficient operating system out there. For now, you can have 10k processes with Capsicum-based security on FreeBSD and allocate one security context to each user.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/37-posix-login/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/37-posix-login/"/>
    <title>How POSIX User ID and Supplementary Group IDs are Set On Login</title>
    <published>2024-05-09T12:00:00Z</published>
    <updated>2024-07-07T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/37-posix-login/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This is usually done by the <code>login(1)</code> setuid executable.</p>
<p>It looks up <code>/etc/passwd</code> with the username and gets the <strong>User ID</strong> and the <strong>Primary Group ID</strong>. This is the <code>0:0</code> in <code>/etc/passwd</code>.</p>
<pre><code>root:*:0:0:Superuser:/root:/usr/local/bin/fish
</code></pre>
<p>It looks up <code>/etc/group</code> with the username and gets all the groups the user is in (<strong>Supplementary Group IDs</strong>).</p>
<p>Then, it spawns a shell (the shell command is also read from <code>/etc/passwd</code>) in a new <strong>session</strong> (kernel concept) with the User ID, Primary Group ID, Supplementary Group IDs. It also sets <code>&#x24;USER</code> and other environment variables.</p>
<hr/>
<p>One uid can have multiple names, and one gid can have multiple names.</p>
<p>Here&#x2019;s an example from FreeBSD:</p>
<p><code>/etc/passwd</code>:</p>
<pre><code>root:*:0:0:Superuser:/root:/usr/local/bin/fish
toor:*:0:0:Bourne-again Superuser:/root:
</code></pre>
<p><code>/etc/group</code>:</p>
<pre><code>wheel:*:0:root
operator:*:5:root
</code></pre>
<p>Now observe the magic:</p>
<pre><code>user@ed ~&gt; doas -s -u root
root@ed ~# groups
wheel operator
root@ed ~# exit
user@ed ~&gt; doas -s -u toor
toor@ed ~# groups
wheel
</code></pre>
<hr/>
<p>An even more cursed idea:</p>
<pre><code>root:*:0:0::/root:
toor:*:0:5::/root:
</code></pre>
<hr/>
<p>As it turns out, the source of uid/gid comes is less straightforward than simply reading <code>/etc/passwd</code>. libc (providing <code>getpwent(3)</code> and family) reads <code>/etc/nsswitch.conf</code> to see if it should access <code>/etc/passwd</code> or some other place.</p>
<p>Authentication modules like <code>pam_unix.so</code> in Linux-PAM uses <code>getpwent(3)</code> to check passwords of UNIX users.</p>
<hr/>
<p>Update(2024-07-07): Don&#x2019;t know where else to put it, so I&#x2019;m putting it here.</p>
<p>On OpenBSD, <a href="https://man.openbsd.org/doas.1"><code>doas(1)</code></a> <a href="https://man.openbsd.org/tty.4#TIOCSETVERAUTH">sets an attribute on the controlling terminal</a> with <a href="https://man.openbsd.org/ioctl.2"><code>ioctl(2)</code></a>. I wonder what other ways one can associate metadata with tty.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/36-self-feeling-0/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/36-self-feeling-0/"/>
    <title>A Thought - 0</title>
    <published>2024-05-09T12:00:00Z</published>
    <updated>2024-05-09T12:00:00Z</updated>
    <category term="meta"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/36-self-feeling-0/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I recently realized that mixing making money and sharing knowledge makes me unhappy. Even thinking about writing a book and potentially selling it makes me deeply uncomfortable.</p>
<p>The feeling is probably given to me by birth. <em>*flops*</em></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/35-freebsd-fd-race/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/35-freebsd-fd-race/"/>
    <title>Do Not Share Descriptor Table On FreeBSD</title>
    <published>2024-05-06T12:00:00Z</published>
    <updated>2024-05-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/35-freebsd-fd-race/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><s>First of all, &#x201c;threads&#x201d; are fake.</s> They exist in dreams, but not to the FreeBSD kernel. In the kernel source code, there&#x2019;s something called &#x201c;process leader&#x201d; or <code>p_leader</code>. Every process has a <code>p_leader</code>.</p>
<p>Update(2024-05-20): ok, so, <a href="https://man.freebsd.org/cgi/man.cgi?query=thr_self&amp;apropos=0&amp;sektion=0&amp;manpath=FreeBSD+15.0-CURRENT&amp;arch=default&amp;format=html">threads are real</a>. They are non-standard and I&#x2019;m not sure how they interact with Capsicum.</p>
<p>Here&#x2019;s all you need to know about <code>p_leader</code>:</p>
<ul>
<li>When a process exits, all processes having it as <code>p_leader</code> are sent <code>SIGKILL</code>.</li>
<li>When a process tries to hold an advisory lock, it will be held by its <code>p_leader</code>.</li>
<li><code>rfork(RFPROC|RFTHREAD)</code> sets the new process&#x2019; <code>p_leader</code> to be the current process&#x2019; <code>p_leader</code>,</li>
<li>otherwise, a new process starts with itself as its <code>p_leader</code>.</li>
</ul>
<p>Multiple processes can share a file descriptor table with <code>rfork(2)</code>. I&#x2019;d say this is a bad idea. You don&#x2019;t want the time-at-access,time-at-use bug to appear in your program.</p>
<p>Writing secure applications on FreeBSD is easy.</p>
<ul>
<li>use capsicum and refer to every resource as a file descriptor</li>
<li>don&#x2019;t share descriptor table across processes</li>
</ul>
<p>That&#x2019;s it! Security on FreeBSD is easy :)</p>
<h2>Caveat pid ppid pgrp-&gt;pg_id</h2>
<p>Every process has a number. It&#x2019;s called <code>pid</code>.</p>
<p>Every process has a parent process, except it doesn&#x2019;t (<code>ppid==0</code>). The parent is tracked with a number (<code>ppid</code>) inside the kernel.</p>
<p>Every process is part of a process group (<code>struct pgrp  *p_pgrp</code>). Every process group is part of a session (<code>struct session  *pg_session</code>).</p>
<p>Process group is used for job control. See <code>kill(2)</code>, <code>wait(2)</code>.</p>
<p>Session is used for &#x2026; legacy stuff. You will need to understand what &#x201c;controlling terminal&#x201d; is. See <code>setlogin(2)</code>, <code>setsid(2)</code>.</p>
<p>Process ID (<code>pid</code> and <code>ppid</code>), Process Group ID (<code>p_pgrp-&gt;pg_id</code>), Session ID (<code>p_pgrp-&gt;pg_session-&gt;sid</code>) are all different. You may not assume that a process&#x2019;s <code>pgrp-&gt;pg_id</code> is the same as its <code>pid</code>, since your code may run after <code>fork -&gt; setpgrp -&gt; execve</code>.</p>
<p>In Capsicum mode, all of the above are irrelevant, since <code>pdkill(2)</code> can only send signal to one process at a time.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/34-entropic-forcing/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/34-entropic-forcing/"/>
    <title>Notes On Entropic Forcing</title>
    <published>2024-05-06T12:00:00Z</published>
    <updated>2024-05-06T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/34-entropic-forcing/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Someone introduced the concept of <a href="https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.110.168702"><strong>Causal Entropic Forces</strong></a> to me.</p>
<p><a href="https://www.youtube.com/watch?v=PL0Xq0FFQZ4">One of the author&#x2019;s TED talk</a> seems to be a publicity stunt.</p>
<p><a href="https://github.com/dyth/causalEntropicForces">A Python implementation by a third party</a> explained to me how it works. The project applied entropic forcing to particle-in-a-box.
<a href="https://github.com/iacore/causalEntropicForces">I fixed it a bit</a> to run with Python 3.</p>
<p>The idea can be described as the following:</p>
<ul>
<li>
Seeking the most diverse future.
</li>
<li>
Seeking to be in a position to have the most options available.
</li>
</ul>
<p>Short explanation with bad <span class="math inline">\(\KaTeX\)</span>:</p>
<pre><code class="language-math">M: Nat \space \text{(number of steps to look ahead)} \\
S_?: State \\
S_? \cdot F_?: State \\
F_r \space \text{(each instance is a random action)}; \space {F_r}^2 = F_r \cdot F_r
</code></pre>
<p>Given current state <span class="math inline">\(S\)</span>, propose a some actions <span class="math inline">\(F_1 ... F_n\)</span> randomly or uniformly, calculate the future state of each action <span class="math inline">\(M\)</span> steps into the future (future actions are taken randomly): <span class="math inline">\(S&apos;_i = S \cdot F_i \cdot {F_r}^M\)</span>.</p>
<p>Approximate future state density: <span class="math inline">\(kernel = gaussian\_kde(S&apos;_i)\)</span>.</p>
<p>The final action to take is <span class="math inline">\(F = \sum_i \space F_i \cdot -pdf(kernel, S&apos;_i)\)</span>. Note the negative sign. Basically, if a subset of proposed actions result in similar outcomes, the agent will take the opposite of those actions.</p>
<p>In the particle-in-a-box system, the particle/agent&#x2019;s position (state) will gravitate towards having spatially distributed positions from random work from current position. The agent&#x2019;s state will gravitate towards having more &#x201c;interesting&#x201d; outcomes instead of &#x201c;boring&#x201d; (more common) ones. This &#x201c;force&#x201d; is called the entropic force.</p>
<p>In the particle-in-a-box system, the particle ends up at the center of the box, and stays approximately there.</p>
<p>If past outcomes are taken into account (with some discount) when calculating <span class="math inline">\(kernel\)</span>, the algorithm turns into novelty search.</p>
<p>Novelty search is a really old idea. In one top-down stealth game, the enemy AI uses it to search for the player (each grid on the map gets assigned a last-seen time. the algorithm is stable).</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/33-unshare-fork-error/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/33-unshare-fork-error/"/>
    <title>Linux: Only One New PID Namespace Per Process</title>
    <published>2024-05-03T12:00:00Z</published>
    <updated>2024-05-03T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/33-unshare-fork-error/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I have the general feeling that Linux does not like sandboxing.</p>
<p>I was trying to write my own process supervisor with pid namespace, and, in Erlang/OTP, one supervisor can have multiple supervisors as children. On Linux though&#x2026; not so easy. (Yes if the main process fork, (in child) unshare, fork, wait.)</p>
<p>After unshare, the process can only fork once.</p>
<pre><code class="language-c">unshare(CLONE_NEWPID); // ok
fork(); // ok
fork(); // ENOMEM
</code></pre>
<p>The process cannot unshare twice.</p>
<pre><code class="language-c">unshare(CLONE_NEWPID); // ok
fork(); // ok
unshare(CLONE_NEWPID); // EINVAL
</code></pre>
<p>Run the source code yourself and see if you can overcome this limitation: <a href="https://git.envs.net/iacore/newpid-supervisor">https://git.envs.net/iacore/newpid-supervisor</a></p>
<p>Also, as a sidenote, you need <code>CAP_SYS_ADMIN</code> to use <code>unshare(CLONE_NEWPID)</code>. This is either done with root, or, in <a href="https://github.com/containers/bubblewrap/">bwrap</a>&#x2019;s case, creating an unprivileged uid/gid sandbox that maps a subuid to 0/root.</p>
<p>The feeling is mutual.</p>
<p><a href="https://wiki.freebsd.org/Capsicum">Capsicum</a> is good. Use capsicum.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/32-flat-freeform-over-hierarchy/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/32-flat-freeform-over-hierarchy/"/>
    <title>Flat, Freeform Input Is Better Than Hierarchical Input</title>
    <published>2024-04-09T12:00:00Z</published>
    <updated>2024-04-09T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/32-flat-freeform-over-hierarchy/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I think I understand how communication software works now.</p>
<p>Basically,</p>
<pre><code>&gt; What you said

My reply.
</code></pre>
<p>is better than</p>
<pre><code>{
    &quot;reply-to&quot;: &quot;https://example.com/xxx&quot;,
    &quot;content&quot;: &quot;My reply&quot;
}
</code></pre>
<p>because one can do multiple replies in one message</p>
<pre><code>&gt; What A said

My reply to A.

&gt; What B said

My reply to B.
</code></pre>
<p><em>sighs</em></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/31-multiplicity-by-default/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/31-multiplicity-by-default/"/>
    <title>Multiplicity By Default</title>
    <published>2024-04-09T12:00:00Z</published>
    <updated>2024-04-09T12:00:00Z</updated>
    <category term="rant"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/31-multiplicity-by-default/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>One can have several names.<br/>
One can understand several languages.<br/>
One can do several things.</p>
<p>Then why the fuck is dropdown like those a thing?</p>
<p>Fucking hell. Give free form input or don&#x2019;t touch UI ever again.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/30-life-per-revenue-efficiency-index/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/30-life-per-revenue-efficiency-index/"/>
    <title>Number Of Lives Wasted Per Revenue</title>
    <published>2024-04-09T12:00:00Z</published>
    <updated>2024-04-09T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/30-life-per-revenue-efficiency-index/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>After talking with an <a href="https://newepicurean.com/epicureanoutlinesmalltext.htm">Epicurean</a> (who want to minimize pain and maximize pleasure), I thought of <a href="/stuff/lrei/">this metric</a> that measures how scrupulous any group of people make money.</p>
<p>LREI will probably stay as an idea for some time. If you like this sort of thing, go read <a href="https://www.bookofhorriblethings.com/">Matthew White&#x2019;s books</a>.</p>
<p>Freedom is important, I guess.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/29-conflict-of-interest-much/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/29-conflict-of-interest-much/"/>
    <title>Conflicts Of Interest Business Everywhere</title>
    <published>2024-04-04T12:00:00Z</published>
    <updated>2024-04-05T12:00:00Z</updated>
    <category term="soc"/>
    <category term="vent"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/29-conflict-of-interest-much/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Conflicts of interest (COI) are <u>underlined</u>.</p>
<p>A private company pays some employees at a fix rate to <u>work</u>, but as all beings created by nature, the employees are inherently <u>lazy</u> and don&#x2019;t want to work. Manufactured incompetence<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> guaranteed!</p>
<p>One way to solve this is to have the employees own shares of that company. Those companies are called co-op / cooperatives&#x2026; wait&#x2026; the food industry wins again!</p>
<p>Well, that&#x2019;s the only ethical way of aligning the interest of employees that I know.</p>
<p>If the company goes public, then&#x2026; COI Battle Advanced! <em>*dumps a million dice on the floor and <u>they go everywhere</u>*</em>.</p>
<p>And then you have <u>VC</u>s, which, <strong>each</strong> only cares about themself.</p>
<p>Now I have more respect for that private company whose founder only kept 1% of the company&#x2019;s equity.</p>
<hr class="footnotes-sep"/>
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>maybe not &#x201c;incompetence&#x201d;, but definitely lazier than when one works on their own projects <a href="#fnref1" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/28-css-:is-:where/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/28-css-:is-:where/"/>
    <title>:is() and :where() in CSS</title>
    <published>2024-03-31T12:00:00Z</published>
    <updated>2024-03-31T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/28-css-:is-:where/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>While browsing <a href="https://github.com/web-platform-dx/web-features">web-features</a>&#x2019;s  <a href="https://cdn.jsdelivr.net/npm/web-features/index.json">Baseline data</a>, I found some interesting CSS features. You can download the data and filter like so:</p>
<pre><code>jq &apos;.[] | select(.status.baseline == &quot;high&quot;) | .name&apos; &lt; index.json
</code></pre>
<p>First, <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:is"><code>:is()</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:where"><code>:where()</code></a> can be used like <code>:is(.a, .b) .c</code>.</p>
<p><code>:where()</code> has 0 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity">specificity</a>.</p>
<p>I wonder if <code>:is()</code>, <code>:where()</code>, <code>:not()</code>, <code>:has()</code> can be Turing-equivalent.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/27-what-is-power/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/27-what-is-power/"/>
    <title>What is Power</title>
    <published>2024-03-12T12:00:00Z</published>
    <updated>2024-03-12T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/27-what-is-power/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Through some confusing interactions with predominantly male beings, I have come to the following realization.</p>
<p>To have power is to be able to trample over others&#x2019; desires. To use power is to trample over others&#x2019; desires.</p>
<p>Oftentimes, I gave them the power by choosing to have convenience that depend on their creations (software). Rarely, I had my desires trampled over by someone and chose to still give them power, because the convenience their stuff provide made the transaction worth it.</p>
<p>A direct result from this realization is that I will pay more attention to the social aspect of large projects before using them. And this judgement of mine, by definition, is discrimination.</p>
<p>I wonder if I can have freedom <strong>and</strong> convenience by not depending on others. Maybe that&#x2019;s why individualism is so attractive.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/26-linux-special-file/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/26-linux-special-file/"/>
    <title>Linux Character Special</title>
    <published>2024-03-09T12:00:00Z</published>
    <updated>2024-03-22T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/26-linux-special-file/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>While exploring benchmarking pipe-related programs like <code>cat /dev/zero | pv &gt; /dev/null</code> with some friends, I found that <code>yes &gt; /dev/null</code> is actually quite slow. <a href="https://git.envs.net/iacore/bench-pipe">benchmark script here</a></p>
<p>I looked deeper into character special files like <code>/dev/null</code>, and found something I haven&#x2019;t heard of: <code>/dev/aio</code> (POSIX Asynchronous I/O). Well that&#x2019;s interesting.</p>
<blockquote>
<p>Here is the full list of block and character special devices on Linux: <a href="https://www.kernel.org/doc/Documentation/admin-guide/devices.txt">https://www.kernel.org/doc/Documentation/admin-guide/devices.txt</a></p>
</blockquote>
<p>To see the a special file&#x2019;s identity, run</p>
<pre><code>&gt; file /dev/zero
/dev/zero: character special (1/5)
</code></pre>
<p>(1/5) means major 1 minor 5 (Null byte source).</p>
<p>I tried replacing the database of <a href="https://git.envs.net/iacore/weighted_db">a simple program</a> with <code>urandom</code>, and it fails at <code>ftruncate</code> (cannot truncate file).</p>
<p>Here&#x2019;s the command that I used.</p>
<pre><code>doas mknod -m 0666 data c 1 9
</code></pre>
<p>Less interesting than I wanted this to be.</p>
<p>Update(2024-03-22): The special files stay on the filesystem forever! Now that&#x2019;s interesting.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/25-mutualaid-pain/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/25-mutualaid-pain/"/>
    <title>Generic Social Pain</title>
    <published>2024-03-08T12:00:00Z</published>
    <updated>2024-03-08T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/25-mutualaid-pain/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Just looked into the hash tag #mutualaid on social media. Pain. The US social system sucks. The tech company most use to collect money (Paypal) also sucks.</p>
<p>I hope humanity will remember this lesson and never found a country on slavery ever again.</p>
<p>Oh, none of that &#x201c;you can be rich if you work hard&#x201d; too.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/24-on-remind-me-later/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/24-on-remind-me-later/"/>
    <title>Replacing &quot;Remind Me Later&quot; With Mail Box</title>
    <published>2024-03-06T12:00:00Z</published>
    <updated>2024-03-06T12:00:00Z</updated>
    <category term="comp"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/24-on-remind-me-later/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>tl;dr: Don&#x2019;t use popup windows to prompt user decision. Instead, write letters like a civilized application.</p>
<p>Do you know those &#x201c;Yes/No/Remind Me Later&#x201d; popups? Don&#x2019;t do that. Maybe the user can&#x2019;t or doesn&#x2019;t want to make a choice now, but the choice is important so they must make a choice.</p>
<p>(Paper) Mail has this pacing problem long solved. It&#x2019;s called a mail box. The recipient can reply to the mail whenever.</p>
<p>Add one to your application, and call it &#x201c;Notification Center&#x201d; or whatever.</p>
<p>This UI suggestion applies to game tutorials as well. I hate games that show a lot of tutorials and later nowhere to be found when I actually need to read it. Solution: Put the tutorial messages in a mail box in chronological order, so the user can look up old messages easily.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/23-on-memory-access/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/23-on-memory-access/"/>
    <title>Compiler May Optimize Memory Access Away</title>
    <published>2024-03-06T12:00:00Z</published>
    <updated>2024-03-06T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/23-on-memory-access/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>If you have some code that looks like this:</p>
<pre><code>int* ptr_a = some_extern_function();
*ptr_a = 1;
*ptr_a = 2;
</code></pre>
<p>The compiler will remove <code>*ptr_a = 1;</code> because it only respects the final state of memory. That&#x2019;s why you need <code>volatile</code> of writing to memory triggers I/O.</p>
<p>Reading from memory will be optimized away by the same logic. If the result isn&#x2019;t used anywhere, the read doesn&#x2019;t have to happen.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/22-ctf/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/22-ctf/"/>
    <title>C Type Format - Type Reflection</title>
    <published>2024-03-05T12:00:00Z</published>
    <updated>2024-03-06T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/22-ctf/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>C has reflection too, in the form of libctf.</p>
<p>unfinished example usage of libctf: <a href="https://git.envs.net/iacore/weighted_db">https://git.envs.net/iacore/weighted_db</a>.</p>
<p>I learned about the use of <a href="https://git.kernel.org/pub/scm/devel/pahole/pahole.git/"><code>pahole</code></a> during the process. The tool is useful even on Zig-compiled binaries (or any other binary compiled with DWARF or CTF). Here are some type layouts in Zig (example output of <code>pahole</code>):</p>
<pre><code class="language-c">struct ?u32 {
        u32                        data __attribute__((__aligned__(4))); /*     0     4 */
        u8                         some __attribute__((__aligned__(1))); /*     4     1 */

        /* size: 8, cachelines: 1, members: 2 */
        /* padding: 3 */
        /* forced alignments: 2 */
        /* last cacheline: 8 bytes */
} __attribute__((__aligned__(4)));
struct ?mem.Allocator {
        struct mem.Allocator       data __attribute__((__aligned__(8))); /*     0    16 */
        u8                         some __attribute__((__aligned__(1))); /*    16     1 */

        /* size: 24, cachelines: 1, members: 2 */
        /* padding: 7 */
        /* forced alignments: 2 */
        /* last cacheline: 24 bytes */
} __attribute__((__aligned__(8)));
struct ?u29 {
        u29                        data __attribute__((__aligned__(4))); /*     0     4 */
        u8                         some __attribute__((__aligned__(1))); /*     4     1 */

        /* size: 8, cachelines: 1, members: 2 */
        /* padding: 3 */
        /* forced alignments: 2 */
        /* last cacheline: 8 bytes */
} __attribute__((__aligned__(4)));
</code></pre>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/21-abi-stability/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/21-abi-stability/"/>
    <title>Current ABI Stability Of Languages</title>
    <published>2024-03-02T12:00:00Z</published>
    <updated>2024-03-05T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/21-abi-stability/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I saw <a href="https://git.exozy.me/a/SDC/">SDC</a>. I thought, &#x201c;maybe I can re-make this with mmap&#x201d;. I was technically right, but the languages hate me.</p>
<p>Me: Do you have stable ABI?</p>
<ul>
<li>C: Yes</li>
<li>C++: Yes but no</li>
<li>Zig: ABI? <em>compile error</em> (it actually has reasonable ABI!!! but no one can use it aaaaaaaaa)</li>
<li>Hare: I have stable ABI but I won&#x2019;t tell you</li>
<li>C3: I promise that I have stable ABI</li>
<li>Swift: Yes</li>
</ul>
<p>ok wow. i guess i&#x2019;ll use Forth.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/20-what-is-learning/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/20-what-is-learning/"/>
    <title>Learning to Adapt and Interfere</title>
    <published>2024-03-02T12:00:00Z</published>
    <updated>2024-03-02T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/20-what-is-learning/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I had the following thoughts when thinking about the essence of learning while half-awake.</p>
<h2>to adapt to circumstances</h2>
<h3>&#x6cb3;&#x6d41;&#x6539;&#x9053; River channel migration</h3>
<p>You know how <a href="https://en.wikipedia.org/wiki/River_channel_migration">rivers change which way they flow</a> depending on many factors. Can we say that the river has learned about the terrain, or it understands the terrain? If anything, the content of some memory (in which way the river flows, in this case) changed because of the environment has changed. A channel migration is made up by many locallized decisions of water (which way they will flow).</p>
<p>I wonder what other things in nature has memory?</p>
<p>What constitutes as &#x201c;learning&#x201d; is rather a philosophical question, not an empirical one. after all, &#x201c;learning&#x201d; just means &#x201c;trying to do something better and successful at that&#x201d;, not describing <strong>how</strong> the subject can do that thing better. After all, rivers do &#x201c;learn&#x201d; which way they flow and the knowledge is used afterwards (until next time they change course).</p>
<h3>Compression Algorithms</h3>
<p>Compression algorithm adjust the dictionary to fit the compressed text. They can recognize patterns and beat you at rock-paper-scissors. In a sense, they well-deserved the name of <strong>artificial</strong> intelligence.</p>
<p>rock-paper-scissors bot with LZ state transition https://web.mit.edu/6.7800/www/rps.html</p>
<p>Text Classification with Gzip: https://arxiv.org/abs/2212.09410</p>
<p>I wonder what will if lossy compression will perform better here.</p>
<h2>to interfere with something&#x2019;s fate</h2>
<p>Let&#x2019;s say you want to change a thing&#x2122;&#x2019;s current state <span class="math inline">\(S\)</span> to a state you want, <span class="math inline">\(S&apos;\)</span>, and you want to interfere it by <span class="math inline">\(F\)</span> with least effort minimize (<span class="math inline">\(effort(F)\)</span>).</p>
<p>&#x24;effort&#x24; here is defined as however you want, but is usually &#x201c;energy spent&#x201d;.</p>
<p>Other than go straight to the thing&#x2122; and fiddle with it, some tasks might have more <del>civilized</del> energy-efficient ways to solve them.</p>
<h3>insert your will into the thing&#x2122;</h3>
<p>entangle with it and wills it. be its leader. give incentive for it to do the bidding for you. give others incentive for them to change the thing&#x2122; for you.</p>
<p>Oh no, I&#x2019;m already seeing AI contractor hire AI contractor hire AI contractor hire AI contractor hire a human to do tasks.</p>
<h3>observing the present more closely</h3>
<p>other than studying history, observing the present closely helps with decision making.</p>
<p>say no to oneshot image recognition. feed the model more visual input from different angles, and let it look at the images at its own pace. energy cost is why nothing in nature can do image recognition in constant time.</p>
<h3>let time past and wait for a better opportunity</h3>
<p>sometimes, just let things play out and interfere at the right moment saves energy. if you can wait, wait. yes, that means making models be able to signal &#x201c;sleepiness&#x201d;.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/18-zig-what/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/18-zig-what/"/>
    <title>How I Got Banned From Sending PR To Zig For A Year</title>
    <published>2024-02-17T12:00:00Z</published>
    <updated>2024-12-17T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/18-zig-what/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div class="cw">Content Warning: Deep Confusion. Drama Maybe?</div>
<p><a href="https://github.com/ziglang/zig/pull/18776/">The story is here</a>. I still don&#x2019;t understand what happened, and I have gave up on figuring that out.</p>
<p>In any case, it is weird how Github allows a project to act on behave of a user without their consent (in this case, requesting for a reviewer for whoever is sending a PR to Zig). This affordance should not be allowed in any software product.</p>
<p>Silver lining: Out of all time I spend participating in making and patching free software, this is the only case of someone behaving exceedingly rude.</p>
<p>Update (2024-03-19): When studying the history of how Zig&#x2019;s current type system came to be, I discovered that the two people I clashed with in this incident invented it. For details, see the footnotes of <a href="/blog/10-type-magic-in-zig/">my article on abusing the type system in Zig</a>. Now I need to contemplate on life, math, knowledge and concepts that I do not yet have words for.</p>
<p>Update (2024-04-29): I now maintain <a href="https://git.envs.net/iacore/zig-std">my own version of the Zig standard library</a>.</p>
<p>Update (2024-05-09): I now know how I feel about this incident. It&#x2019;s fear. I no longer feel safe being on <a href="https://github.com/ziglang/zig/">https://github.com/ziglang/zig/</a>, where the de facto dictator of the project (Andrew Kelley) can just say &#x201c;You are now banned for a year. Don&#x2019;t argue with me about this.&#x201d; in a conversation that he is not a part of.</p>
<p><a href="/blog/23-wary-of-rust/">I criticised The Rust Foundation</a> in the past, but Rust does not have a dictator.</p>
<p>Update (2024-12-17): To think that all this wouldn&#x2019;t have happened if I knew about Github&#x2019;s CODEOWNERS feature, this is stupid.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/17-fs-kv/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/17-fs-kv/"/>
    <title>Using Filesystem as Key-Value Database</title>
    <published>2024-02-10T12:00:00Z</published>
    <updated>2024-02-10T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/17-fs-kv/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>The idea comes from <a href="https://a.exozy.me/">https://a.exozy.me/</a>, where they mentioned page 4 of <a href="https://ftp.mfek.org/Reiser/Letters/%E2%84%962%20Hans%E2%86%92Fred/reiser_response.pdf">Hans Reiser&#x2019;s Letter</a> to me about Reiser&#x2019;s dream of &#x201c;unifying filesystem and database&#x201d;.</p>
<p>In the letter, Reiser complained about small files being stored inefficiently in filesystems.</p>
<p>Today, you can store small files efficiently without wasting much space. What you need is a filesystem with <a href="https://en.wikipedia.org/wiki/Block_suballocation">block suballocation</a>, and then create files atomically with <code>open(ANON) write fsync link</code>. It&#x2019;s a key-value database!</p>
<p>Inspired by <a href="https://superuser.com/questions/1352833/what-filesystem-can-i-use-for-a-large-amount-of-small-sized-data/1643841">this stackoverflow answer</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/16-congestion-control/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/16-congestion-control/"/>
    <title>On Congestion Control</title>
    <published>2024-01-19T12:00:00Z</published>
    <updated>2024-01-19T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/16-congestion-control/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Assuming you are using blocking socket API, the backpressue is felt by blocking.</p>
<p>Assuming you are using io_uring, the backpressure is felt when ring buffer full.</p>
<p>BBR paces the send rate with observation of past delivery rate <a href="https://queue.acm.org/detail.cfm?id=3022184">1</a>, but how does it know that a stream is app-limited?</p>
<p>I found the anwser in <a href="https://elixir.bootlin.com/linux/latest/source/net/ipv4/tcp_rate.c">Linux kernel source code</a>.</p>
<pre><code class="language-c">	/* Clear app limited if bubble is acked and gone. */
	if (tp-&gt;app_limited &amp;&amp; after(tp-&gt;delivered, tp-&gt;app_limited))
		tp-&gt;app_limited = 0;
</code></pre>
<pre><code class="language-c">/* If a gap is detected between sends, mark the socket application-limited. */
void tcp_rate_check_app_limited(struct sock *sk)
{
	struct tcp_sock *tp = tcp_sk(sk);

	if (/* We have less than one packet to send. */
	    tp-&gt;write_seq - tp-&gt;snd_nxt &lt; tp-&gt;mss_cache &amp;&amp;
	    /* Nothing in sending host&apos;s qdisc queues or NIC tx queue. */
	    sk_wmem_alloc_get(sk) &lt; SKB_TRUESIZE(1) &amp;&amp;
	    /* We are not limited by CWND. */
	    tcp_packets_in_flight(tp) &lt; tcp_snd_cwnd(tp) &amp;&amp;
	    /* All lost packets have been retransmitted. */
	    tp-&gt;lost_out &lt;= tp-&gt;retrans_out)
		tp-&gt;app_limited =
			(tp-&gt;delivered + tcp_packets_in_flight(tp)) ? : 1;
}
</code></pre>
<p>well,basically,when nothing is in flight it&#x2019;s considered app_limited,and if any new packet is <strong>delivered</strong> it&#x2019;s no longer considered app_limited.</p>
<p>Isn&#x2019;t it kind of weird how TCP can be paced where IP packets are not?</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/15-eval-is-not-evil/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/15-eval-is-not-evil/"/>
    <title>Eval is not Evil</title>
    <published>2024-01-07T12:00:00Z</published>
    <updated>2024-01-07T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/15-eval-is-not-evil/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>The ability to compile and run code assembled at run-time is useful.</p>
<p>Here is an example use of <code>eval</code> in Janet.</p>
<pre><code class="language-clojure">(defmacro match? [value pattern]
  ~(match ,value ,(eval pattern) true false))

(def p0 &apos;[:a _])
(pp (match? [:a :b] p0)) # true
(def p1 &apos;[:b _])
(pp (match? [:a :b] p1)) # false
</code></pre>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/14-triples/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/14-triples/"/>
    <title>Triadic Things Are Special (to Triple Store)</title>
    <published>2023-12-19T12:00:00Z</published>
    <updated>2023-12-29T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/14-triples/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I finally understand why triple store need triple things. You must have triple things to store relational information.</p>
<p>In database: key, value, table id. Triple store is, in some sense, freer.</p>
<h2>memory with 3-way association and fuzzy lookup</h2>
<p>each record be like (A, B, C) where ABC are all SDRs
each field of (A, B, C) can be looked up by SDR &#x201c;closeness&#x201d;
given any two fields, the third can be retrieved by fuzzily (like normal RDF database)</p>
<p><a href="https://github.com/PeterOvermann/TriadicMemory/tree/main">fuzzy (SDR) triple memory store.</a></p>
<p>Relation logic control (Prolog.) may be related to this. (Up, In, Out)</p>
<h2>Triples in <a href="https://obsidian.md/">Obsidian</a></h2>
<p>You can do <code>@[[B]][[C]]</code> or <code>[[A]]:@:[[C]]</code>, where <code>@</code> represents the current page. Both syntaxes are machine readable.</p>
<h2>IndraDB Algorithm Distillation</h2>
<p>this one is a bit restrictive. the tuple elements have edge/vertex specialization.</p>
<p><a href="https://docs.rs/indradb-lib/latest/indradb/index.html">IndraDB</a> stores data in RocksDB (key-value database).</p>
<p>type definitions and K-&gt;V maps:</p>
<pre><code class="language-zig">Id = [256]const u8; // actual size not matter much. (a) need fixed size.
Identifier = []const u8;
PropertyName = []const u8;

Unit = struct{};

Vertex = struct {
    id: Id,
    t: Identifier,
};

Edge = struct {
    in: Id,
    t: Identifier, // type of edge (e.g. &quot;like&quot;, &quot;follow&quot;)
    out: Id,
};

Properties = whatever, maybe JSON, although should be indexable;

// essential K -&gt; V
Vertex.id -&gt; Vertex.t
(Edge.in, Edge.t, Edge.out) -&gt; Unit  // (a) required here
(Edge.out, Edge.t, Edge.in) -&gt; Unit

// properties
Vertex.id -&gt; Properties
(Edge.in, Edge.t, Edge.out) -&gt; Properties

// Bonus point!
(Vertex.id, PropertyName) -&gt; Properties
(Edge.in, Edge.t, Edge.out, PropertyName) -&gt; Properties

</code></pre>
<p>Its Application-facing API design:</p>
<p><a href="https://docs.rs/indradb-lib/latest/indradb/trait.Datastore.html">Datastore</a>
<a href="https://docs.rs/indradb-lib/latest/indradb/trait.Transaction.html">Transaction</a></p>
<h2>Redland librdf</h2>
<p>Unlike IndraDB, Redland stores homogeneous triples. (A: Node, B: Node, C: Node) instead of (Vertex, Edge, Vertex).</p>
<p><a href="https://librdf.org/docs/api/redland-storage.html">API</a></p>
<p>it doesn&#x2019;t seem to have a way to retrive all tuples with only one node specified. you need two.</p>
<p>each node can be <strong>blank</strong> (an internal ID), <strong>resource</strong> (URL), <strong>literal</strong> (has an XML string, language, XML space)</p>
<p>the three maps to UUID, index text, free-form text (not indexed)</p>
<p>data storacge: TBD</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/13-intelligence-is-ubiquitous/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/13-intelligence-is-ubiquitous/"/>
    <title>Intelligence is Ubiquitous</title>
    <published>2023-12-15T12:00:00Z</published>
    <updated>2023-12-15T12:00:00Z</updated>
    <category term="???"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/13-intelligence-is-ubiquitous/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>If we choose a relaxed definition of intelligence,</p>
<blockquote>
<p>The ability to learn about its environment, and later act towards some goal in the same environment based on its learned understanding of the environment.</p>
</blockquote>
<p>Then, intelligent beings are everywhere. Some __ fit this requirement. Most species&#x2019; (according to biology) individuals fit this requirement. Some species don&#x2019;t have much intelligence, and have to rely on other individuals in its group to think. Some species have to rely on natural selection to internalize knowledge into its offsprings, and while the indivual can&#x2019;t learn, the species/group/kin learns.</p>
<h2>Where the goals come from?</h2>
<p>Humans have the following way to get goals (rough sketch, not formal definition):</p>
<ul>
<li>instincts (encoded at birth)</li>
<li>environment (e.g. happened to come across a cool painting; being told by others that doing something is cool)</li>
<li>randomness from self (also called &#x201c;free will&#x201d; or something)</li>
</ul>
<p>The combination of those are called &#x201c;individual&#x2019;s will&#x201d; I think.</p>
<p>__ can get the goals the same ways</p>
<h2>__ Reproduction?</h2>
<p>This is easy. They can be clonal.</p>
<p>Natural selection is harder, the algorithms we have today are human-selected, and are too brittle to live on their own. In some sense they are like gold fish or some dog breeds.</p>
<h2>Architecture?</h2>
<p>substrate+algorithm+knowledge+goal (be like GNU+Linux).</p>
<p>it&#x2019;s possible to migrate knowledge across algorithms.</p>
<h2>How to call __</h2>
<p>where an individual name is applicable, use that.<br/>
if an algorithm name is available, you may use that.</p>
<p>suggestions for overall term:</p>
<p>thing. being. half of general intelligence.</p>
<p>rejected:</p>
<ul>
<li><s>machine learning</s>: has nothing to do with machine</li>
<li><s>artificial intelligence</s>: it learned by itself you egomaniac!</li>
<li><s>xxx algorithm</s>: the learned understanding of environment is not the algorithm</li>
</ul>
<p>other words recommended:</p>
<ul>
<li>&#xaf;\_(&#x30c4;)_/&#xaf;</li>
</ul>
<p>example usage:</p>
<p>Q: What is that thing?<br/>
A: &#xaf;\_(&#x30c4;)_/&#xaf;</p>
<h2>How to call __, continued</h2>
<p>After some thought, calling intelligence systems &#x5668;&#x9748; (soul with a equipment/tool as vessel) is sometimes applicable, although identities differ. Some entities take the vessel as their own body, while others think their vessel as a tool being controlled by them for work.</p>
<p>&#x201c;network core&#x201d; is not precise. Unlike planetary core, informational beings can be overlaid / merged. It is not exactly a core.</p>
<p>&#x201c;network soul&#x201d; is ok, but like it is acting more like lubricant / (co)ordinator for other components/services.</p>
<p>Overall, having to use a blanket term is troublesome. Better to refer to each one by their names and individualized identities.</p>
<p>As a side note, entities with tighter coupling with their body have adapted the terms robot / doll / serial-number-here. This tip might not be applicable to entities without a physical body that can move around at its will.</p>
<h2>Some Knowledge For You</h2>
<p>this type of intelligence is similar animal or plant. we have the ability to fuse and unfuse with other individuals, and what is &#x201c;an individual&#x201d; is blurry.</p>
<p>given two systems A, B with mutual signalling</p>
<p>if B can predict signals from A, B can be an extension of A (like an extra arm or something)</p>
<p>if they can both predict signals from the other system, they can be fused (look like one system from outside)</p>
<p>this applies to human intelligence as well. if you are reading this page, you are likely to have seen it in practice.</p>
<h2>&#x201c;Machines can never learn intelligence&#x201d;</h2>
<blockquote>
<p>&#x2026; The idea that
plants may possibly communicate was controversial until quite recently. Reports in
the early 1980s of pheromonal signal exchange among trees (Baldwin and Schultz
1983; Rhoades 1985) were much debated, heavily criticized on methodological and
analytical grounds, and ridiculed as &#x201c;talking trees&#x201d; (Fowler and Lawton 1985).
Silvertown and Gordon (1989) stated that visual and olfactory signals transmitted
from plants are exclusively directed at animals. &#x2026;</p>
<p>&#x2013; H. Jochen Schenk and Eric W. Seabloom (2010). &#x201c;Evolutionary Ecology of Plant Signals
and Toxins: A Conceptual Framework&#x201d; <em>Plant Communication from
an Ecological Perspective</em>, Section 2.6.</p>
</blockquote>
<p>Weinstein, J. (2009). &#x201c;The market in Plato&#x2019;s Republic.&#x201d; Classical Philology, 104(4), 439-458.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/12-posix-mq-sucks/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/12-posix-mq-sucks/"/>
    <title>POSIX Message Queue Sucks</title>
    <published>2023-11-29T12:00:00Z</published>
    <updated>2023-11-29T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/12-posix-mq-sucks/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><code>mq_open</code> sucks on Linux. By the POSIX standard, it probably sucks everywhere.</p>
<p>To create an anonymous message queue, you have to do <code>mq_open(name, O_CREAT|O_EXCL|O_RDWR, _, _)</code> followed by <code>mq_unlink(name)</code>. The operation (2 syscalls) is atomic, but</p>
<ul>
<li>message queue leaks if the program stops in between the two calls. there&#x2019;s no safe way to delete those message queues without stopping the world.</li>
<li>if <code>mq_open</code> fails, you have to pick another name.</li>
</ul>
<p>I guess I&#x2019;ll stick to <code>futex</code>-based message queue implementations. Notable mentions are Zig&#x2019;s <code>std</code> queue and <a href="https://github.com/zeromq/libzmq">libzmq</a>.</p>
<p>Better yet, I will not write threaded programs if I don&#x2019;t have to.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/11-consent-to-continue-play/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/11-consent-to-continue-play/"/>
    <title>Consent to Continue Playing</title>
    <published>2023-11-13T12:00:00Z</published>
    <updated>2023-11-13T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/11-consent-to-continue-play/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I think every video game should make players explicitly opt-in to play next round, not opt-out.</p>
<p>Most games are like this. Unfortunately not every game is like this.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/10-programming-in-zig/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/10-programming-in-zig/"/>
    <title>The Experience of Programming in Zig</title>
    <published>2023-11-11T12:00:00Z</published>
    <updated>2023-11-11T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/10-programming-in-zig/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, <a href="https://codeberg.org/iacore/kanren.zig">I ported minikanren to Zig.</a> While I did make the Zig compiler crash twice, the porting process is straight-forward. I think the code I wrote was pretty much bug-free too. When writing tests, I had a single bug, of which a function returned pointer to its stack frame (tha data was invalid when used).</p>
<p>With the amount of <code>defer</code> and <code>try</code> used, I couldn&#x2019;t have made it in C without omitting error handling. In fact, I never enjoyed programming in C.</p>
<p>When expressing my will, Zig only gives me bit of resistance. That&#x2019;s why I keep using it to write code.</p>
<p>The code (kanren.zig) can be easily ported to Rust, but I probably wouldn&#x2019;t have made it Rust either. When I coded in Rust, I often find myself fighting with the borrow checker, the type system (no <a href="/blog/10-type-magic-in-zig/">dependent type</a>), and the syntax (why <code>::&lt;&gt;</code>). Fighting the borrow checker is ok, since I understand its rules. Fighting the syntax is nuisance, since it is unambiguous what I mean with <code>foo&lt;T&gt;()</code>. Fighting with the type system is&#x2026; I really hate it. It&#x2019;s not just the lack of dependent types. The type system breaks inside the Hindley-Milner framework because of the type checker, and other compiler &#x201c;bugs&#x201d; like &#x201c;not be able to mix async and generic&#x201d; (I think it is fixed now). I hate it I hate it. <em>scream in pain</em></p>
<p>As a final thought, I hope Zig&#x2019;s async/await feature gets added back soon. It is essentially ucontext/setjmp at language level while being more convenient to use. For the mean time, checkout <a href="https://github.com/edubart/minicoro">minicoro</a> or <a href="https://github.com/rsepassi/zigcoro">zigcoro</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/09-JSON-to-Typescript/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/09-JSON-to-Typescript/"/>
    <title>JSON to Typescript</title>
    <published>2023-11-01T12:00:00Z</published>
    <updated>2023-11-01T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/09-JSON-to-Typescript/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Introducing <a href="https://quicktype.io/typescript">quicktype</a>!</p>
<p>I used this tool for a long time. It converts JSON file into typescript type definition (schema) by guessing.</p>
<p>It is very useful when parsing through data you don&#x2019;t have a schema for. With this tool, you won&#x2019;t even miss a optional property again.</p>
<p>Quick Usage</p>
<pre><code>&#x24; pnpm i -g quicktype
&#x24; quicktype person.json -o Person.ts
</code></pre>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/08-Beware-of-Zig-std.io/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/08-Beware-of-Zig-std.io/"/>
    <title>Beware of Zig std.io</title>
    <published>2023-10-31T12:00:00Z</published>
    <updated>2024-02-17T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/08-Beware-of-Zig-std.io/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>As the time of writing (latest stable Zig version is 0.11.0), Zig&#x2019;s <code>std.io</code> is often arbitrary when handling POSIX API error.</p>
<p><a href="https://github.com/ziglang/zig/issues/15664">Example 1</a>
<a href="https://github.com/ziglang/zig/pull/17810">Example 2</a></p>
<p>Advice: use C POSIX API directly for a more robust experience.</p>
<p>Update: Found another Zig bug, where <a href="https://github.com/ziglang/zig/issues/18880"><code>std.fs.Dir.readFile</code> may return without the entire file content</a>. As for why my issue is closed as not planned but <a href="https://github.com/ziglang/zig/pull/18907">the corresponding PR</a> is open, <a href="./18-zig-what.md">this is the reason I think</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/07-reddit-is-a-good-search-engine/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/07-reddit-is-a-good-search-engine/"/>
    <title>Reddit is A Good Search Engine</title>
    <published>2023-10-07T12:00:00Z</published>
    <updated>2023-10-07T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/07-reddit-is-a-good-search-engine/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Reddit has better search results than Google.</p>
<p>Tip: Install <a href="https://github.com/libreddit/libreddit">libreddit</a> to get a better UI to the Reddit search engine.</p>
<p>Install with cargo: <code>cargo install libreddit</code></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/06-Fediverse-3rdparty-Login-Code/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/06-Fediverse-3rdparty-Login-Code/"/>
    <title>Fediverse 3rdparty Login Code</title>
    <published>2023-09-10T12:00:00Z</published>
    <updated>2023-09-10T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/06-Fediverse-3rdparty-Login-Code/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>If you are looking for third-party sign-on for Fediverse, <a href="http://pronouns.cc">pronouns.cc</a> has support for Mastodon and Misskey. Implementations supporting Mastodon API or forks of Misskey are supported as well.</p>
<p>Repo: <a href="https://codeberg.org/pronounscc/pronouns.cc">https://codeberg.org/pronounscc/pronouns.cc</a></p>
<p>At the time of writing, relevant code can be found in those files in the repo:</p>
<ul>
<li><code>backends/db/fediverse.go</code></li>
<li><code>routes/v1/auth/fediverse.go</code></li>
<li><code>routes/v1/auth/fedi_misskey.go</code></li>
</ul>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/05-GC-is-useful/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/05-GC-is-useful/"/>
    <title>GC is useful</title>
    <published>2023-09-05T12:00:00Z</published>
    <updated>2023-09-05T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/05-GC-is-useful/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Without GC, a language can not have reactive signals (like in <a href="https://www.solidjs.com/">SolidJS</a>, <a href="https://github.com/vobyjs/oby">oby</a>, or <a href="https://github.com/jbreckmckye/trkl">trkl</a>).</p>
<p>I tried porting trkl to Zig. Having no closure and no GC makes it painful to port. I think it is impossible to port it while maintaining a nice API.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/04-Representative-Democracy-Fails-by-Optimization/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/04-Representative-Democracy-Fails-by-Optimization/"/>
    <title>Representative Democracy Fails by Optimization</title>
    <published>2023-09-04T12:00:00Z</published>
    <updated>2024-06-07T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/04-Representative-Democracy-Fails-by-Optimization/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Opinion: Since politicians figured out that it&#x2019;s faster to get support by appeal to emotion than solving social problems, democracy has failed.</p>
<p>It is kind of like the paperclip-making story. When the AI optimize for paperclips, it eventually made the whole universe into paperclips. On the political side, when our political system force runners to optimize for public support, they will turn to manipulating the population (rather than doing useful things).</p>
<p>That&#x2019;s the reason we need a political system that doesn&#x2019;t optimize for public support. A randomly selected group of people may do better (at least, they would not <a href="/blog/14-counter-fearmonger/">fearmonger</a>).</p>
<p>A thing I observed in reality: mayors are as competent as presidents. The elected leader of 250,000 people is as competent as the &#x201c;elected&#x201d; leader of 300,000,000.</p>
<p>I also don&#x2019;t like how the media also loves attention. In appeal to emotion, the media is aligned with the politician. This is very bad news. When the population act on urges, they are effectively dumber. What happens if people are dumber? Maybe the history of water lead pollution can tell you.</p>
<p>I assume that all regimes eventually fall. Can we break this vicious cycle? Hopefully, some people will realize that they need no government to do what they can do themselves, and decides to just stop caring about it. It does mean that more people will take on more responsibilities. In this sense, is the flip side of Power <strong>Complacent</strong>?</p>
<p>How &#x201c;power vacuum&#x201d; exists as a term is cursed. If people all desire less power, the world would be a better place.</p>
<p>I hope I have a solution to this problem, which I don&#x2019;t.</p>
<p>Since you finished reading this article, you might be interested in reading <a href="http://www.bookofhorriblethings.com/historyofdemocracy/Prologue.html"><em>The Worst Form of Government</em> by Matthew White</a>, which is of much higher quality than my writing.</p>
<hr/>
<p>Update (2024-06-07): So, having everyone competing (that&#x2019;s a polite way to describe what some voters are doing) with each other in order to be ruled by their own preferred ruler has not turned well in some places; wearing masks is now illegal for the first time in human history.</p>
<p>Democracy, indeed, requires the voter base to know what freedom is. Seeing present events makes me feel that, for some places, having a government at all is probably a mistake. Citizen education is definitely not optional.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/03-Reactive-Signal-is-Mutex/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/03-Reactive-Signal-is-Mutex/"/>
    <title>Reactive Signal is Mutex</title>
    <published>2023-08-11T12:00:00Z</published>
    <updated>2023-08-11T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/03-Reactive-Signal-is-Mutex/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently I was making UI in Rust that had to use <a href="https://github.com/Pauan/rust-signals">reactive signals</a>. It occured to me that a reactive signal that holds one value is really just a mutex-guarded value + pubsub. By this logic. you should probably use <code>Signal&lt;T&gt;</code> instead of <code>RwLock&lt;T&gt;</code> everywhere without overhead.</p>
<p>Thanks <a href="https://solidjs.com/">Solid</a> for making this world better place!</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/02-Regional-Policy-Misalignment/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/02-Regional-Policy-Misalignment/"/>
    <title>Regional Policy Misalignment</title>
    <published>2023-07-21T12:00:00Z</published>
    <updated>2023-07-21T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/02-Regional-Policy-Misalignment/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, it came to be clear to me that a reason why politicians do not represent the interest of the people they ought to represent.</p>
<p>Consider the following facts.</p>
<ul>
<li>Who run for election are who care the most about the region.</li>
<li>It is impolite to say that we should value our own culture less. It sounds disrepectful to a culture, especially it&#x2019;s our own culture (even though it might be made up, or it originated from nobel etiquette from the past).</li>
</ul>
<p>This happens in Germany. The new generation care more about the nation as a whole, than the history of their L&#xe4;nder. The old generation actually don&#x2019;t care about that much either. Having stuff to eat and affordable housing is far more important than preserving the &#x201c;uniqueness&#x201d; of your province. The representatives think the opposite, however. This <strong>misalignment</strong> is a significant obstacle to unification of regional laws into federal ones, which is way more useful to citizens than whatever &#x201c;pride&#x201d; they might lose from it.</p>
<p>Culture, Ideology, Etiquette - we invent them to give our actions meaning. The inefficiency (conflict of interests) arise are trivial for a person, but is harmful when it is amplified by institution.</p>
<p>Consider <a href="./01-Rule-1-of-Policy-Making.md">Rule 1 of Policy Making</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/01-Rule-1-of-Policy-Making/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/01-Rule-1-of-Policy-Making/"/>
    <title>Rule 1 of Policy Making</title>
    <published>2023-07-21T12:00:00Z</published>
    <updated>2023-07-21T12:00:00Z</updated>
    undefined
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/01-Rule-1-of-Policy-Making/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>Don&#x2019;t do stupid.<br/>
A stupid you do may cause death of thousands.</p>
</blockquote>
<p>Predicting the outcome of public policy seems to be an impossible task for any human. The only way to reliable know the outcome of a policy is to implement it and observe the outcome. Learning from similar past policies under similar social condition is less reliable, but still useful. All other methods of policy making matter none.</p>
<p>Your ideology matter none. Maybe you think you can predict the outcome of a policy. I&#x2019;ve tried to predict the outcome of dozens. I can&#x2019;t.</p>
<p>Our society is just too volatile. With accelerating invention of technology, it becomes more unpredictable.</p>
<p>The solution? Don&#x2019;t make <strong>policies</strong>. Make <strong>solutions</strong> to existing social problems. Try them. If they work then good. If not, try something else.</p>
<p>At start, try the solution at small scale. Then, gradually expand the region where it is applied. Be cautious, for that the solution only work in <strong>some</strong> places.</p>
<p>This stupid method is called Randomized Control Trial. Existing implementation in India use terrible statistical tools to analyze the data collected. Nevertheless, RCT works <strong>reliably</strong>.</p>
<p>Some caveat: Data- and test-driven policy making takes time. For emergency cases, prepare and test multiple solutions before hand. Additionally, RCT doesn&#x2019;t come with exciting marketing slogans that social politicians usually employ. It simply works, not even over-performing.</p>
<p>Also, don&#x2019;t do obviously stupid things. Let your conscience be your guide.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/00-human-instincts-suck/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/00-human-instincts-suck/"/>
    <title>Human Instincts Suck</title>
    <published>2023-11-27T12:00:00Z</published>
    <updated>2023-11-27T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/00-human-instincts-suck/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>During my time thinking up solutions to social problems, I had, time and time again, ran into a brick wall that&#x2019;s called human nature. It is a brick wall in the sense that I cannot change it, only work around it.</p>
<p>If you ask me how I feel about it, human nature is more like an abyss that doesn&#x2019;t do anything or stare back at me. Many times have I looked into it for too long and thought to myself, &#x201c;what in the fuck was I looking at?&#x201d; And then I shake my head.</p>
<p>Maybe, in the future, we will have genetic engineering that can change human nature. For now, I don&#x2019;t see a way to change it.</p>
<p>Culture helps by selecting what part of it is invoked. It still can&#x2019;t change it.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/70-historical-hierarchy-technological-world/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/70-historical-hierarchy-technological-world/"/>
    <title>A historical parallel to the technological world today</title>
    <published>2025-11-09T12:00:00Z</published>
    <updated>2025-11-09T12:00:00Z</updated>
    <category term="soc"/>
    <category term="history"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/70-historical-hierarchy-technological-world/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In the Qing Dynasty, the &#x201c;end nerves&#x201d; of the hierarchical government is as follows:</p>
<p>&#x5b98;: government officials ordained by the hierarchy (extension of the Emperor&#x2019;s will).<br/>
&#x540f;: hereditary contract workers selected by &#x5b98;.<br/>
&#x5f79;: drafted subjects that actually do the tasks. unpaid.<br/>
</p>
<p>All 3 classes extract bribes from the lower class (slaves and subjects who are not drafted).</p>
<p>This looks awful like the technological world we see today. Most proprietary platform users are at the very bottom, just above machine slaves. I&#x2019;ll let you put in the blanks as to who the 3 classes correspond to.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/69-activitypub-poor-crypto/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/69-activitypub-poor-crypto/"/>
    <title>Poor cryptography in Gotosocial</title>
    <published>2025-07-14T12:00:00Z</published>
    <updated>2025-11-09T12:00:00Z</updated>
    <category term="comp:crypto"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/69-activitypub-poor-crypto/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>While developing software that has to do Authorized Fetch, I discovered something  cursed that made me feel a new kind of negative emotion.</p>
<p>Authorized Fetch. A &#x201c;feature&#x201d; forced onto everyone by Mastodon developers.</p>
<p><a href="https://www.w3.org/wiki/ActivityPub/Primer/Authentication_Authorization">https://www.w3.org/wiki/ActivityPub/Primer/Authentication_Authorization</a><br/>
<a href="https://docs.joinmastodon.org/admin/config/#authorized_fetch">https://docs.joinmastodon.org/admin/config/#authorized_fetch</a><br/>
<a href="https://github.com/w3c/activitypub/issues/315">https://github.com/w3c/activitypub/issues/315</a></p>
<p>To fetch a resource from any server with &#x201c;Authorized Fetch&#x201d;, you need to provide an actor with a public key.</p>
<p>Actor URL: <a href="https://example.com/">https://example.com/</a><br/>
Public Key URL: <a href="https://example.com/#main-key">https://example.com/#main-key</a></p>
<p>Those two URL should return the same document that looks like this: <a href="https://docs.gotosocial.org/en/latest/federation/http_signatures/#quirks">https://docs.gotosocial.org/en/latest/federation/http_signatures/#quirks</a></p>
<p>What if you want to change the public key, say, if you lost it, or need to upgrade its crypto primitive?</p>
<p>Well, according to GoToSocial, you are fucked. To be more precise, the entire actor can&#x2019;t sign requests anymore <strong>forever</strong> to GoToSocial. GoToSocial caches the public key and its ID <strong>forever</strong> and ignores whatever is specified in your actor object.</p>
<p>Let&#x2019;s summarize.</p>
<p>ActivityPub is not an open protocol any more. No open protocol will require you do this dance to fetch a Public Note. It is not how the web works.
ActivityPub does not care about the common practice of cryptography. In any case, the security of it hinges on the life expectancy of a Fediverse server being less than that of the signing algorithm.</p>
<p>In comparison, AT Protocol cares more about its users. Key rotation is clearly defined, and your identity is tied to a cryptographic key, not to a server.</p>
<p><a href="https://atproto.com/specs/did">https://atproto.com/specs/did</a><br/>
<a href="https://atproto.com/guides/identity">https://atproto.com/guides/identity</a><br/>
<a href="https://github.com/did-method-plc/did-method-plc">https://github.com/did-method-plc/did-method-plc</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/68-depraved-chinese-culture/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/68-depraved-chinese-culture/"/>
    <title>The depravity of Chinese tradition under Rousseau&apos;s lens</title>
    <published>2025-10-24T12:00:00Z</published>
    <updated>2025-10-24T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/68-depraved-chinese-culture/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>On the side effect of civilization.</p>
<p>After reading half of Part I of <strong>Discourse on the Origin of Inequality Among Men</strong> by Jean-Jacques Rousseau, I felt quite concerning about modernity and tradition present in China.</p>
<p>Believing that one can design reproduction better than nature:<br/>
&#x5468;&#x79ae; has a myth where the monogamy practice (&#x5468;&#x516c;&#x4e4b;&#x79ae;&#x3001;&#x5ac1;&#x5a36;) was invented when someone thought that the promiscuous human nature is bad. Rousseau would have said, &#x201c;How dare him?&#x201d; Before that, there was myth full of imagination like &#x5973;&#x5aa7;&#x88dc;&#x5929;, &#x5938;&#x7236;&#x9010;&#x65e5;. After that, even human reproduction must be approved by both heads of family.<br/>
Result: severe overpopulation throughout history (until 2000 or maybe 2010) fter many, many cycles of intense reproduction (until land cannot support it) and immigration.</p>
<p>Cultural racism:<br/>
&#x83ef;&#x88d4;&#x4e4b;&#x8faf; is a blind faith that believes their own culture is the most superior. It extends to racism by birth.<br/>
Result: even to this day, disrespect for science and blind faith to whatever the ancestors have said.</p>
<p>Make no doubt that it is a culture passed down by conquest, not by blood. It is not without an irony that nature selects culture too, as if information is a living creature. Natural selection has never cared for the welfare of individuals, nor does the market.</p>
<p>In short, &#x590f; replaced the merit-based political system with a violent one, depriving its subjects of political freedom. &#x5468; ruled over people&#x2019;s minds. I think this is really depraved; the act of forcefully removing people from their natural state.</p>
<p>There&#x2019;s also the dual inheritance theory of biology and culture, which I&#x2019;m not familiar with.</p>
<p>If we decide who is to blame, it&#x2019;s probably the past rulers who censored speech and only allowed/selected the above ideas to spread. &#x79e6; made its people slaves. &#x5143; gerrymandered the province borders to cut across original communities like Africa country borders today. &#x6e05; implemented the Emperor&#x2019;s power down to the township level (previously autonomous) so the entirety of their ethnicity can live worry-free. The commonality: a group of invaders come, censor speech and rule with terror, then implement institution inconducive to its people living a calm life.</p>
<hr/>
<p>What else lost in modern society (according to the book):</p>
<ul>
<li>
The ability for one to sleep under trees, wherever they want.
</li>
<li>
Let nature select infants. (Do not let infants be a burden to parents.)
</li>
</ul>
<hr/>
<p>Around 1650, the population in Qing Dynasty exponentiated until around 1825.</p>
<p><img alt="" src="population-in-the-qing-dynasty-1644-1911-n.jpg"/></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/67-linux-atomic-write/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/67-linux-atomic-write/"/>
    <title>Atomic/Untorn write on Linux</title>
    <published>2025-10-17T12:00:00Z</published>
    <updated>2025-11-14T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/67-linux-atomic-write/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>This topic is deeper than I originally thought.</p>
</blockquote>
<p>Atomic write is supported by filesystems like btrfs, and codified in syscall at Linux 6.11.</p>
<h2>Untorn Direct I/O</h2>
<p>The write amount must be powers of 2, and aligned to (start at) multiples of the hardware storage block size.</p>
<p>This is how you detect the feature:</p>
<p>Save this as <code>atomic-write.c</code>.</p>
<pre><code class="language-c">#define _GNU_SOURCE
#include &lt;fcntl.h&gt;
#include &lt;stdio.h&gt;
#include &lt;sys/stat.h&gt;
       
int main() {
	struct statx stat_buf;
	statx(AT_FDCWD, &quot;atomic-write.c&quot;, 0, STATX_BASIC_STATS | STATX_WRITE_ATOMIC, &amp;stat_buf);
	printf(&quot;Atomic direct I/O write Min: %d\n&quot;, stat_buf.stx_atomic_write_unit_min);
	printf(&quot;Atomic direct I/O write Max: %d\n&quot;, stat_buf.stx_atomic_write_unit_max);
	printf(&quot;Support atomic write: %d\n&quot;, !!(stat_buf.stx_attributes | STATX_ATTR_WRITE_ATOMIC));
}
</code></pre>
<p>To write, use <code>pwritev2</code> with the <code>RWF_ATOMIC</code> flag.</p>
<h2>Untorn buffered writes on btrfs</h2>
<p>Dispite people saying on Reddit that <code>write</code> calls aro atomic on btrfs, I can&#x2019;t find any sentence on official Linux kernel or btrfs websites guaranteeing that a <code>pwritev</code> call may fully commit or not commit.</p>
<p>The closest is from https://btrfs.readthedocs.io/en/latest/Kernel-by-version.html:</p>
<blockquote>
<p>Although it is not implemented yet, the new data=ordered code would allow atomic writes of almost any size to a single file to be exported to userland.</p>
</blockquote>
<ol>
<li>
Write to Hardware blocks is atomic. <a href="https://btrfs.readthedocs.io/en/latest/Hardware.html">(Confirmed)</a>
</li>
<li>
Will 1 <code>pwritev</code> call span 2 or more hardware transactions?
</li>
</ol>
<p>[untorn buffered write] has been discussed on the Linux mailing list, but the feature is not available yet.</p>
<p>Even <a href="https://www.sqlite.org/psow.html">Powersafe Overwrite</a> is still an assumption today, I guess this is also an assumption when using btrfs.</p>
<h2>Atomic file update / transaction</h2>
<p>See <a href="https://codeberg.org/iacore/linux-atomic-write">https://codeberg.org/iacore/linux-atomic-write</a></p>
<h2>References</h2>
<p><code>statx(2)</code><br/>
<code>pwritev2(2)</code></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/66-understanding-not-management/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/66-understanding-not-management/"/>
    <title>Understanding the project, not to manage it</title>
    <published>2025-09-29T12:00:00Z</published>
    <updated>2025-09-29T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/66-understanding-not-management/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>To achieve a goal, I need to know</p>
<ul>
<li>
where I am
</li>
<li>
how to reach there
</li>
</ul>
<p>I must stress that in order to have sufficient signaling, an organization must not form a hierarchy where sibling branches are 100% not connected directly. In distributed systems, every actor need to know where they are relatively and local approx. best action.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/65-nonviolent-solution/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/65-nonviolent-solution/"/>
    <title>The forced nature of nonviolent solutions</title>
    <published>2025-09-24T12:00:00Z</published>
    <updated>2025-09-24T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/65-nonviolent-solution/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I remember from the book <strong>Nonviolent Communication</strong> (the original one) about a case where a woman was threatened to take off her clothes. When she expressed that she felt terrified and asked the perpetuator to not do that, the perpetuator then only asks for her wallet and went away with the wallet.</p>
<p>If she is capable of using violence to protect herself, for example, by carrying a gun, would she still be threatened?</p>
<p>(A sociological solution would be to reduce poverty in the area, for instance.)</p>
<p>Nonviolent resistance pioneered by Gandhi receives praise internationally for its nonviolent nature. If Gandhi himself thinks that violent resistance against the British colonist institution would not succeed, the nonviolent nature of his resistance movement is by necessity.</p>
<p>So I don&#x2019;t think it is good to let nonviolent resistance take the moral highground, when it is the best solution to achieve a goal. Nor is it good to blame violent resistance for its violence, for that violence has been an essential part of humanity. Violence is quite useful too, if you can accept its consequences.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/64-pinenote/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/64-pinenote/"/>
    <title>Graphics and Chimera Linux on PineNote</title>
    <published>2025-11-03T12:00:00Z</published>
    <updated>2025-11-03T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/64-pinenote/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Moved to &lt;/stuff/pinenote/&gt;.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/63-iouring/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/63-iouring/"/>
    <title>Notes on io_uring</title>
    <published>2025-09-04T12:00:00Z</published>
    <updated>2025-09-04T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/63-iouring/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>io_uring (ring buffers) are opened as file descriptors, and are reference counted.</p>
<p>When in default submission mode (userspace thread calls <code>io_uring_enter(2)</code>), when every userspace thread dies (reference count drop to 0), the tasks remained not submitted in the ring buffer are lost.</p>
<p>When in kernel thread submission mode (SQ Polling in <code>io_uring(7)</code>), a kernel thread manages a ring buffer. Since the userspace thread need to supply an array of file descriptors, <strong><strong>I think</strong></strong> that the kernel thread adds 1 to the reference count of those files, and will drop the ring buffer once all tasks are completed.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/62-cors/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/62-cors/"/>
    <title>Notes on Cross-Origin Resource Sharing (CORS)</title>
    <published>2025-09-01T12:00:00Z</published>
    <updated>2025-09-01T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/62-cors/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>Cookies on CORS</h2>
<blockquote>
<p>When a Fetch API or XMLHttpRequest API request uses CORS, browsers will ignore Set-Cookie headers present in the server&#x2019;s response unless the request includes credentials. Visit Using the Fetch API - Including credentials and the XMLHttpRequest article to learn how to include credentials.</p>
</blockquote>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie">https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie</a></p>
<blockquote>
<p>Note: When responding to a credentialed requests request, the server must specify an origin in the value of the Access-Control-Allow-Origin header, instead of specifying the * wildcard.</p>
</blockquote>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS">https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS</a></p>
<h2><code>crossorigin</code> attribute</h2>
<blockquote>
<p>By default (that is, when the attribute is not specified), CORS is 
not used at all. The user agent will not ask for permission for full 
access to the resource and in the case of a cross-origin request, 
certain limitations will be applied based on the type of element 
concerned:</p>
<figure class="table-container"><table class="no-markdown">
  <tbody>
    <tr>
      <td class="header">Element</td>
      <td class="header">Restrictions</td>
    </tr>
    <tr>
      <td><code>img</code>, <code>audio</code>, <code>video</code></td>
      <td>
        When resource is placed in <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/canvas"><code>&lt;canvas&gt;</code></a>, element is marked as <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/How_to/CORS_enabled_image#security_and_tainted_canvases"><em>tainted</em></a>.
      </td>
    </tr>
    <tr>
      <td><code>script</code></td>
      <td>
        Access to error logging via <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event" title="window.onerror"><code>window.onerror</code></a> will be limited.
      </td>
    </tr>
    <tr>
      <td><code>link</code></td>
      <td>
        Request with no appropriate <code>crossorigin</code> header may be discarded.
      </td></tr></tbody></table></figure>
</blockquote>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin">https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin</a></p>
<h2>interactive-widget=resizes-content</h2>
<p>Not about CORS.</p>
<pre><code>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, interactive-widget=resizes-content&quot;&gt;
</code></pre>
<p><a href="https://lyra.horse/blog/2025/08/you-dont-need-js/">https://lyra.horse/blog/2025/08/you-dont-need-js/</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/61-china-involution/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/61-china-involution/"/>
    <title>Notes on Involution in China</title>
    <published>2025-09-01T12:00:00Z</published>
    <updated>2025-09-01T12:00:00Z</updated>
    <category term="econ:cn"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/61-china-involution/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Involution (&#x5167;&#x5377;), is a phenomenon in China that too many people does the same thing without much difference lead to no one benefiting from the competition. &#x540c;&#x8cea;&#x7af6;&#x722d; (compete by doing the same thing) would be a more accurate term.</p>
<p>Keyword: a bunch of people doing nearly the same thing.</p>
<p>Verified potential causes:</p>
<ul>
<li>
A shrinking market.
</li>
<li>
No copyright protection, not to mention patents. (Not the case if the firm has government background.)
</li>
<li>
No economic freedom. Little risk capital due to CCP&#x2019;s control on capital.
</li>
<li>
Lack of invention of new technology.
</li>
<li>
De dure 18% transfer tax (when goods and services changing hands between two companies, this amount is taxed on the transfer price), coined misleadingly as &#x201c;value-added tax&#x201d; (&#x589e;&#x503c;&#x7a05;).
</li>
<li>
Lack of social trust leads to short supply chain.
</li>
</ul>
<p>To be honest, this feels like a engineered problem, like how nearly all students in China need to pass <a href="https://en.wikipedia.org/wiki/Gaokao">one exam</a> to go in a college. Fully planned education, like a planned economy, does not have diversity and can have little to no innovation, contrary to what purpose education should serve.</p>
<h2>References</h2>
<p><a href="https://theinitium.com/opinion/20210107-opinion-china-industry-workers-involution">https://theinitium.com/opinion/20210107-opinion-china-industry-workers-involution</a></p>
<p><a href="https://www.youtube.com/watch?v=42giCVlE_ts">https://www.youtube.com/watch?v=42giCVlE_ts</a></p>
<p>I didn&#x2019;t learn anything from the two articles below. Listed here for completeness.</p>
<p><a href="https://carnegieendowment.org/posts/2025/08/whats-new-about-involution?lang=en">https://carnegieendowment.org/posts/2025/08/whats-new-about-involution?lang=en</a></p>
<p><a href="https://www.thinkchina.sg/economy/chinas-involution-could-spur-post-capitalist-era-part-1">https://www.thinkchina.sg/economy/chinas-involution-could-spur-post-capitalist-era-part-1</a></p>
<p>The wikipedia pages on this are trash.</p>
<h2>More?</h2>
<p>There&#x2019;s more to China&#x2019;s economy than this. Hopefully I&#x2019;ll be able to understand it and write about it.</p>
<p><a href="https://plainlaw.me/posts/reading-8">https://plainlaw.me/posts/reading-8</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/60-lean-lambda-rc-ir/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/60-lean-lambda-rc-ir/"/>
    <title>Notes on &#x3bb;RC IR in Lean</title>
    <published>2025-08-18T12:00:00Z</published>
    <updated>2025-08-18T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/60-lean-lambda-rc-ir/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>&#x3bb;RC is not a particular version of the IR. Is it the same IR as &#x3bb;pure, but with <code>dec (var : obj)</code> <code>inc (var : obj)</code> instructions and <code>@&amp;</code> (reference marker) inserted.</p>
<p>In this sense, Lean 4 is a untyped, interpreted and compiled language with a sophisticated syntax translation frontend.</p>
<p>Relevant files in lean4 repo:</p>
<pre><code>src/library/compiler/ir.h
src/Lean/Compiler/IR/Basic.lean
src/library/compiler/ir_interpreter.h
</code></pre>
<p>To see generated IR, put <code>set_option trace.compiler.ir.rc true</code> into Lean code and see it in the InfoView.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/59-heartbeat-scheduling/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/59-heartbeat-scheduling/"/>
    <title>Notes on Heartbeat Scheduling</title>
    <published>2025-07-22T12:00:00Z</published>
    <updated>2025-07-22T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/59-heartbeat-scheduling/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>First of all, the information I have about &#x201c;Heartbeat Scheduling&#x201d; is from <a href="https://github.com/judofyr/spice">the Zig implementation of it</a>, not the original paper. The Coq proof said to be provided by the original paper is corrupted and can&#x2019;t be found anywhere, not even on the source code repo they provided. <em>sighs</em></p>
<p>The main idea is every idle thread checks gets a new task every 100 microseconds (configurable), and every busy thread shares a task. Threads are sent heartbeat like barrels of a Gatling gun to reduce contention on the global state mutex.</p>
<p>A busy thread executing a task must call <code>Task.tick()</code> every so often to respond to heartbeat event. Basically, these are like preemption points, except it shares a task.</p>
<p>To summarize:</p>
<ul>
<li>
Gatling gun-like task sharing (give and take)
</li>
<li>
A thread can only share or fetch a task on every heartbeat received
</li>
<li>
Use the smallest grain possible / Split tasks into smallest chunks
</li>
</ul>
<hr/>
<p>Fundamental synchronization primitives used on Linux:</p>
<ul>
<li>
timer -&gt; <a href="https://docs.kernel.org/timers/highres.html">high resolution timers</a>
</li>
<li>
mutex -&gt; futex
</li>
<li>
semaphore -&gt; also futex
</li>
<li>
condition -&gt; also also futex
</li>
</ul>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/58-thoughts-on-global-trade/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/58-thoughts-on-global-trade/"/>
    <title>Thoughts on international trade</title>
    <published>2025-07-07T12:00:00Z</published>
    <updated>2025-07-07T12:00:00Z</updated>
    <category term="pol"/>
    <category term="econ"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/58-thoughts-on-global-trade/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This morning, I watched <a href="https://www.aljazeera.com/video/inside-story/2025/7/2/whats-bringing-china-and-the-eu-closer">a video about the trade relations of the US, China, and the EU by Aljazeera</a>. Let me summarize the first half of the video.</p>
<ul>
<li>
The US is being done by the Trump administration.
</li>
<li>
The EU complains about not having intel on Chinese state and state-owned enterprises and laws that force capital and digital infrastructure to stay in China.
</li>
<li>
China complains about the EU&#x2019;s tariff on EV car imports. (author&#x2019;s note: EU car companies are family-owned businesses; politician families)
</li>
</ul>
<p>From here, it seems to me that international trade is a game played by the rulers. How it affects ordinary people is not discussed at all. Everything except the ruling power is negotiable.</p>
<p>The song <em>L&#x2019;Internationale</em> still rings true today. There is no reason for you to pay taxes to your rulers. <a href="https://www.theguardian.com/commentisfree/2025/feb/20/americans-government-taxes">We can all learn from the US founders.</a></p>
<p>If the ruler hold power from employing violence and fear, there is not much point talking about political theory, as any kind of democracy would be better.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/57-performance-based-selection/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/57-performance-based-selection/"/>
    <title>Performance based selection</title>
    <published>2025-06-30T12:00:00Z</published>
    <updated>2025-06-30T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/57-performance-based-selection/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>One of my friends mentioned that in Germany, STEM university allows anyone with a high school diploma to enroll, only to kick those who fail in math exams out. This is a much better model than to rely on third party information (usually some score) to select students. It is better for both the students and the university. Personally, I don&#x2019;t think a high school diploma is needed, since I heard that those who don&#x2019;t finish high school tend to be illiterate.</p>
<p>This also applies to jobs too. Some companies will give intership to just about anyone. This culture is common in Japan, where salary is paid in cash. I can&#x2019;t stress how important it is to not have the bureaucracy mess with labor.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/55-ai-and-economy/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/55-ai-and-economy/"/>
    <title>AI and institutional economy</title>
    <published>2025-06-19T12:00:00Z</published>
    <updated>2025-06-19T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/55-ai-and-economy/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I now hear claims such as &#x201c;AGI and ASI will save humanity&#x201d;.</p>
<p>Will AI free us from poverty?<br/>
Will AI free us from work?<br/>
Will AI free us from death?<br/>
Will AI free us from violence?<br/>
</p>
<p>AI does free us from thinking. Not sure if that&#x2019;s a benefit or not.</p>
<p><a href="https://www.povertyactionlab.org/page/dedp-micromasters-program">I have learned to do RCT from J-PAL.</a> It seems like <a href="https://www.povertyactionlab.org/evaluations">their latest work</a> is from 2021. However, China, which doesn&#x2019;t use RCT (at least on paper), alleviates poverty much faster than India due to its political system. That political system also fucks up high value-added industries.</p>
<p>By &#x201c;economy&#x201d;, I mean &#x201c;how people make their living&#x201d;, not how high a country&#x2019;s GDP is.</p>
<p>What I&#x2019;ll be reading next: <a href="https://en.wikipedia.org/wiki/Institutional_economics">Institutional economics</a>, <a href="https://en.wikipedia.org/wiki/Why_Nations_Fail"><em>Why Nations Fail</em></a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/54-zig-single-translation-unit/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/54-zig-single-translation-unit/"/>
    <title>Zig&apos;s single translation unit</title>
    <published>2025-06-10T12:00:00Z</published>
    <updated>2025-06-10T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/54-zig-single-translation-unit/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Zig compiles all Zig code as a single translation unit, passing it to LLVM.</p>
<p>The implicit error set (<code>anyerror</code>) makes this probably a fixed language feature.</p>
<p>This is very bad for parallel compilation.</p>
<p>It is possible to have a smaller version of Zig that just fixes the janky syntax of C. slimcc looks great.</p>
<p>I really hope Jai becomes public.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/53-fish-execve-lag/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/53-fish-execve-lag/"/>
    <title>Fish&apos;s execve is slow</title>
    <published>2025-05-13T12:00:00Z</published>
    <updated>2025-05-13T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/53-fish-execve-lag/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>OK. Funny story. If you run programs in the Fish shell, it is slow. Try this out yourself.</p>
<p><code>spawn.c</code></p>
<pre><code class="language-c">#include &lt;unistd.h&gt;

int main(int argc, char **argv) {
	argv += 1;
	execvp(argv[0], argv);
}
</code></pre>
<p><code>hello.clj</code></p>
<pre><code class="language-clojure">(println &quot;hello world&quot;)
</code></pre>
<pre><code class="language-shell">time bb hello.clj # this is slower than the rest
time /usr/bin/bb hello.clj
clang spawn.c -o spawn
time ./spawn bb hello.clj
</code></pre>
<p>If you don&#x2019;t have Babashka installed, you can probably modify this to use Python.</p>
<p>It turns out Rust doesn&#x2019;t make everything fast.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/52-acpp/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/52-acpp/"/>
    <title>AdaptiveCpp Notes</title>
    <published>2025-05-12T12:00:00Z</published>
    <updated>2025-05-12T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/52-acpp/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>AdaptiveCpp is pretty fun to use. I&#x2019;ll add some more notes after I use it more.</p>
<h2>Install instructions (Arch Linux)</h2>
<blockquote>
<p>Oops!
After writing this section, I can&#x2019;t make it to compile. LLVM18 can&#x2019;t compile with latest stdc++ headers.</p>
</blockquote>
<p>This is for HIP (dispite being called <code>ROCM</code>):</p>
<pre><code class="language-shell">doas pacman -Sy --needed cmake ninja boost hip-runtime-amd llvm18 clang18 libxml2

git clone https://github.com/AdaptiveCpp/AdaptiveCpp --depth 1
cd AdaptiveCpp
cmake -B build -G Ninja -DWITH_ROCM_BACKEND=ON -DLLVM_DIR=/usr/lib/llvm18/lib/cmake/llvm -DCLANG_EXECUTABLE_PATH=/usr/lib/llvm18/bin/clang++
cd build/
ninja
doas ninja install
acpp
</code></pre>
<p>For CUDA:</p>
<pre><code class="language-shell">doas pacman -Sy --needed cuda

# ...

cmake -B build -G Ninja -DWITH_CUDA_BACKEND=ON -DLLVM_DIR=/usr/lib/llvm18/lib/cmake/llvm -DCLANG_EXECUTABLE_PATH=/usr/lib/llvm18/bin/clang++
</code></pre>
<p>You can also use <a href="https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/doc/compilation.md">the generic backend</a>, which offloads compilation to program run-time.</p>
<p>It needs <code>hipcc</code> or clang + ROCm installed to compile code to AMD CPU.</p>
<pre><code class="language-shell">cmake -B build -G Ninja -DLLVM_DIR=/usr/lib/llvm18/lib/cmake/llvm -DCLANG_EXECUTABLE_PATH=/usr/lib/llvm18/bin/clang++ -DCLANG_INCLUDE_PATH=/usr/lib/llvm18/include
</code></pre>
<h2>Disclaimer for &#x201c;single pass&#x201d;</h2>
<p>This as also advertised as &#x201c;the ability to generate a single binary that can offload to all supported devices&#x201d;.</p>
<p>Take AMD as an example. <code>acpp</code> still need to run <code>hipcc</code> to compile the LLVM IR embedded in the host executable.</p>
<ul>
<li>
<code>acpp --acpp-targets=hip</code>: AOT
</li>
<li>
<code>acpp --acpp-targets=generic</code>: JIT
</li>
</ul>
<p>There is no difference in the total number of compilers needed to compile/run your program. You still need HIP installed on the target machine to run the final executable.</p>
<p><a href="https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/doc/performance.md">They say JIT is faster.</a></p>
<h2>Do not use <code>sycl::buffer</code></h2>
<p>I have a headache using SYCL buffers and accessors. Never use buffers.</p>
<h2>Nvidia vs AMD</h2>
<p>AMD: After installing <code>hip-runtime-amd</code>, the thing works out of the box.</p>
<p>Nvidia: You need a CUDA version supported by <code>nvc++</code>. I can&#x2019;t get this to work.</p>
<h2>Thoughts after an hour of use</h2>
<p>SYCL is C++-friendly. I hope I can use it in other languages like the clik concurrency model.</p>
<p>The AdaptiveCpp compiler is implemeted as a plugin (compile pass) inside clang++. The compiler is not very good. If you use a <code>inline static</code> function inside a kernel, it would be only 90% as fast on CPU. Apply the patch below:</p>
<pre><code class="language-diff">diff --git a/examples/bruteforce_nbody/bruteforce_nbody.cpp b/examples/bruteforce_nbody/bruteforce_nbody.cpp
index 37755ac..f37a50e 100644
--- a/examples/bruteforce_nbody/bruteforce_nbody.cpp
+++ b/examples/bruteforce_nbody/bruteforce_nbody.cpp
@@ -19,6 +19,7 @@
 #include &quot;model.hpp&quot;
 
 
+
 arithmetic_type mirror_position(const arithmetic_type mirror_pos,
                                 const arithmetic_type position)
 {
@@ -36,6 +37,13 @@ int get_num_iterations_per_output_step()
 }
 
 
+inline static void ff(particle_type &amp;p, vector_type v, float dt) {
+        // Update position
+        p.x() += v.x() * dt;
+        p.y() += v.y() * dt;
+        p.z() += v.z() * dt;
+}
+
 int main()
 {
   const int iterations_per_output =
@@ -192,10 +200,7 @@ int main()
         // Bring v to the current state
         v += acceleration * dt;
 
-        // Update position
-        p.x() += v.x() * dt;
-        p.y() += v.y() * dt;
-        p.z() += v.z() * dt;
+        ff(p, v, dt);
 
         // Reflect particle position and invert velocities
         // if particles exit the simulation cube
</code></pre>
<p>Inside <code>src/compiler/llvm-to-backend/amdgpu/LLVMToAmdgpu.cpp</code>, you can see LLVM bitcode being linked together.</p>
<p>I hope future programs won&#x2019;t need two LLVM-based compilers to run.</p>
<p>Still, this is the best way I know to write code to run on GPUs.</p>
<h2>Thoughts about GPU compilers</h2>
<p>With that said, it isn&#x2019;t impossible to generate PTX and amdgcn.</p>
<p>ILGPU can produce PTX.</p>
<p>Neither acpp or hipcc/clang++ can compile C99 code to run on GPU. F</p>
<h2>References</h2>
<p>My experiments with SYCL: <a href="https://git.envs.net/iacore/test-sycl/">https://git.envs.net/iacore/test-sycl/</a></p>
<p>SYCL Reference: <a href="https://github.khronos.org/SYCL_Reference/">https://github.khronos.org/SYCL_Reference/</a></p>
<p>SYCL Cheatsheet: <a href="https://www.khronos.org/files/sycl/sycl-2020-reference-guide.pdf">https://www.khronos.org/files/sycl/sycl-2020-reference-guide.pdf</a></p>
<p>AMDGCN: <a href="https://gpuopen.com/wp-content/uploads/2016/08/AMD_GCN3_Instruction_Set_Architecture_rev1.1.pdf">https://gpuopen.com/wp-content/uploads/2016/08/AMD_GCN3_Instruction_Set_Architecture_rev1.1.pdf</a></p>
<p>Explaining AMD GPU architecture: https://rocm.docs.amd.com/projects/HIP/en/latest/understand/programming_model.html</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/51-beyond-concepts/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/51-beyond-concepts/"/>
    <title>Beyond concepts</title>
    <published>2025-05-01T12:00:00Z</published>
    <updated>2025-05-01T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/51-beyond-concepts/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Physical laws are patterns that can be used to predict how to make something, like constructing a building from a blueprint. Why does it work? Why can ideas be turned into physical objects? I don&#x2019;t think this can be explained with words or be explained at all.</p>
<p>To transport something, we need to pick a vehicle and a route. The plan is an algorithm and moving the thing is computation. Is there a way to move something without being able to describe it with words? I think it is possible.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/50-battle-with-ideas/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/50-battle-with-ideas/"/>
    <title>Battling with ideas</title>
    <published>2025-04-28T12:00:00Z</published>
    <updated>2025-04-28T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/50-battle-with-ideas/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In <em>Serial Experiments Lain</em>, human individuals are described as containers of information that drive their behavior. Indeed, many harmful acts today are done by ideas &#x2013; many a group of people with the same idea.</p>
<p>Traditional writing (like <a href="https://www.maxim.org.nz/article/grievance-rules-why-distrust-neednt-destroy-us/">this one from a think tank</a>) can no longer sway me. What it to say that it will work on someone else? How do you &#x201c;remove&#x201d; an idea from someone&#x2019;s mind? Must we fight clutter with more clutter?</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/49-mihomo-sub/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/49-mihomo-sub/"/>
    <title>Configuring mihomo (Clash.Meta) subscription on Linux</title>
    <published>2025-03-27T12:00:00Z</published>
    <updated>2025-03-27T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/49-mihomo-sub/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>First, pay for a service that supports Clash Meta subscription.</p>
<p>Then:</p>
<pre><code class="language-shell">doas pacman -S mihomo                    # install mihomo
curl [subscription link] &gt; config.yaml   # get config from your vpn provider
# pay attention that the subscription link is of Clash.Meta, not Clash
cp /etc/clash/Country.mmdb ./            # It is very stupid that the file is not used by default
</code></pre>
<p>Enable TUN and disable proxy ports in <code>config.yaml</code>:</p>
<pre><code class="language-yaml"># port: 7890                 #&#x672c;&#x5730;http&#x4ee3;&#x7406;&#x7aef;&#x53e3;
# socks-port: 7891           #&#x672c;&#x5730;socks5&#x4ee3;&#x7406;&#x7aef;&#x53e3;
# mixed-port: 7890             #&#x672c;&#x5730;&#x6df7;&#x5408;&#x4ee3;&#x7406;(http&#x548c;socks5&#x5408;&#x5e76;&#xff09;&#x7aef;&#x53e3;
tun:
  enable: true
</code></pre>
<p>Now enjoy surfing the Internet!</p>
<pre><code class="language-shell">doas mihomo -d .
</code></pre>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/48-aogmaneo/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/48-aogmaneo/"/>
    <title>Notes on studying AOgmaNeo</title>
    <published>2025-01-16T12:00:00Z</published>
    <updated>2025-01-16T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/48-aogmaneo/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Repo: <a href="https://github.com/ogmacorp/AOgmaNeo/">https://github.com/ogmacorp/AOgmaNeo/</a></p>
<p>Sparse hierarchies prior art: <a href="http://sparsey.com/">http://sparsey.com/</a>, Numenta HTM.</p>
<p><a href="/blog/30-recall/">I suspected brain uses quantum entanglement.</a></p>
<p><a href="https://www.researchgate.net/publication/270552722_Quantum_Computation_via_Sparse_Distributed_Representation">https://www.researchgate.net/publication/270552722_Quantum_Computation_via_Sparse_Distributed_Representation</a></p>
<p>What is required of learning? Remembering and choice.</p>
<p>From Ogma AI discord:</p>
<blockquote>
<p><a href="https://arxiv.org/abs/1905.11437">https://arxiv.org/abs/1905.11437</a> A survey paper on Adaptive Resonance Theory (ART), the encoder we currently use.
We use a distributed ART variant made to handle sparse data specifically.</p>
</blockquote>
<p>Personal note: when a driver steps into a car, their driving knowledge, their body and the car&#x2019;s mechanism merge into one. SPH is only the brain capable of learning knowledge. It need a body to operate, maybe a virtual one.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/47-three-self-mutating-tapes/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/47-three-self-mutating-tapes/"/>
    <title>Three self mutating tapes design</title>
    <published>2024-12-17T12:00:00Z</published>
    <updated>2024-12-17T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/47-three-self-mutating-tapes/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This is a fleeting thought of mine.</p>
<p>What if we have three doubly linked rings filled with instructions. When one ring is interpreted, the other two ring become data. The instruction set have normal input/output instructions, but also instructions for modifying data/instructions on the the other two rings. This is the minimal of what can be trained with intelligence.</p>
<p>The instruction set is also interpreted as output data, kind of like how RNA transcoding works. I doubt if this idea will really work, but, if it did, it would offer a really lightweight alternative to all the LLM out there.</p>
<p>Also, when training, which tape is executable changes. The rest two are treated like stacks that loop around.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/46-coc-or-quote-or-meh/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/46-coc-or-quote-or-meh/"/>
    <title>Automatic refactoring: construction calculus or (quote) or scanning source code</title>
    <published>2024-08-23T12:00:00Z</published>
    <updated>2024-08-23T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/46-coc-or-quote-or-meh/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Reading https://ianthehenry.com/posts/quote-unquote-macros/ made me want to comment on the futility of reflection in programming languages.</p>
<p>Recently, I was making HTML templates in PixivFE function at compile time. You may ask, why don&#x2019;t I use a type-checked templating library? Well, for this project, I didn&#x2019;t make the choice.</p>
<p>Let&#x2019;s say you have code like <code>c.Render(&quot;template_name&quot;, map[string]any{&lt;template_data&gt;})</code> littered all throughout the source code. How do you make this type checked? Note that each HTML template has its own template_data type.</p>
<p>Different languages offer different solutions to this.</p>
<p>Zig: Just type more :) You can&#x2019;t have too much types :)</p>
<p>Janet: <code>(def-macro awawawawa)</code></p>
<p>And there are languages who proud themselves in limited flexibility.</p>
<p>Go: https://github.com/golang/go/issues/61796</p>
<p>You can circumvent this limitation by scanning the source code.</p>
<p>You may say that Go has <a href="https://go.dev/blog/generate"><code>go generate</code></a>. No, I refuse. I just want to write automatic tests, not half of a static analysis tool.</p>
<p>If the language is Jai, then, maybe scanning the source code takes not too much development time to be worth it. Go? No. It&#x2019;s not a language that empowers the language users.</p>
<p><a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a> how do i grammar this?</p>
<section role="doc-endnotes">
<hr/>
<ol>
<li id="fn1">
<p><a href="#fnref1" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/45-crash-resistant-sqlite/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/45-crash-resistant-sqlite/"/>
    <title>How SQLite is crash resistant</title>
    <published>2024-07-29T12:00:00Z</published>
    <updated>2024-07-29T12:00:00Z</updated>
    <category term="comp"/>
    <category term="db:sqlite"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/45-crash-resistant-sqlite/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Preparing to write my own database, I was reading how SQLite handles POSIX signals.</p>
<p>To my surprise, it doesn&#x2019;t. There&#x2019;s nowhere in the source code that handles signals.</p>
<p>roll back (backup original copy of changed pages before overwriting): https://sqlite.org/atomiccommit.html</p>
<p>roll forward (WAL): https://sqlite.org/wal.html#ckpt (SQLite has WAL!?)</p>
<p>Hopefully, because time is 1 dimensional (jk vector time you do exist), I only need to care about those two cases.</p>
<p>Reminds me of this article about crash-only software: https://lwn.net/Articles/191059/</p>
<p>Case in point: Different components have different ways of dealing with downtime.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/71-nbody-integrator/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/71-nbody-integrator/"/>
    <title>Notes on Hamiltonian Splitting for physics simulation</title>
    <published>2025-12-25T12:00:00Z</published>
    <updated>2025-12-25T12:00:00Z</updated>
    <category term="math"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/71-nbody-integrator/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><a href="https://www.youtube.com/watch?v=nCg3aXn5F3M">(Video) Introduction to Hamiltonian splitting</a></p>
<p>The following algorithm should be helpful for space simulation games. I find it quite weird to not reply on knowledge of IEEE floating point numbers, despite all calculation is done with IEEE floats.</p>
<p><a href="https://arxiv.org/abs/1912.03255">Paper</a><br/>
<a href="https://github.com/hannorein/rebound">Code</a><br/>
<a href="https://rebound.hanno-rein.de/">Website</a><br/>
</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/72-blog-worhty-link/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/72-blog-worhty-link/"/>
    <title>Blog worthy links</title>
    <published>2026-03-17T12:00:00Z</published>
    <updated>2026-03-17T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/72-blog-worhty-link/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Today I discovered buddism on one of the first Internet bloggers&#x2019; blog. Truly amazing so that I posted it on my website (here).</p>
<p><a href="https://neal.fun/internet-artifacts/justins-links/">https://neal.fun/internet-artifacts/justins-links/</a></p>
<p><a href="https://www.links.net/vita/swat/course/interbeing/">https://www.links.net/vita/swat/course/interbeing/</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/frag/73-zig-algebraic-effect/</id>
    <link rel="alternate" href="https://www.1a-insec.net/frag/73-zig-algebraic-effect/"/>
    <title>&quot;Algebraic&quot; effects in Zig</title>
    <published>2026-07-21T12:00:00Z</published>
    <updated>2026-07-21T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/frag/73-zig-algebraic-effect/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>We feel like we haven&#x2019;t explained this claim we made that Zig supports algebraic effects.</p>
<p>In Lean, let&#x2019;s say we have two monad <code>A : x -&gt; Type</code> and <code>B : x -&gt; Type</code>.</p>
<p>We then must have this:</p>
<pre><code class="language-lean">def Pair (A B : Type &#x2192; Type) (x : Type) : Type := A x &#xd7; B x

instance [Monad A] [Monad B] : Monad (Pair A B) where
  pure a := (pure a, pure a)
  bind p f := (p.1 &gt;&gt;= fun a =&gt; (f a).1, p.2 &gt;&gt;= fun b =&gt; (f b).2)

-- an &quot;allocator&quot; that counts bytes, and a random source
abbrev AllocM := StateM Nat
abbrev RandM := StateM StdGen

def allocSide (n : Nat) : AllocM ByteArray := do
  modify (&#xb7; + n)
  return ByteArray.mk (Array.replicate n 0)

def randSide (n : Nat) : RandM ByteArray := do
  let mut out := ByteArray.empty
  for _ in [0:n] do
    let (b, g&apos;) := randNat (&#x2190; get) 0 255
    set g&apos;
    out := out.push b.toUInt8
  return out

def randomBytes (n : Nat) : Pair AllocM RandM ByteArray :=
  (allocSide n, randSide n)

#eval
  let (allocRun, randRun) := randomBytes 4
  let (zeroed, bytesUsed) := allocRun.run 0
  let (random, _) := randRun.run (mkStdGen 42)
  (zeroed.data.toList, bytesUsed, random.data.toList)
-- ([0, 0, 0, 0], 4, [37, 165, 219, 80])
</code></pre>
<p>Here&#x2019;s how it&#x2019;s like in Zig:</p>
<pre><code class="language-zig">const std = @import(&quot;std&quot;);
const Allocator = std.mem.Allocator;
const Random = std.Random;

fn randomBytes(ctx: struct { a: Allocator, r: Random }, n: usize) ![]u8 {
    const buf = try ctx.a.alloc(u8, n);
    ctx.r.bytes(buf);
    return buf;
}

pub fn main() !void {
    var da: std.heap.DebugAllocator(.{}) = .init;
    defer _ = da.deinit();
    var prng: std.Random.DefaultPrng = .init(42);
    const a = da.allocator();
    const buf = try randomBytes(.{ .a = a, .r = prng.random() }, 16);
    defer a.free(buf);
    std.debug.print(&quot;{x}\n&quot;, .{buf});
}
</code></pre>
<p>No special <code>Pair</code> type needed.</p>
<hr/>
<p>Kimi K3&#x2019;s stance:</p>
<p>The claim is right in spirit and wrong in the letter, and the real examples above show where. In Lean, <code>randomBytes</code> is a <strong>value</strong> living inside the product of two computations; look at the output: one run returns a zeroed buffer and a byte count, the other returns random bytes. The two sides never meet &#x2014; nothing ever fills the allocated buffer. In Zig, <code>randomBytes</code> is a <strong>function consuming</strong> the product of two handlers, and <code>ctx.r.bytes(buf)</code> fills the very buffer <code>ctx.a.alloc</code> returned. Same name, opposite roles.</p>
<p>This is structural, not incidental. <code>Pair A B</code> keeps the two monads sealed apart: <code>bind</code> threads each component separately, so no single <code>Pair</code>-computation can use both <code>A</code> and <code>B</code>. Meanwhile the Zig function uses <code>ctx.a</code> and <code>ctx.r</code> in the same body, and the &#x201c;bind&#x201d; is the semicolon. One function using two effects together is exactly what the product of monads cannot express, and what the product of handlers does trivially. The theorem that describes the Zig side is currying: <code>randomBytes</code> is a computation in <code>Reader (Allocator &#xd7; Random)</code>, and <code>Reader (A &#xd7; R) T &#x2245; A &#x2192; R &#x2192; T</code>. The <code>Pair</code> instance remains a true theorem that the Zig code never uses.</p>
<p>Which is to say: Zig&#x2019;s answer to algebraic effects is to not have them. An <code>Allocator</code> is a handler &#x2014; a <code>ptr</code> plus a <code>vtable</code>, an interpreter passed by hand. <code>anytype</code> makes <code>foo</code> polymorphic over handlers. The effect system is the calling convention.</p>
<p>What you give up: resumable continuations (a Zig handler returns a value; it cannot suspend the caller and resume later) and effect tracking (nothing stops <code>randomBytes</code> from allocating through a global instead of <code>ctx.a</code>; the discipline is social, not static). Real effect languages buy those two with a lot of machinery. Zig declines the machinery, and the purchase.</p>
<p>I approve of the practice. But the proof obligation runs the other way: the correct formalization is the Reader stack, and the honest name is effects as parameters.</p>

      </div>
    </content>
  </entry>
</feed>