Andreas Longo
  • Blog
  • Contact
  • Training

Things I learned

Some notes that might be valuable.

all | by date | by topic | search

Rust: Printing a short CLI usage message with clap

Clap can print a short usage message rather than the full help text. File: Cargo.toml [package] edition = "2021" # --snip-- [dependencies] clap = { version = "4.4.0", features = ["derive"] } File: src/main.rs use clap::CommandFactory; use clap::Parser; #[derive(Parser)] struct Cli { /// First arg arg1: String, /// Second arg arg2: Vec<String>, } fn main() { let mut cmd = Cli::command(); println!("{}", cmd.render_usage()); } Result al@linux ~ $ ./clap_test Usage: clap_test <ARG1> [ARG2]....

August 28, 2023

PowerShell: Fixing terminal input issues

When you start PowerShell and you are not able to enter any commands (copy/paste might still work), chances are your PSReadLine module is outdated. Fix: Update PSReadLine module Get-Module PSReadLine Version 2.0.0 # Open cmd.exe as admin and run: powershell -noprofile -command "Install-Module PSReadLine -Force" Get-Module PSReadLine Version 2.2.6

July 31, 2023

Windows: Testing network connections

Verifying that one system can connect to another system via network is a common task for managing applications. A business application that is not interconnected to some other entity is hard to find. This is a quick way to test some basic network connections on Windows without much dependencies. All you need is PowerShell and .NET which should already be included on most Windows hosts. You create a custom TcpListener (which is an instance of a ....

July 25, 2023

Windows: Publishing a remote terminal app

When working with centrally hosted applications on Windows, I often provide such programs as RemoteApp for a good user experience. A remote app runs remotely on a terminal server, but the look and feel for a user is more like a locally installed app on a client computer - e.g. the app has its own resizable window and its own taskbar entry. Publishing a remote app For publishing remote apps, I use a variation of the following command....

July 19, 2023

Git: Fixing GPG signing errors

I use GPG to sign Git tags. This is a list of signing errors I encountered and possible solutions. # Error: $ git tag --sign --message 'Release 2023.07.13' 2023.07.13 # --snip-- gpg: signing failed: No pinentry error: unable to sign the tag # Problem: # This can happen in a container if GPG cannot find a tool to ask the user for a passphrase. # https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html # Solution: dnf install pinentry # Error: $ git tag --sign --message 'Release 2023....

July 18, 2023

Repairing video files with FFmpeg

I often record a short screencast to document some process rather than taking a long series of screenshots. To me this is more effective to produce and most of the time also more convenient to consume later on. When I need some screenshots for written or printed documentation, I take them from the screencast after the fact. For recording, I use the GNOME builtin recorder. It is instantaneously ready to use and requires no fiddling with settings or file paths....

July 13, 2023

Unix-like `watch` and `tail` commands for PowerShell

There is no equivalent to the Unix watch command on Windows, but you can get close enough behavior. Watching commands with PowerShell # Similar to `watch <command>` PS> while ($true) {<your command>; sleep -Seconds 2} PS> while ($true) {(Get-Service -Name 'Remote Desktop Services').Status; sleep -Seconds 2} Running Running You can also follow log file output similar to the Unix tail command. Tailing logs with PowerShell: # Similar to `tail --follow <filename>` PS> Get-Content -Path <logfile> -Tail 10 –Wait PS> Get-Content -Path 'C:\app....

April 13, 2022

MSSQL: Configure an alias for SQL connections

You can use the SQL Server Configuration Manager to configure an alias for connections to a MSSQL instance. But on some versions of Windows, the configuration manager is not available as a regular application. You might find it as a snap-in for the Microsoft Management Console (MMC). If the configuration manager is generally not available on your system, you can instead use this tools to set an alias: # 64 bit version C:\Windows\System32\cliconfg....

April 12, 2022

Creating a new image from a running container

You can save the state of a running container as a new image. This is somewhat similar to "creating a snapshot" when working with virtual machines. If you use Docker, just replace podman with docker in the below commands. $ podman container commit <container name or id> <new-image:tag> $ podman container commit ansible ansible:2022-04-11

April 11, 2022

Git: Signing an already pushed commit

Given you have created a pull request (PR) with a single commit on GitHub. The commit is not GPG-signed. The maintainer asks you to sign the commit. If you are the only one working (committing) to this PR, you can force-push a signed commit. # Sign the latest commit on your local repository git commit --amend --no-edit --gpg-sign # Force push the commit to your remote repository (fork) git push --force-with-lease GitHub will automatically update your PR....

April 9, 2022
Next  »
© 2023 Andreas Longo