Category: system admin

Powershell – find alias or function in profile by pattern

Since I have lots of aliases and functions in my profile, frequently I need to search them by some pattern.

This Powershell function lets me do just that.

function ff {
  param(
    [string]$Pattern
  )

  # Define the path to the PowerShell profile
  $profilePath = $PROFILE

  # Check if the profile exists
  if (-not (Test-Path $profilePath)) {
    Write-Host "Profile script does not exist at $profilePath"
    return
  }

  # Define the patterns to search for aliases and functions
  $patterns = "Set-Alias.*$Pattern", "New-Alias.*$Pattern", "function.*$Pattern"

  # Search the profile for the specified pattern
  # Select-String -Path $profilePath -Pattern $patterns
  Select-String -Path $profilePath $patterns
}

Now, all I need to do is type this to find the matching line and the actual function in my profile.

> ff <pattern>

Ruby OpenSSL::SSL::SSLError – SSL_connect returned=1 errno=0 unsafe legacy renegotiation disabled

So, all of a sudden, one of our servers, while trying to connect to another, started giving this cryptic error –

OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 unsafe legacy renegotiation disabled

These kind of errors are usually dependent on some system updates. But the error seemed to be coming from the target server. After a bit of searching around, this article gave the most understandable information.

From that article –

This “unsafe legacy renegotiation disabled” error happens when connecting to outdated endpoints that do not support RFC 5746 secure renegotiation. Ideally, the endpoints causing these errors should be upgraded for security reasons. 

In the same article, they mention that it should be possible to remove this security check, but the solutions mentioned there didn’t work.

Continue reading

fzf – error when pressing Ctrl+R

I’ve become a big fan of fzf since I discovered it.

However, after a recent upgrade, when I pressed Ctrl+R, I got the following error –

unknown option: --scheme=history

After some searching, found the following solution.

Remove fzf from /usr/bin/ and relink it.

Run these two commands in order –

sudo rm /usr/bin/fzf
sudo ln -s ~/.fzf/bin/fzf /usr/bin/fzf

install fzf on Linux

fzf is a serious timesaver. To be able to quickly go through past commands and in a fuzzy manner, especially when you don’t recall the exact command is a Godsend!

To install fzf on Linux, we need to

a) clone the repository into the system

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf

b) run the command which will add the relevant shortcut keys

~/.fzf/install --all

There are a bunch of other stuff that can be done once fzf is installed. For example, to see instant file previews –

fzf --preview 'less {}'

And if there is bat also installed, then the previews can show syntax highlighting and line numbers also!

fzf --preview 'bat --color=always --style=numbers --line-range=:100 {}'

Windows – Path changes not updating

Multiple times when I change the path on Windows, via the ‘Environment Settings’ dialog, those changes don’t apply.

Even when I reopen the command prompt, the settings don’t seem to be there.

So, either I would log out of Windows completely and log back in or do a system restart. This was a big pain and God knows how much time I’ve wasted with this!

Recently, I got tired of this and decided to dig in a bit deeper and finally found the answer!

Continue reading

upgrading bitwarden / vaultwarden

I had posted earlier about running Vaultwarden (a Bitwarden server in Rust). This has been running amazingly all this time.

But today, when I tried to log in from the browser extension, I kept getting an error.

Searching in the forum, I found the issue – I had to update the Vaultwarden server.

Since I was running Vaultwarden as a Docker container, and I had run the docker command directly, so I decided to create a docker-compose.yml file instead this time.

Continue reading

Nginx – folders as subdomains

I have a projects folder in which I put multiple folders, each having an html page.

So, the folder hierarchy looks something like this –

projects
|-sampleproject1
  |-index.html
  |-style.css
|-sampleproject2
  |-index.html
  |-style.css

I want to have each of these folders as subdomains to my domain, so I had to create an nginx conf file for each one with a different root path.

I was looking for way to have this done automatically using Nginx and finally found it!

Continue reading

Postgres pg_dump without password

I have to do a dump of a Postgres database on a regular basis.

So pg_dump is the obvious choice to do this as is cron to do this periodically.

But the main problem with this is – pg_dump expects a password to be entered at the prompt. There’s no way to pass the password in the prompt to be able to do this.

Stackoverflow to the rescue.

What is required is a .pgpass file in the home directory.

Continue reading

Copyright © 2024 the möbius trip

Theme by Anders NorenUp ↑