Kotlin Tutorial #15: Delegation — by lazy, Delegates, and Custom Delegation

In the previous tutorial, you learned about error handling. Now let’s learn about delegation. Delegation is a design pattern where an object hands off work to another object. Kotlin has built-in support for delegation using the by keyword. In this tutorial, you will learn: by lazy — lazy initialization Delegates.observable — react to changes Delegates.vetoable — reject invalid changes Map delegation — properties from a map Custom delegates — build your own Class delegation — delegate interface implementation by lazy by lazy creates a property that is computed only once, the first time you access it. After that, the cached value is returned. This is useful for expensive initialization. ...

March 22, 2026 · 8 min

Kotlin Tutorial #14: Error Handling — try/catch, Result, and Patterns

In the previous tutorial, you learned about interfaces and generics. Now let’s learn about error handling. Every program needs to handle errors. Kotlin gives you several tools for this, from traditional try/catch to the modern Result type. In this tutorial, you will learn: try/catch/finally try as an expression Custom exceptions The Result type (runCatching, getOrElse, map, fold) Sealed classes for errors Error handling patterns and best practices try/catch/finally The try/catch block catches exceptions. finally always runs, even after an exception. ...

March 22, 2026 · 8 min

Kotlin Tutorial #13: Interfaces, Generics, and Type Constraints

In the previous tutorial, you learned about sealed classes, enum classes, and value classes. Now let’s learn about interfaces, generics, and type constraints. These features let you write flexible, reusable code while keeping type safety. In this tutorial, you will learn: Interfaces and multiple inheritance Generics with <T> Type constraints with where Variance — in and out Star projection * Reified type parameters Interfaces An interface defines a contract. Classes that implement the interface must provide the required functions and properties. ...

March 22, 2026 · 8 min

Kotlin Tutorial #12: Sealed Classes, Enum Classes, and Value Classes

In the previous tutorial, you learned about scope functions. Now let’s learn about three important types in Kotlin: enum classes, sealed classes, and value classes. Each one solves a different problem, and knowing when to use which will make your code better. In this tutorial, you will learn: Enum classes — fixed set of constants Sealed classes — restricted hierarchies with different data Sealed interfaces — multiple inheritance with sealed types Value classes — type safety without runtime overhead When to use which Enum Classes An enum class defines a fixed set of constants. Every value is known at compile time. ...

March 22, 2026 · 9 min

Kotlin Tutorial #10: Extension Functions and Properties

In the previous tutorial, you learned about lambdas and higher-order functions. Now let’s learn about extension functions and properties. Extensions let you add new functions and properties to existing classes without modifying them. This is one of Kotlin’s best features. You can add a toSlug() function to String or a secondOrNull() function to List — without changing the original class. In this tutorial, you will learn: Extension functions Practical extensions like String.toSlug() and List.secondOrNull() Extension properties Extensions on nullable types Companion object extensions Generic extensions Extension Functions An extension function adds a new function to an existing class. The class you extend is called the “receiver.” ...

March 22, 2026 · 8 min

Kotlin Tutorial #9: Lambdas and Higher-Order Functions

In the previous tutorial, you learned about collections. Now let’s learn about lambdas and higher-order functions. These are some of the most powerful features in Kotlin. A lambda is a function without a name. You already used lambdas with filter, map, and other collection functions. In this tutorial, you will learn how they work in depth. In this tutorial, you will learn: Lambda syntax and the it keyword Trailing lambdas Function types like (Int) -> String Higher-order functions (functions that take or return functions) Function references Closures Inline functions Lambda Syntax A lambda is written between curly braces { }. The arrow -> separates the parameters from the body. ...

March 22, 2026 · 9 min

Kotlin Tutorial #8: Collections — List, Set, Map, and Operations

In the previous tutorial, you learned about classes. Now let’s learn about collections — one of the most important topics in Kotlin. You will use collections in almost every program you write. Kotlin’s collections are powerful and expressive. You can filter, transform, group, and combine data with just a few lines of code. In this tutorial, you will learn: List, MutableList, Set, and Map filter, map, flatMap groupBy, sortedBy reduce and fold zip and associate Chaining operations together List A List is an ordered collection. listOf creates a read-only list. mutableListOf creates a list you can change. ...

March 22, 2026 · 8 min

SQL Cheat Sheet 2026 — Queries, JOINs, and Performance

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers SQL from basic queries to window functions and performance. Try examples at db-fiddle.com. Last updated: March 2026 SELECT Basics SELECT * FROM users; -- all columns SELECT name, email FROM users; -- specific columns SELECT DISTINCT city FROM users; -- unique values SELECT name AS full_name FROM users; -- column alias SELECT * FROM users LIMIT 10; -- first 10 rows SELECT * FROM users LIMIT 10 OFFSET 20; -- rows 21-30 (pagination) WHERE — Filtering Rows SELECT * FROM users WHERE age > 18; SELECT * FROM users WHERE city = 'Berlin'; SELECT * FROM users WHERE age BETWEEN 18 AND 30; SELECT * FROM users WHERE city IN ('Berlin', 'Munich', 'Hamburg'); SELECT * FROM users WHERE name LIKE 'A%'; -- starts with A SELECT * FROM users WHERE name LIKE '%son'; -- ends with son SELECT * FROM users WHERE name LIKE '%alex%'; -- contains alex SELECT * FROM users WHERE email IS NULL; -- null check SELECT * FROM users WHERE email IS NOT NULL; SELECT * FROM users WHERE age > 18 AND city = 'Berlin'; SELECT * FROM users WHERE age > 65 OR age < 18; SELECT * FROM users WHERE NOT city = 'Berlin'; ORDER BY and LIMIT SELECT * FROM users ORDER BY name; -- ascending (default) SELECT * FROM users ORDER BY age DESC; -- descending SELECT * FROM users ORDER BY city, name; -- multiple columns SELECT * FROM users ORDER BY age DESC LIMIT 5; -- top 5 oldest INSERT, UPDATE, DELETE -- Insert one row INSERT INTO users (name, email, age) VALUES ('Alex', 'alex@example.com', 25); -- Insert multiple rows INSERT INTO users (name, email, age) VALUES ('Sam', 'sam@example.com', 30), ('Jordan', 'jordan@example.com', 22); -- Update UPDATE users SET age = 26 WHERE name = 'Alex'; -- Update multiple columns UPDATE users SET city = 'Munich', age = 27 WHERE id = 1; -- Delete DELETE FROM users WHERE id = 5; -- Delete all rows (use with caution!) DELETE FROM users; -- Faster delete all (resets table) TRUNCATE TABLE users; -- UPSERT — insert or update if exists (PostgreSQL) INSERT INTO users (email, name) VALUES ('alex@example.com', 'Alex') ON CONFLICT (email) DO UPDATE SET name = EXCLUDED.name; -- MySQL equivalent INSERT INTO users (email, name) VALUES ('alex@example.com', 'Alex') ON DUPLICATE KEY UPDATE name = VALUES(name); Warning: Always use WHERE with UPDATE and DELETE. Without it, every row is affected. ...

March 21, 2026 · 8 min

Jetpack Compose Tutorial #8: Navigation — Moving Between Screens

Welcome to Part 2 of the series. You can now build beautiful single-screen apps. But real apps have many screens — a home screen, a detail screen, a settings screen, a profile screen. Navigation is how you move between them. In this tutorial, you will learn everything about Compose navigation: Setting up navigation Creating screens and routes Type-safe navigation with Kotlin Serialization Passing data between screens Bottom navigation bar Nested navigation graphs Back stack management Best practices This is a long tutorial. Take your time. ...

March 20, 2026 · 11 min

Docker Cheat Sheet 2026 — Commands, Dockerfile, and Compose

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers Docker CLI commands, Dockerfile instructions, Docker Compose, volumes, networking, and production tips. Last updated: March 2026 How Docker Works ┌──────────────┐ docker build ┌──────────┐ docker run ┌────────────┐ │ Dockerfile │ ───────────────► │ Image │ ─────────────► │ Container │ │ (recipe) │ │ (template)│ │ (running) │ └──────────────┘ └──────────┘ └────────────┘ │ docker push │ ┌────▼───────┐ │ Registry │ │ (Docker Hub)│ └────────────┘ Container Commands Command Description docker run <image> Create and start a container docker run -d <image> Run in background (detached) docker run -it <image> bash Run interactively with shell (sh for Alpine) docker run -p 8080:80 <image> Map host port 8080 to container port 80 docker run --name myapp <image> Run with a custom name docker run --rm <image> Automatically remove container when it stops docker run -e KEY=value <image> Set environment variable docker run -v /host:/container <image> Mount a volume docker ps List running containers docker ps -a List all containers (including stopped) docker stop <container> Stop a running container docker start <container> Start a stopped container docker restart <container> Restart a container docker rm <container> Remove a stopped container docker rm -f <container> Force remove (even if running) docker exec -it <container> bash Open a shell inside a running container docker logs <container> View container logs docker logs -f <container> Follow logs in real-time docker inspect <container> Show detailed container info (JSON) docker stats Live resource usage for all containers docker cp <container>:/path ./local Copy file from container to host docker cp ./local <container>:/path Copy file from host to container docker container prune Remove all stopped containers docker kill <container> Force stop a container (SIGKILL) Image Commands Command Description docker images List all local images docker pull <image> Download an image from registry docker push <image> Upload an image to registry docker build -t myapp . Build image from Dockerfile in current dir docker build -t myapp:v1 . Build with a tag/version docker tag <image> <new-tag> Add a tag to an image docker rmi <image> Remove an image docker image prune Remove unused (dangling) images docker system prune -a Remove all unused images, containers, networks (not volumes) docker system prune -a --volumes Remove everything including volumes docker history <image> Show image layers and sizes docker login Log in to Docker Hub (required before push) docker logout Log out from registry docker save -o image.tar <image> Export image to tar file docker load -i image.tar Import image from tar file Dockerfile Reference # Base image FROM node:20-alpine # Set working directory WORKDIR /app # Copy dependency files first (for caching) COPY package.json package-lock.json ./ # Install dependencies RUN npm ci --production # Copy application code COPY . . # Expose a port (documentation only) EXPOSE 3000 # Default command when container starts CMD ["node", "server.js"] Dockerfile Instructions Instruction Description FROM <image> Base image (required, must be first) WORKDIR /app Set working directory for subsequent commands COPY <src> <dest> Copy files from host to image ADD <src> <dest> Like COPY but can extract tar and fetch URLs RUN <command> Execute command during build (creates a layer) ENV KEY=value Set environment variable ARG KEY=value Build-time variable (not available at runtime) EXPOSE <port> Document which port the app listens on CMD ["executable", "arg"] Default command (can be overridden) ENTRYPOINT ["executable"] Fixed command (CMD becomes arguments) VOLUME /data Create a mount point for persistent data USER <username> Switch to non-root user `HEALTHCHECK CMD curl -f http://localhost/ CMD vs ENTRYPOINT # CMD — default command, can be overridden CMD ["python", "app.py"] # docker run myapp → runs python app.py # docker run myapp bash → runs bash (overrides CMD) # ENTRYPOINT — fixed command, CMD becomes arguments ENTRYPOINT ["python"] CMD ["app.py"] # docker run myapp → runs python app.py # docker run myapp test.py → runs python test.py Multi-Stage Build # Stage 1: Build FROM node:20-alpine AS builder WORKDIR /app COPY package.json ./ RUN npm ci COPY . . RUN npm run build # Stage 2: Production (smaller image) FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] Multi-stage builds produce smaller images — the final image only contains the production output, not the build tools. ...

March 19, 2026 · 6 min