Running Migrations From Console

Note: I am using Apartment gem to manage my multi schema database, and this article is written with expectation you know and use that gem.

When you have multiple schema in your rails application, it is important for them to remain consistent. Rails migration is run by keeping track of the timestamp prefixed in front of its file name. It stores the database. So when you restore a schema that hasn’t ran the migration, but rest of the schemas has it, rails thinks it has already ran the migration. Rails look at the main / default schema to know if it has ran the migrations and then follow up on the rest.

Access History in IRB

Accessing the list of commands you have ran in your irb or rails console.

Running the following command in your console Readline::HISTORY.to_a returns the array of commands you have typed in console. After which you can treat it like any other array in ruby - search, sort, etc.

Remote Coding Using Tailscale and Code Server

This tutorial or concept uses two softwares to make remote coding on your home machine possible.

  1. Tailscale
  2. code-server

Tailscale is basically a VPN using open source wireguard protocol. It creates an encrypted point to point connection so that only your devices can talk to each other.

So you can build a secure connection between your two computers over the internet. These two computers can be across the world, and they will be as if they are on a same network.

Adding New Key per User to AWS EC2 Instance

When we create a new server in aws, it allows us to generate a key pair and attach it to the server. Now imagine you want to share access to this multiple people in your team, but you don’t want to share your private key. This is what you need to do.

  • Generate new key for each member of your team or ask each member for there public keys
  • Add it to the authorized_keys list in your servers .ssh folder

HTOP for GPU in Linux

htop/top is a useful command that helps users understand how much of there CPU (Different core)/RAM are being used. We would like to see the same for GPU there are tools that provide that, but sadly unlike cpu top/htop the ones for GPU are sadly fragmented. Based on your GPU vendor we have different tools to provide us this graphical info.

Note: I am talking about tools i tested in Ubuntu/Debian Linux