Category: programming

VS Code – disable inline MDN suggestions

VS Code has this setting on by default – as I start typing it tries to suggest some MDN references. It took me forever to figure out how to set this off.

Every time I’m setting up VS Code on a new machine, I forget what this setting is!

"editor.parameterHints.enabled": false,

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

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

How to require multiple files in irb from command line

Recently, I had the need to run Ruby’s irb with multiple files already loaded.

After a bit of trial and error I came up with this which worked perfectly!

irb -r ./file1.rb -r ./dir/file2.rb

The files get loaded in order so if there are any dependencies in file2.rb on something in file1.rb, that works correctly.

Disable browser caching in Ruby Roda app

Recently, writing a plain Roda app, I was facing a caching problem. I had a list and a detail page and whenever there was a list item clicked on I was using the flash plugin to maintain the item selected and highlighting the item when the list page was loaded.

However, on navigating back via the browser button, the cached page was showing up and the highlight would be on the previous selected item or not there at all.

Continue reading

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

‘asdf’ not finding program

I discovered asdf quite late! I was relying on a bunch of different programs to manage Ruby (rvm), Node (nvm).

asdf was an amazing headache saver. It already has core plugins for Elixir, Erlang, Node and Ruby. Plus, it has community plugins for what seems like practically anything under the sun.

I had installed asdf on a new system. And as usual, there were some crons to run on it. I kept getting a /bin/bash/ruby not found error.

After some time I realized I had faced this problem before as well!

Continue reading

Ruby Sequel migration – increment column in a group

The requirement was to add a column called position to the order_details table.

The order_details table is actually a table with a foreign key of order_id. The requirement is to increment the position starting from 1 in the position column grouped on order_id.

So, before the migration if the records are –

id  order_id
1   1
2   1
3   1
4   2
5   2
6   2

After the migration, the records should be –

id  order_id position
1   1       1
2   1       2
3   1       3
4   2       1
5   2       2
6   2       3

There are two solutions possible. One using window functions and one without.

Continue reading

Copyright © 2026 the möbius trip

Theme by Anders NorenUp ↑