webdev

System Design: CAP Theorem

System Design: CAP Theorem

Imagine you and a friend are watching the same live football match but on different devices. One device shows the final whistle has blown, while the other still displays a tense final minute on the clock. Frustrating, right? This seemingly simple scenario highlights a fundamental concept in distributed systems: the CAP theorem. Before we dive deeper into trade-offs and debates regarding the CAP theorem let's first understand what CAP stands for: consistency: consistency in CAP theorem(different than the consistency in ACID) stands for the guarantee that the read receives the most recent write. Availability: Guarantee that a read returns data…
Read More
Mastering Scoped CSS in Vue: Deep Selectors, Slotted Content, Global Styles, and More

Mastering Scoped CSS in Vue: Deep Selectors, Slotted Content, Global Styles, and More

Learn how to effectively style your Vue components using scoped CSS features like deep selectors, slotted selectors, global styles, CSS modules, and dynamic v-bind() in both Vue 2 and Vue 3. 1. Deep Selectors Vue 2: Options API <template> <div class="parent"> <div class="child">Styled via Deep Selector</div> </div> </template> <style scoped> .parent { background-color: lightgrey; padding: 20px; } /* Deep selector for child elements */ >>> .child { color: blue; } </style> Enter fullscreen mode Exit fullscreen mode Vue 3: Composition API <template> <div class="parent"> <div class="child">Styled via Deep Selector</div> </div> </template> <style scoped> .parent { background-color: lightgrey; padding: 20px; }…
Read More
private vs #private

private vs #private

Preamble (aka you can skip this part)A few weeks ago I got distracted at work and accidentally wrote this blog as a src/readme.md. Now that I'm up to merging that branch in its time to remove that readme, but I like to think that more than just the 4 other people in my team might find this perspective interesting. So now I present it to you all as-is. Happy coding! Hello I decided to take note of a convention that I've been using in this project regarding TypeScript style private and ECMAScript style private. class Foo { private bar: string;…
Read More
How to Use Shadow DOM and Honeypots to Deter Crawlers

How to Use Shadow DOM and Honeypots to Deter Crawlers

This is a short introduction and demonstration on how we can increase security on forms, especially against crawling, it's noticeable that it's most likely overkill for most applications but very interesting for those who want to understand a bit more about such practices as and how it's possible to undermine them. Disclaimer: This post was inspired by Felippe Regazio, on a late-night coding stream, make sure to give him a follow. Huge thanks. Also, I'm not a senior dev, so please feel free to double-check any information you believe I could've misstated so that we can correct/improve it together. Next.js…
Read More
4 Best Rate Limiting Solutions for Next.js Apps (2024)

4 Best Rate Limiting Solutions for Next.js Apps (2024)

When implementing rate limiting in a Next.js application, there are several effective solutions available. Let's take a comprehensive overview of the best rate limiting options for Next.js: This middleware for Express applications is widely used for managing how many requests a client can make in a given time frame. Integration: You can use it in your Next.js API routes by importing the package and applying it as middleware. Example: import rateLimit from 'express-rate-limit'; const apiLimiter = rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100, // limit each IP to 100 requests per windowMs message: 'Too many…
Read More
“Learning React” Book Review

“Learning React” Book Review

"Learning React" by Alex Banks and Eve Porcello is a project-based guide that looks into the essential concepts of React, ensuring readers gain practical skills in using the framework effectively. From exploring the details of React Hooks to mastering advanced component patterns, this book equips you with the knowledge to build dynamic, efficient web applications. It also covers key libraries within the React ecosystem, providing a comprehensive foundation for developers at all levels.In this article, I will summarise the book and explain it might be a good read for anyone looking to learn the basics of React.The book starts by…
Read More
Writing Better React Code: A Guide to Clean, Efficient Practices

Writing Better React Code: A Guide to Clean, Efficient Practices

As React continues to evolve, it is essential for developers to stay updated with best practices that enhance code readability, maintainability, and performance. This guide outlines the key practices to follow in 2024 for writing cleaner and more efficient React applications, including the latest changes introduced in React 19. 1. Use Functional Components and Hooks Functional components with hooks are the standard for building React applications. They are simpler and promote better code organization. Example: import React, { useState } from 'react'; const Counter = () => { const [count, setCount] = useState(0); return ( <div> <p>Count: {count}</p> <button onClick={()…
Read More
Step-by-Step: Deploy Laravel App to Cloud (AWS, Google, Azure, DigitalOcean) with CI/CD Using GitHub Actions/GitLab CI

Step-by-Step: Deploy Laravel App to Cloud (AWS, Google, Azure, DigitalOcean) with CI/CD Using GitHub Actions/GitLab CI

Deploying a Laravel app to a cloud server with CI/CD using GitHub Actions or GitLab CI involves several steps. Below is a hands-on example and step-by-step guide for deploying a Laravel app to a cloud server like AWS, Google Cloud, Azure, or DigitalOcean using CI/CD pipelines. Prerequisites: A Laravel project hosted on GitHub or GitLab. A cloud server (AWS EC2, Google Cloud Compute Engine, Azure VM, or DigitalOcean Droplet). SSH access to your cloud server. Installed Docker on the cloud server (optional but recommended for consistency across environments). High-level steps: Set up the cloud server (AWS, Google Cloud, Azure, or…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.