comment line and duplicate snippet for VS Code with keyboard shortcut

Multiple times during the day, I comment a line and then duplicate it with some minor changes. This whole action does not take much time individually but over the course of days and years, I think I’ve wasted a lot of time on this!

This has been overdue for a long time, and I should have created a snippet for this earlier, but never got around to it.

So, I’ll create a snippet which does exactly that and map it to keyboard shortcuts so that the same shortcut works across multiple programming languages.

Continue reading

Run caddy as a non-root user on Ubuntu

Any process can be run as a non-root user service.

The first criteria to have a service as a non-root user is to have the service be kept running even when the user is not logged in.

However, having a web server places an additional challenge – port 80 and port 443 which are basically the http and the https ports need to be bound by a user with administrative privileges because they are lower ports.

Continue reading

Fossil Activity Graph

I’ve been a bit envious of the activity graph that Github creates for the checkins happening across all repositories by a developer.

Since I’ve always been using fossil across projects, I thought I could do the same with fossil as well.

Fossil repositories being SQLite databases themselves made things a bit easier.

Continue reading

Restrict access to part of path in Nginx

So, I have a site, let’s call it example.com. But I have multiple levels of directories under it. I have directories like /example.com/repositories and the actual repositories at the next level like so example.com/repositories/abcd or example.com/repositories/efgh.

Now, I only want access to example.com/repositories restricted. Everyone should be able to access the root level i.e. example.com and the nested subdirectories i.e. example.com/repositories/*.

Continue reading

Add a confirmation on a rake task

Many times on a rake task it’s better to have a confirmation before continuing the task. This is especially required before important tasks like a deployment or a database migration in production.

Adding a gets doesn’t work at all. To overcome this, we can add a confirm task which is run before the actual task is run.

Continue reading

Nginx config for SvelteKit SPA

For creating a SvelteKit SPA app, we first need to set up SvelteKit to have all the pages pre-rendered. For this, for every +page.svelte we need to add a +page.server.ts or a +page.server.js with the following –

export const prerender = true;
export const ssr = true;

This will create the corresponding pages for each route. For example, if we have a URL like example.com/about, we will have an about.html page getting created.

However, putting the build folder directly under a simple nginx config doesn’t work. Since the URL does not have an .html extension, even if those pages are there, nginx doesn’t show them.

Continue reading

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>

Copyright © 2025 the möbius trip

Theme by Anders NorenUp ↑