<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Luke Sampson</title>
    <description></description>
    <link>https://lukesampson.silvrback.com/feed</link>
    <atom:link href="https://lukesampson.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="lukesampson.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Tue, 22 Nov 2022 20:32:22 -1200</pubDate>
    <managingEditor>me@lukesampson.com (Luke Sampson)</managingEditor>
      <item>
        <guid>http://blog.lukesampson.com/run-a-web-server-in-one-line-of-powershell#53932</guid>
          <pubDate>Tue, 22 Nov 2022 20:32:22 -1200</pubDate>
        <link>http://blog.lukesampson.com/run-a-web-server-in-one-line-of-powershell</link>
        <title>Run a web server in one line of Powershell</title>
        <description></description>
        <content:encoded><![CDATA[<p>Here&rsquo;s how to serve a static single page website in one line of Powershell.<br>
<br>
while(1) { cat index.html | nc -w1 -l -p 8080 }<br>
<br>
<br>
Where index.html is the file you want to serve, in your current working directory. Open a browser to&nbsp;<a href="http://localhost:8080">http://localhost:8080</a>&nbsp;to see the &ldquo;website&rdquo;.<br>
This requires&nbsp;netcat, which you can install with&nbsp;Scoop&nbsp;by running&nbsp;scoop install netcat, or download from Jon Craton&nbsp;here.<br>
The -w1 option makes netcat close the connection after 1 second, which seems necessary for the Windows version of netcat. Unlike the Unix version, it doesn&rsquo;t automatically close the connection when it reaches the end of the piped input. So unfortunately this is a very slow web server, unless someone knows how to fix this?<br>
For kicks, here&rsquo;s how to serve a &ldquo;dynamic website&rdquo; that reports the current time:<br>
<br>
while(1) { &quot;The time is $([datetime]::now)&quot; | nc -w1 -l -p 8080 }<br>
Try hitting refresh in your browser a few times to confirm that this is really working.<br>
<br>
<br>
And here&rsquo;s a dynamic REST API that returns the current time in JSON<br>
<br>
while(1) { [datetime]::now | convertto-json | nc -w1 -l -p 8080 }<br>
<br>
<br>
Inspired by&nbsp;Web server in one line of bash</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://blog.lukesampson.com/cowsay-in-powershell#53934</guid>
          <pubDate>Tue, 23 Aug 2022 13:14:40 -1200</pubDate>
        <link>http://blog.lukesampson.com/cowsay-in-powershell</link>
        <title>Cowsay in Powershell</title>
        <description></description>
        <content:encoded><![CDATA[<p>&nbsp;I&rsquo;ve been working on a command-line installer for Windows called&nbsp;Scoop, and I wanted to have some interesting programs to demo it with.&nbsp;Cowsay&nbsp;seemed like an obvious choice.<br>
<br>
 ------------<br>
&lt; Try Scoop! &gt;</p>

<hr>

<p>\   <sup>__^</sup><br>
         \  (oo)_______<br>
            (__)\       )\/\<br>
                ||----w |<br>
                ||     ||<br>
<br>
<br>
So I wrote&nbsp;Cowsay in Powershell, trying to follow the functionality of the original Perl version as closely as I could. Afterwards I found that John Kane had already done a PS&nbsp;port&mdash;so I&rsquo;m not the only one who considers this an essential program for the Windows command-line.<br>
There are some benefits to using my version though&mdash;it supports (or at least tolerates) the&nbsp;same parameters as the original, so you can use cowthink, change the eyes, pipe your message from another program or specify one of 46 built-in cowfiles (or even use your own).<br>
<br>
$ &quot;What powers hell?&quot; | cowthink -f daemon</p>

<hr>

<p>( What powers hell? )</p>

<hr>

<p>o         ,        ,<br>
    o       /(        )<code><br>
     o      \ \___   / |<br>
            /- _</code>-/  &#39;<br>
           (/\/ \ \   /\<br>
           / /   | <code>\<br>
           O O   ) /    |<br>
</code>-<sup>--&#39;`&lt;</sup>     &#39;<br>
          (<em>.)  _  )   /<br>
           `.</em><strong>/<code>/<br>
</code>-----&#39; /<br>
&lt;----.     __ / __   \<br>
&lt;----|==<mark>O)))</mark>) ) /====<br>
&lt;----&#39;    <code>--&#39;</code>.</strong>,&#39; \<br>
             |        |<br>
              \       /<br>
        ___<strong><em>( (</em>  / _</strong>___<br>
      ,&#39;  ,-----&#39;   |        \<br>
      `--{__________)         \/<br>
<br>
<br>
If you&rsquo;d like to try it out, you can install&nbsp;Scoop&nbsp;and then run:&nbsp;<br>
<br>
$ scoop install cowsay</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://blog.lukesampson.com/figlet-in-go#53933</guid>
          <pubDate>Wed, 10 Aug 2022 22:19:29 -1200</pubDate>
        <link>http://blog.lukesampson.com/figlet-in-go</link>
        <title>Figlet in Go</title>
        <description></description>
        <content:encoded><![CDATA[<p>I&rsquo;ve just finished porting&nbsp;Figlet&nbsp;to the Go programming language. Figlet is a program&nbsp;originally written in 1991&nbsp;that prints out large ASCII-art letters from the plain text you provide, e.g:<br>
<br>
 ,          _   _<br>
/|   |     | | | |      |<br>
 |<strong><em>|  _  | | | |  _</em>  |<br>
 |   ||/  |/  |/  /  _|<br>
 |   |/|</strong>/|<strong>/|</strong>/__/ o<br>
<br>
<br>
As with porting&nbsp;Cowsay to Powershell, I mainly did this so I&rsquo;d have interesting programs to demo&nbsp;Scoop&nbsp;with. If you&rsquo;re on Windows and you have Scoop installed, you only need to type &ldquo;scoop install figlet&rdquo; and you can start playing around.<br>
I did try getting the full C version to build and run on Windows under MSYS, but only got as far a bunch of gibberish being printed. I was way out of my depth, so I decided to port the C code to Go instead.<br>
There were a couple of benefits to using Go. The first being that I could learn a bit about Go, which I really enjoyed. The second is that it should be cross-platform.&nbsp;</p>
]]></content:encoded>
      </item>
  </channel>
</rss>