TIL (Today I Learned)

Quick notes about things I learn every day. Small discoveries, tips, tricks, and “aha!” moments.

Git Interactive Rebase for Clean History

· git productivity

Learned about git rebase -i today. You can squash multiple commits into one before pushing!

git rebase -i HEAD~3

Then mark commits as squash or fixup. Makes PR history much cleaner. Wish I knew this earlier.

Python Walrus Operator (:=)

· python syntax

The walrus operator (:=) in Python 3.8+ lets you assign and use a variable in the same expression:

# Instead of:
data = fetch_data()
if data:
    process(data)

# You can write:
if data := fetch_data():
    process(data)

Cleaner code, especially in list comprehensions!

Hugo Page Bundles for Co-located Assets

· hugo web-dev

Hugo has “page bundles” where you can put images next to your markdown file:

content/
  posts/
    my-post/
      index.md
      image1.jpg
      image2.jpg

Then reference images with just ![](image1.jpg). No need for /static/ paths. Game changer for organizing content!

CSS Container Queries Are Here!

· css responsive-design

Container queries let you style elements based on their parent’s size, not viewport:

.card-container {
  container-type: inline-size;
}

@container (min-width: 400px) {
  .card {
    display: grid;
    grid-template-columns: 1fr 2fr;
  }
}

Better than media queries for component-based design. Supported in all modern browsers now!