<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Posts Tagged "javascript" on Alex Leighton's Blog</title>
  <id>https://alexleighton.com/posts/tags/javascript-tag-feed.xml</id>
  <link href="https://alexleighton.com/posts/tags/javascript-tag-feed.xml" rel="self" />
  <link href="https://alexleighton.com/posts/tags/javascript.html" />
  <updated>2026-03-11T13:36:28.055135011Z</updated>
  <author>
    <name>Alex Leighton</name>
    <uri>https://alexleighton.com/</uri>
  </author>
  <icon>https://alexleighton.com/static/icon-dino.png</icon>
  <logo>https://alexleighton.com/static/icon-dino.png</logo>
  
  <entry>
    <title>TIL: Websockets and SSE</title>
    <id>https://alexleighton.com/posts/2025-11-20-til-websockets-and-sse.html</id>
    <link href="https://alexleighton.com/posts/2025-11-20-til-websockets-and-sse.html" />
    <published>2025-11-20T17:00:00Z</published>
    <updated>2025-11-20T17:00:00Z</updated>
    <author><name>Alex Leighton</name></author>
    <summary type="html"><![CDATA[<p>Protocol basics at the transport layer.</p><p>Published on <span title="2025-11-20T17:00:00Z">2025-11-20</span></p>]]></summary>
    <content type="html"><![CDATA[<h3>Protocol basics at the transport layer.</h3><p>Published on <span title="2025-11-20T17:00:00Z">2025-11-20</span><br>Tags: javascript, protocol, til</p><p>Today at work I learned of the existence of <a href="https://en.wikipedia.org/wiki/Server-sent_events">Server Sent Events</a> (SSE) and some transport layer/protocol facts about <a href="https://en.wikipedia.org/wiki/WebSocket">Websockets</a>.</p>
<p>SSE is just a standardization of the old <a href="https://en.wikipedia.org/wiki/Comet_(programming)">Comet</a> model. The browser initiates an HTTP request, the server and the client keep the underlying TCP connection alive, with the server sending events-as-they-happen by adding more data onto a neverending HTTP response body.</p>
<p>Websockets also <a href="https://en.wikipedia.org/wiki/WebSocket#Protocol">start life as an HTTP request</a> to the server, but the initial request is to switch protocols, after which the server and client drop down to communicating in a binary frame-based protocol on top of the underlying TCP connection.</p><p><a href="https://alexleighton.com/posts/2025-11-20-til-websockets-and-sse.html">Read the post →</a></p>]]></content>
  </entry>
  
  <entry>
    <title>Mechanical Watch Simulation</title>
    <id>https://alexleighton.com/posts/2025-09-09-mechanical-watch-simulation.html</id>
    <link href="https://alexleighton.com/posts/2025-09-09-mechanical-watch-simulation.html" />
    <published>2025-09-09T15:40:00Z</published>
    <updated>2025-09-09T15:40:00Z</updated>
    <author><name>Alex Leighton</name></author>
    <summary type="html"><![CDATA[<p>Fully working, interactive 3d mechanical watch model and explanation.</p><p>Published on <span title="2025-09-09T15:40:00Z">2025-09-09</span></p>]]></summary>
    <content type="html"><![CDATA[<h3>Fully working, interactive 3d mechanical watch model and explanation.</h3><p>Published on <span title="2025-09-09T15:40:00Z">2025-09-09</span><br>Tags: javascript, watch</p><p><a href="https://ciechanow.ski/mechanical-watch/">Mechanical Watch by Bartosz Ciechanowski</a>. An absolute masterpiece of simulation, modeling, explanation, and teaching. If you've ever wanted to learn the full details of how a mechanical watch functions, this page will teach you with an incredibly detailed breakdown of a normal mechanical watch, but simulated in fully-interactive 3d models, to go along with the English explanations.</p>
<p>If you're interested in going deeper, the Javascript driving the simulations is about 8500 lines of unminified code, though you'll have to use your browser to inspect the <code>watch.js</code> file.</p><p><a href="https://alexleighton.com/posts/2025-09-09-mechanical-watch-simulation.html">Read the post →</a></p>]]></content>
  </entry>
  
  <entry>
    <title>ASCII Side of the Moon</title>
    <id>https://alexleighton.com/posts/2025-09-01-ascii-side-of-the-moon.html</id>
    <link href="https://alexleighton.com/posts/2025-09-01-ascii-side-of-the-moon.html" />
    <published>2025-09-02T04:45:00Z</published>
    <updated>2025-09-02T04:45:00Z</updated>
    <author><name>Alex Leighton</name></author>
    <summary type="html"><![CDATA[<p>ASCII Moon images on-demand.</p><p>Published on <span title="2025-09-02T04:45:00Z">2025-09-02</span></p>]]></summary>
    <content type="html"><![CDATA[<h3>ASCII Moon images on-demand.</h3><p>Published on <span title="2025-09-02T04:45:00Z">2025-09-02</span><br>Tags: javascript, software</p><p>Came across this fun software project: <a href="https://aleyan.com/projects/ascii-side-of-the-moon/?date=2025-09-02">The ASCII Side of the Moon</a>. They calculated the possible views of the Moon, generated images using a Blender model of the Moon, converted the images to ASCII, and aligned the views with the current date. Very cool!</p>
<pre><code>                                 x`!                        
                         ^\+e%*_,&lt;- ,_ _pK+                 
                             ggg$Z%92kyBWWyC /              
                           wg@$E$$@@K@Rg$7QRvx$t,           
                           a@@B$"  ~~"WRux$$@g@@$}L         
                       jLyA$@@$       "0@@@@s@KRM*W{        
                     gyg^@@@R@&gt; _ J    X@#$@$@05&amp;3x2=.      
                    $@@@@y@@@@$ggg0= . 9@$P5$$gb#~ \M$.     
                    0@@@@@@@@B$@@$@R'yy.^~  R@BK/    &amp;)     
                    @@@@@@@$@@@@$$$g@g@gw_ .w*y#@K_  }W     
                    $@@$@@@@@@@@$@$@@$@@@gF/g@t='4@$$/O     
                    @@@$@@$@@@@@@@@@$@$@$@ERF`    ^~1.4/    
                    @@@$@@@@@@@@@@B@@@@@E@$$gQ      ]&lt;W L   
                    $@@@@$@@$@@$@B@@@$@@@@@sBFy_ ua9mm7W    
                    M4R$$@@@@@$$@@@@@@@@@@$@@W@$@r&amp;MMMx#    
                    gg$@@@$$@@@$@@@@@$@@@R@$@@@E$$$0V$R     
                     @$$@@$$@@@$$$$$@$@$$B@$@@$@22@$@t\     
                     @@g@@@@@$$@@$@@@@$@@B$2R@@@$@Eh(`      
                      $$@$@5$@@@$$$@$@$B@$@@@$gRRs5'        
                      @$@@@$M@RM$g@@$@@%$N@R@5\R"^          
                       @g@R@@Dg@$$@$$$@b0B@E@#^`            
                        F@E#@@0$T@BE@#5@$?6m-,              
                         4zR@5g$$EEgBngK"_&gt;-~               
                          MKqZR@Ds!=`('  `                  
                            `'  ` `                         
</code></pre><p><a href="https://alexleighton.com/posts/2025-09-01-ascii-side-of-the-moon.html">Read the post →</a></p>]]></content>
  </entry>
  
  <entry>
    <title>Building Search for this Site</title>
    <id>https://alexleighton.com/posts/2025-08-09-building-search-for-this-site.html</id>
    <link href="https://alexleighton.com/posts/2025-08-09-building-search-for-this-site.html" />
    <published>2025-08-10T05:10:37Z</published>
    <updated>2025-08-10T05:10:37Z</updated>
    <author><name>Alex Leighton</name></author>
    <summary type="html"><![CDATA[<p>Search on a static site.</p><p>Published on <span title="2025-08-10T05:10:37Z">2025-08-10</span></p>]]></summary>
    <content type="html"><![CDATA[<h3>Search on a static site.</h3><p>Published on <span title="2025-08-10T05:10:37Z">2025-08-10</span><br>Tags: article, java, javascript, ocaml, static-site</p><p>I like the idea of having search for my blog, to help readers find anything related to a specific topic, or something they'd read in the past. How do I make something as dynamic as search, but statically generated?</p>
<h2>Requirements</h2>
<ul>
<li><strong>The solution has to be small</strong> — part of my purpose in statically generating the site is to make it fast to download, fast to view. Whatever is chosen needs to maintain that vision.</li>
<li><strong>The solution can't introduce too many dependencies</strong> — I really like OCaml as a language, and I used building my personal site as an excuse to work in it. Introducing non-OCaml dependencies has to be done with care, as I don't want to maintain a Rube Goldberg machine for my website.</li>
</ul><p>...<br><a href="https://alexleighton.com/posts/2025-08-09-building-search-for-this-site.html">Read the full post →</a></p>]]></content>
  </entry>
  
  <entry>
    <title>Syntax Highlighting</title>
    <id>https://alexleighton.com/posts/2025-08-06-syntax-highlighting.html</id>
    <link href="https://alexleighton.com/posts/2025-08-06-syntax-highlighting.html" />
    <published>2025-08-06T13:30:00Z</published>
    <updated>2025-08-06T13:30:00Z</updated>
    <author><name>Alex Leighton</name></author>
    <summary type="html"><![CDATA[<p>We're not there yet.</p><p>Published on <span title="2025-08-06T13:30:00Z">2025-08-06</span></p>]]></summary>
    <content type="html"><![CDATA[<h3>We're not there yet.</h3><p>Published on <span title="2025-08-06T13:30:00Z">2025-08-06</span><br>Tags: article, css, html, javascript, static-site</p><p>Unfortunately I spoke too soon when I wrote the <a href="../../../posts/2025-07-18-building-this-site.html">Building this Site</a> post. I had a plan in place to use <a href="https://opam.ocaml.org/packages/hilite/"><code>hilite</code></a>, along with TextMate grammars and themes pulled from <a href="https://shiki.style/">Shiki</a> (which in turn gets its grammars and themes from TextMate/VSCode), but it fell through.</p>
<h2>The Plan</h2>
<p>The plan was to grab lightmode and darkmode themes from Shiki's <a href="https://github.com/shikijs/textmate-grammars-themes/tree/main/packages/tm-themes">trove of themes</a>, stripping out any extraneous styles (a lot of text-editor-specific colors are given) to arrive at two sets of colors for pre-determined class names. Shiki works similarly to <code>hilite</code>: during processing it tags portions of the source code with CSS tags derived from the grammars. All of the <a href="https://github.com/shikijs/textmate-grammars-themes/tree/main/packages/tm-grammars">TextMate grammars</a> employed by Shiki use a consistent naming scheme, ensuring themes always line up with the grammars, resulting in colored text. With a little adjustment of the theme CSS tags to account for any differences between Hilite's and Shiki's tagging, I'd have ahead-of-time syntax highlighting, with as many supported languages as VSCode.</p><p>...<br><a href="https://alexleighton.com/posts/2025-08-06-syntax-highlighting.html">Read the full post →</a></p>]]></content>
  </entry>
  
</feed>
