Run command periodically automatically 2025/11/14 Fri - 04:06 AM
You can use watch to run a command periodically. I used this to see how many active connections on Redis using redis-cli as well:
watch -n 1 "redis-cli CLIENT LIST | wc -l"Go back
Here show everything that I learned in some way during my day.
1.
Run command periodically automatically 2025/11/14 Fri - 04:06 AM
You can use watch to run a command periodically. I used this to see how many active connections on Redis using redis-cli as well:
watch -n 1 "redis-cli CLIENT LIST | wc -l"2.
Postgres is awesome 2025/09/08 Mon - 12:59 AM
While reading Stop Building for “Scale.” You Don’t Have Users Yet by Shayan, I realized what just PostgreSQL has to offer:
pgvectorIf you’re wondering if this will not scale, I recommend reading the original post before jumping to conclusions.
3.
Use multiple directories of the same Git repo with git worktree 2025/09/05 Fri - 02:19 PM
git worktree is a Git feature that allows you to have multiple working directories linked to the same Git repository. This means you can simultaneously have different branches checked out in separate directories, enabling seamless context switching between tasks without having to stash changes or constantly switch branches within a single working directory.
4.
Use latest version of Alacritty on Ubuntu-based distros 2025/08/09 Sat - 02:21 PM
I tried doing this because I’m currently using Pop!_OS and the version of alacritty available in the apt is outdated. I want to use the latest features and improvements.
One cool way to install it is through Cargo, which allows you to get the latest version directly from the source.
For up-to-date dependencies for your OS and instructions, refer to the official Alacritty installation guide
Install .deb dependencies:
sudo apt install cmake g++ pkg-config libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3If you’re using Wayland on Nvidia GPU, you should also install
libegl1-mesa-devon Ubuntu.
You should have rust installed. Instructions here.
Install Alacritty using Cargo:
cargo install alacrittyYou’ll probably have to add it as an alternative (skip it if it appears as alternative already)
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $HOME/.cargo/bin/alacritty 50Set as default terminal:
sudo update-alternatives --config x-terminal-emulator5.
Aggregations in MongoDB 2025/06/30 Mon - 11:13 PM
An aggregation in MongoDB is used when you want to:
The best way of using aggregation is with aggregation pipelines, where you can have multiple stages. And in each stage you can process documents, from the docs:
6.
Run ESM scripts only when called directly 2025/06/30 Mon - 12:33 AM
I faced an issue when trying to see if a script of my blog was running directly or being imported.
Before ESM I would try:
if (require.main === module) {
run();
}
// otherwise, I could use the import/exports without worrying about it running other stuffBut this throws ReferenceError: require is not defined in ES module scope, you can use import instead if you’re using ESM.
In order to fix it, you can use the following snippet:
import path from 'node:path';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
if (process.argv[1] === fileURLToPath(import.meta.url)) {
run();
}7.
How I improve myself, neuroscientifically 2025/06/26 Thu - 01:32 AM
8.
Use different SSH keys and git configs 2025/06/24 Tue - 02:28 AM
~/.ssh/config fileHost gh_personal
User git
Hostname ssh.github.com
Port 443
IdentityFile ~/.ssh/personal
Host work
User git
Hostname altssh.gitlab.com
Port 443
IdentityFile ~/.ssh/work.gitconfig you can include different config files based on the path you’re on.gitconfig
[user]
name = Your Name
email = your-email@example.com
[includeIf "gitdir:~/www/work"]
path = ~/.gitconfig-work.gitconfig-work
[user]
email = work-email@example.comPersonal key
git clone gh_personal:username/dsa.gitWork key
git clone gh_work:username/dsa.git9.
How to handle errors in Express 2025/06/03 Tue - 07:26 PM
You can throw errors in Express and handle them correctly.
In this gist I put an example of how you can use it with Zod to customize the ZodError to a readable error message.
Before Express V5 you had to use express-async-errors, but now you can do this automatically.
10.
Run TypeScript files directly in Node.js 2025/06/01 Sun - 10:58 PM
You can pass --experimental-strip-types to enable Node.js to run TS files:
node --experimental-strip-types--watch flag to run on watch mode (no need for nodemon anymore!)--env-file=.env to handle the dotenv fileFor more information about type stripping, TypeScript in Node.js and other stuff, see this
11.
Run git commands in Node.js 2025/05/31 Sat - 03:32 PM
I once struggled with updating the updatedAt date of the post on my previous attempts to blog.
simple-git enables me to do this and many other cool stuff with git.
For example, on /now page the updated time can be fetched by passing the file:
const git = simpleGit();
let lastCommit: GitLogCommit | null = null;
const file = path.join(process.cwd(), 'src', 'pages', 'now.astro');
try {
const log = await git.log({ file });
lastCommit = log.latest;
} catch (err) {
console.error(err);
}Then just format it with dayjs:
dayjs(lastCommit?.date).format('YYYY-MM-DD HH:mm');