Blog

Article Tags

Hua Enhancements

By William Jeffrey Rankin, Tue Dec 26 2023

I've made some enhancements to Hua, my PowerShell based static content generator, over the past few days. Formerly, all tagged-with-* files, as well as index and archive files were regenerated every time Hua was run. Now, Hua runs a comparison to determine if the files have actually changed, and replaces them accordingly. In this way, files that haven't really changed are not reuploaded to a remote server by tools that rely simply on date as change criteria (among other use cases).

Related Articles

    Article Tags

    Cygwin's Apache as a Service on Windows

    By William Jeffrey Rankin, Sun Nov 19 2023

    The command line to install Cygwin's Apache as a service on Windows:

    cygrunsrv -I httpd -d "Cygwin HTTPD" -p /usr/sbin/httpd.exe -a '-DNO_DETACH' -s TERM -o
    

    -p specifies the path, -a the arguments passed to Apache, -s the signal to send when the service is stopped, and -o stops the service upon system shutdown.

        Article Tags

        Installing svnserve on Cygwin

        By William Jeffrey Rankin, Wed May 17 2023

        I recently installed a Subversion server and found this article on Steve's Toolbox helpful. Everything in the article worked for me with the exception of the cygrunsrv command that installs the service itself. For reference, here's the command he documents:

        cygrunsrv -install svnserve -disp "CYGWIN svnserve" -path /bin/svnserve -args "-daemon -foreground -root=/cygdrive/c/svn"
        

        Here's the command that worked for me (adjust paths as needed):

        cygrunsrv -I svnserve -d 'Cygwin SVN Service' -p /usr/bin/svnserve -a '-d --foreground -r "/srv/svn"'
        

        Additional Notes

        If you receive permission errors during check in or other operations, make sure svnserve is running under the appropriate user and has access to the repository directory. You can check this by opening Services > Properties > Log On tab.

            Article Tags

            Windows Uptime Using Powershell

            By William Jeffrey Rankin, Sun Nov 27 2022

            About

            A basic version of the Unix uptime command, implemented in PowerShell. Reports uptime only (not user count or load averages). Testing using PowerShell 7.3 and 5.1 on Windows 10.

            Usage & Sample Output

            jeffr@CALLISTO: D:\Documents\Uptime $ .\uptime.ps1
            CALLISTO: 11/27/2022 16:22:20 up 07:12:48
            
            jeffr@IO: C:\Users\jeffr\Documents\Uptime $ .\uptime.ps1
            IO: 11/27/2022 16:24:55 up 2 days, 08:32:54
            

            The Code

            # uptime - Basic PowerShell implementation of the Unix uptime command
            
            # $Author: jeffr $
            # $Date: 2022-11-30 17:04:08 -0500 (Wed, 30 Nov 2022) $
            # $Revision: 4 $
            
            $c_time = Get-Date
            $b_time = Get-CimInstance -ClassName win32_operatingsystem | Select-Object lastbootuptime
            $d_time = New-TimeSpan -Start $b_time.lastbootuptime -End $c_time
            $a_d_time = ($d_time.ToString()).Split(':')
            
            # Days and hours
            if ($a_d_time[0].Contains('.')) {
                $a_days = $a_d_time[0].Split('.')
            
                # Day or days?
                if ($a_days[0] -eq 1) {
                    $d_str = 'day'
                } else {
                    $d_str = 'days'
                }
                $days = "$($a_days[0]) $($d_str), "
                $hours = $a_days[1]
            } else {
                $days = ''
                $hours = $a_d_time[0]
            }
            
            # Minutes
            $minutes = $a_d_time[1]
            
            # Seconds
            $a_seconds = ($a_d_time[$a_d_time.Length - 1]).Split('.')
            
            # Output the result
            Write-Host "$($env:computername): $($c_time) up $($days)$($hours):$($minutes):$($a_seconds[0])"
            

                Article Tags

                Old Farmer's Almanac Sun/Planetary Rise and Set Times

                By William Jeffrey Rankin, Sat Nov 12 2022

                A set of scripts written in the Rexx programming language that produce localized sun/planetary rise/set times based upon data in The Old Farmer's Almanac. These have been replaced by the Astronomical Almanac scripts, but are still occasionally useful.

                Included are supporting libraries (CORTIME.rex and TIMEADJS.rex) and sample data files. The DAY.txt file contains time adjustments for locality and should be replaced with appropriate values for your location (refer to the Time Corrections section in the almanac).

                The scripts have been tested on Cygwin, Linux, Windows 10, and FreeDOS.

                Example Usage

                srss.rex: Takes a file containing uncorrected sunrise and set values from the Old Farmer's Almanac and a file containing time corrections for locality. Pass 'today' as third argument to show results for current day only. Outputs corrected values.

                jeffr@Ganymede: ~/rise-set-times $ regina srss.rex srss-data.txt DAY.txt | tail -n 5
                11/26/2022, 7:32 AM, 5:16 PM
                11/27/2022, 7:33 AM, 5:15 PM
                11/28/2022, 7:34 AM, 5:15 PM
                11/29/2022, 7:36 AM, 5:14 PM
                11/30/2022, 7:37 AM, 5:14 PM
                

                planets.rex: Takes a file containing uncorrected planet rise and set values and a file containing time corrections for locality. Outputs corrected values.

                jeffr@Ganymede: ~/rise-set-times $ regina planets.rex planet-data-2022.txt DAY.txt | tail -n 5
                10/11/2022, Saturn, Set, 2:48 AM
                10/21/2022, Venus, Set, 6:52 PM
                10/21/2022, Mars, Rise, 9:45 PM
                10/21/2022, Jupiter, Set, 5:41 AM
                10/21/2022, Saturn, Set, 2:08 AM
                

                rscli.rex: A simple command line interface to the CORTIME library. Takes an uncorrected time, AM/PM, a file containing time corrections for locality, and correction column. Outputs corrected time.

                jeffr@Ganymede: ~/rise-set-times $ regina rscli.rex 6:32 AM DAY.txt e
                7:16 AM
                

                lod.rex: Takes the output of srss.rex and calculates day lengths.

                jeffr@Ganymede: ~/rise-set-times $ regina srss.rex srss-data.txt DAY.txt \ | tail -n 5 | regina lod.rex
                12/27/2022, 9:06
                12/28/2022, 9:06
                12/29/2022, 9:07
                12/30/2022, 9:08
                12/31/2022, 9:08
                

                Download

                rise-set-times.tar.gz, 7K

                Related Articles

                    Newer Articles Older Articles