Monday, August 12, 2019

Moon, Saturn, and Jupiter at Night Sky

Stepping out at this Friday night, I happened to see a few bright astronomical bodies in the night sky.  A striking view was that Saturn, Moon, and Jupiter were lined up in an almost straight line. Can you spot the two planets and the Moon in this low-quality cellphone photo?


It also happened that above my head were two bright stars, Altair and Vega that were supposedly separated by the Milky Way -- I say "supposedly" because the Milky Way wasn't visible at all in this light-polluted city park. In both western and eastern folklore and cultures, these two have had interesting histories and stories that often inspire romances. In Chinese folklore, Altair and Vega are a couple whose love are banished. Against all odds, Altair and two nearby but much darker stars β-Aquilae and γ-Aquilae at one side of the river, i.e., the Milky way are meeting his wife and the children's mother, the Weaving girl, Vega at the other side of the river. I wish I had had taken a photo of these beloved stars.

Wednesday, August 7, 2019

Installing Jekyll on Windows 10 with Windows Subsystem for Linux

Following the Jekyll document, I installed Jekyll on Windows 10 with Windows System for Linux. The steps were as follows:

  1. Enable Windows Subsystem for Linux following Microsoft's documentation, i.e., 
    1. In Windows 10, open PowerShell as Administrator.
    2. Run the following in PowerShell

      Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
      

    3. Restart Windows
  2. Download and install a Linux distribution from Microsoft Store by opening the following URL in a Web browser: https://aka.ms/wslstore
  3.  Open a Windows Command Prompt window, and run

    bash
    

  4. Run the following in bash
    
    sudo apt-get update -y && sudo apt-get upgrade -y
    sudo apt-get install -y --no-install-recommends software-properties-common gnupg gpg-agent dirmngr 
    sudo apt-add-repository ppa:brightbox/ruby-ng
    sudo apt-get update
    sudo apt-get install -y ruby2.5 ruby2.5-dev build-essential dh-autoreconf zlib1g-dev
    sudo apt-get install bundler
    sudo gem update
    

  5. Assume you have a Jeykll site at the www directory. Then go to the directory in bash
    
    cd www
    

  6. In bash, run the following
    
    cd www
    bundle update
    bundle install
    
  7. Build the site and launch the Web serer for testing.
    
    bundle exec jekyll serve --host=0.0.0.0 --incremental
    

Wednesday, July 31, 2019

Adding Github Repository as a Dependecy to Java Project

I just learned that we could easily add a Github repository as a dependency to a Java project using JitPack. Below is an example to a Maven project to which we wish to add JGraphX as a dependency to the Maven project. Since JGraphX "don't properly support Maven or publish to Maven Central", this comes very handy. I view this as a two step approach:

  1. Add JitPack to the pom.xml. I added the following just above the dependencies tag:
    
    <repositories>
     <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
     </repository>
    </repositories>
    
  2. Add a Git commit or release of a Git repository as a dependency. In the following, we use the JGraphX project as an example. The project's Git repository is the JGraphX repository whose url is https://github.com/jgraph/jgraphx.git, from which we read that the Github username is jgraph, and the repository name is jgraphx. Browsing the project repository, we can select a commit by using its commit id (i.e., commit hash), or a tag, or a release. The JGraphX has a number releases as seen at https://github.com/jgraph/jgraphx/releases, among which is v4.0.3. Having gathered the Github username, the repository name, and the release number, we add the following as a child tag to the dependencies tag,
    
     <dependency>
      <groupId>com.github.jgraph</groupId>
      <artifactId>jgraphx</artifactId>
      <version>v4.0.3</version>
     </dependency>
    
After these two steps, we do a Maven update.

Friday, July 12, 2019

Looking up TexLive Package Name using .sty Filename

I am using TexLive, and sometimes it reports that it cannot locate a .sty file. It is not always the case that the package name is identical to the .sty filename (less the extension). For instance, when LaTeX reports that it cannot locate manyfoot.sty. The following will fail because the package that has manyfoot.sty isn't manyfoot.

$ tlmgr install manyfoot
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr.pl install: package manyfoot not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: An error has occurred. See above messages. Exiting.

A method to figure out the package name is to use tlmgr to search TexLive repositories, i.e.,

tlmgr search --global --file STY_FILE_NAME

For the example of manyfoot.sty, we do,

$ tlmgr search --global --file  manyfoot.sty
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
lwarp:
        texmf-dist/tex/latex/lwarp/lwarp-manyfoot.sty
ncctools:
        texmf-dist/tex/latex/ncctools/manyfoot.sty

after which we do,

$ tlmgr install ncctools
tlmgr.pl: package repository http://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: ncctools [2430k]
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: package log updated: C:/Applications/texlive/2019/texmf-var/web2c/tlmgr.log

Saturday, June 22, 2019

Finding Windows Uptime from Command Line

To get Windows uptime from the command line, we can instead obtain the boot time of the system, and subtract it from current time. To obtain the boot time, we can do the following,

On a Windows server,

net statistics server | find "Statistics since" 


On a Windows workstation

net statistics workstation | find "Statistics since"


Alternatively, we can use the following,

systeminfo | find "System Boot Time:"

or

wmic path Win32_OperatingSystem get LastBootUpTime

or

echo (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime | powershell

Friday, June 7, 2019

PostgreSQL Password File

To access a PostgreSQL database, we may use a Password file. We can place the Password file any where and references to it via a PGPASSFILE environment variable. Here is an example on Windows:



C:\Work>type ./pgpass
# hostname:port:database:username:password
foodbhost:5432:foodb:foouser:foopassword

C:\Work>set PGPASSFILE=./pgpass

C:\Work>psql -U foodbuser -h foodbhost foodb
psql (9.6.3)
Type "help" for help.

foodb=>

Using this method, we help separate the DB authentication and authorization from the application logic. 

Sunday, June 2, 2019

Making New Git Repository from Directories in Existing Git Repository

I want to make a new Git repository from a few directories in an existing Git repository. I found the solution provided in this Stack Overflow answer was exactly what I wanted.