Blog

  • Angular Signals: A New Era of Reactivity in Angular

    Angular’s reactivity model has traditionally relied heavily on RxJS, but with the introduction of Signals in Angular 16+, the framework has entered a new phase. Signals are a fresh and powerful way to manage reactive state without the boilerplate and learning curve of observables. Let’s dive into what Angular Signals are, how they work, and why you should care.


    What are Signals?

    A Signal is a wrapper around a value that can notify subscribers when that value changes. Think of it as a reactive variable—when its value is updated, any computation or component that depends on it is automatically updated.

    At their core, Signals provide:

    • Automatic dependency tracking
    • Push-based updates
    • Synchronous reads
    • Fine-grained reactivity

    They aim to simplify state management and reduce the cognitive load compared to more complex patterns like BehaviorSubject and manual subscription handling.


    Why Signals?

    Here’s why Angular introduced Signals:

    1. Simplicity: Easy to understand and use, even for beginners.
    2. Performance: Fine-grained reactivity enables fewer unnecessary change detections.
    3. Integration: Works seamlessly with the Angular rendering engine.
    4. Type Safety & Tooling: Fully typed and IDE-friendly.

    Getting Started with Signals

    You can start using signals by importing them from @angular/core.

    import { signal, computed, effect } from '@angular/core';

    Example: A Counter with Signals

    import { Component, signal, computed, effect } from '@angular/core';
    
    @Component({
      selector: 'app-counter',
      template: `
        <h2>Counter: {{ count() }}</h2>
        <button (click)="increment()">Increment</button>
      `
    })
    export class CounterComponent {
      count = signal(0);
    
      double = computed(() => this.count() * 2);
    
      constructor() {
        effect(() => {
          console.log('Count changed:', this.count());
        });
      }
    
      increment() {
        this.count.update(value => value + 1);
      }
    }

    Here’s what’s happening:

    • signal(0) creates a reactive signal.
    • count() is how you read the signal value.
    • count.update(...) is how you write to it.
    • computed() defines a derived reactive value.
    • effect() is a reactive side-effect that re-runs when dependencies change.

    Signals vs Observables

    FeatureSignalsObservables (RxJS)
    Push model✅ Yes✅ Yes
    Pull/synchronous read✅ Yes (count())❌ No (subscribe() only)
    Cleanup mechanism✅ With effect teardown✅ With unsubscribe
    Learning curve🟢 Low🔴 Moderate-high
    Operators⚠️ Limited (for now)✅ Rich (map, switchMap…)
    Debugging✅ Easier⚠️ Harder in complex chains

    When to Use Signals

    Use Signals when:

    • You want reactive local state in a component.
    • You need derived state (computed) or reactive side-effects (effect).
    • You want a simpler alternative to BehaviorSubject or NgRx for small apps.

    Stick with RxJS when:

    • You’re dealing with async streams, like HTTP requests or WebSocket data.
    • You need complex stream transformations with operators like mergeMap, debounceTime, etc.

    Testing with Signals

    Testing signals is straightforward since they’re synchronous:

    it('should increment the count', () => {
      const count = signal(0);
      count.update(v => v + 1);
      expect(count()).toBe(1);
    });

    No need to worry about fakeAsync, zones, or subscription cleanup!


    Future of Signals in Angular

    Signals are a core part of Angular’s reactivity roadmap. Upcoming improvements include:

    • Signal-based forms
    • Better dev tools support
    • Signal-aware change detection
    • Integration with the Angular Control Flow syntax (@if, @for)

    As Angular continues to modernize, Signals will become a key tool for cleaner, faster, and more maintainable apps.

  • VSCode Shortcut Cheat Sheet for Web Developers

    Visual Studio Code (VSCode) is more than just a code editor—it’s a productivity powerhouse when you know the right shortcuts. Whether you’re debugging, navigating files, or editing code, mastering these time-saving key combos can dramatically speed up your workflow. In this post, we’ll cover essential VSCode shortcuts that every developer should have at their fingertips.

    File & Editor Navigation

    Ctrl + P: Quick open file by name

    Ctrl + Shift + O: Go to symbol in file

    Ctrl + G: Go to line

    Ctrl + Tab: Switch between open editors

    Ctrl + B: Toggle sidebar visibility

    Ctrl + `: (backtick): Toggle terminal

    F12: Navigate to the definition of a variable, function, or class.

    Alt + F12: View the definition inline without leaving your current file


    Editing Code

    Ctrl + D: Select next match (multi-cursor)

    Alt + Click: Add a new cursor

    Ctrl + /: Toggle line comment

    Shift + Alt + A: Toggle block comment

    Alt + ↑ / ↓: Move line up/down

    Shift + Alt + ↓ / ↑: Copy line up/down

    Ctrl + Shift + K: Delete line

    Ctrl + Space: Trigger suggestion/autocomplete

    F2: Rename all instances of a variable or function across your code.

    Ctrl + F2: Multi-select and edit all occurrences of a word.

    Shift + Alt + F: Auto-format your code using the configured formatter (Prettier, ESLint, etc.).


    Search & Replace

    Ctrl + F: Find

    Ctrl + H: Replace

    F3 / Shift + F3: Find next / previous

    Ctrl + Shift + F: Search across files


    File Management

    Ctrl + N: New file

    Ctrl + S: Save

    Ctrl + Shift + S: Save as

    Ctrl + W: Close file

    Ctrl + Shift + T: Reopen closed editor


    Run & Debug

    F5: Start debugging

    Ctrl + F5: Run without debugging

    F9: Toggle breakpoint

    F10 / F11: Step over / Step into


    Command Palette & Settings

    Ctrl + Shift + P: Open Command Palette

    Ctrl + ,: Open settings

    Ctrl + K Ctrl + S: Keyboard shortcuts reference

    Mastering VSCode shortcuts and commands isn’t just about saving time—it’s about working smarter. With the right key combos and tools at your fingertips, you can streamline your development workflow and focus more on writing great code. Whether you’re a seasoned developer or just starting out, building muscle memory for these commands will pay off in every project. Happy coding!

  • Understanding SQL Joins: The Ultimate Beginner’s Guide

    SQL joins can seem intimidating at first, but they’re one of the most powerful tools in your data toolbox. They let you combine data from multiple tables based on related columns — unlocking insights that live across your database.

    What is Join in SQL?

    A JOIN connects rows from two or more tables based on a related column — usually a foreign key. Think of it as forming meaningful conversations between tables.

    Customer Table

    idnamecountry
    1AliceUSA
    2BobCanada
    3CharlieUK
    4DianaAustralia
    5EthanGermany

    Orders Table

    idcustomer_idproductamount
    1011Laptop1200
    1021Headphone150
    1032Smartphone800
    1044Monitor300
    1056Keyboard100

    4 Most common SQL JOINs

    1. Inner JOIN

    Returns only matching rows from both tables.

    SELECT * FROM orders
    INNER JOIN customers ON orders.customer_id = customers.id;

    Use it when: You want data only where both side have a match

    2. LEFT JOIN (LEFT OUTER JOIN)

    Return all rows from the left table, and matched rows from the right. Null if no match.

    SELECT * FROM customers
    LEFT JOIN orders ON customer.id = orders.customer_id;

    Use it when: You want to keep everything from the left table.

    3. RIGHT JOIN (RIGHT OUTER JOIN)

    Returns all rows from the right table, and matched rows from the left.

    SELECT * FROM orders
    RIGHT JOIN customers ON orders.customer_id = customers.id;

    Use it when: You want to keep everything from the right table.

    4. FULL JOIN (FULL OUTER JOIN)

    Returns all records when there is a match in either table. Nulls where there’s no match.

    SELECT * FROM customers
    FULL JOIN orders ON customers.id = orders.customer_id;

    Pro Tips: Use Aliases for cleaner SQL

    SELECT c.name, o.amount
    FROM customers c
    LEFT JOIN orders o ON c.id = o.customer_id;

  • Configuring Apache Virtual Hosts with SSL via Certbot

    Setting up HTTPS on your website might seem a bit intimidating at first—especially when you’re dealing with Apache virtual hosts and SSL certificates. I’ve been there too, and I know how many moving parts there can be. That’s why I put together this simple, step-by-step guide to help anyone—whether you’re just getting started or need a quick refresher—secure your site using Certbot and Let’s Encrypt.

    In this post, I’ll walk you through the process of configuring your Apache virtual host, installing a free SSL certificate, and making sure everything stays up and running with auto-renewals. Hopefully, this helps make the path to a more secure web feel just a little smoother.

    Let’s dive in.

    Prerequisites

    • Apache installed and running
    • A registered domain name pointed to your server’s IP
    • sudo access on the server
    • Certbot and the Apache plugin installed

    Step 1: Install Certbot + Apache Plugin (if not already)

    sudo apt update
    sudo apt install certbot python3-certbot-apache

    Step 2: Step 2: Configure Apache Virtual Host

    Edit / Create Virtual Host file

    sudo nano /etc/apache2/sites-available/yourdomain.com.conf

    Basic Example:

    <VirtualHost *:80>
        ServerName yourdomain.com
        ServerAlias www.yourdomain.com
        DocumentRoot /var/www/yourdomain.com
    
        <Directory /var/www/yourdomain.com>
            Options -Indexes +FollowSymLinks
            AllowOverride All
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/yourdomain_error.log
        CustomLog ${APACHE_LOG_DIR}/yourdomain_access.log combined
    </VirtualHost>

    Enable and reload it

    sudo a2ensite yourdomain.com
    sudo systemctl reload apache2

    Step 3: Step 3: Get the SSL Certificate with Certbot

    Use the Apache plugin to automatically configure HTTPS:

    sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

    Certbot will:

    • Obtain a certificate
    • Update your Apache config with SSL settings
    • Reload Apache

    Step 4: Auto-Renewal Check

    Certbot sets up a cron job or systemd timer. You can test it:

    sudo certbot renew --dry-run

    Congratulations! Now your site should be accessible via https://yourdomain.com