Skip to content

Instantly share code, notes, and snippets.

@omernaci
omernaci / docker-general-commands.csv
Last active September 29, 2024 10:30
Docker General Commands
Command Description
docker version Displays Docker version information.
docker info Shows detailed information about the Docker installation and system.
docker login Logs into a Docker registry.
docker logout Logs out from a Docker registry.
docker search <image-name> Searches for Docker images in a registry.
docker stats Shows real-time resource usage statistics of running containers.
docker events Streams real-time events from the Docker server.
docker kill <container-id> Forcibly stops a running container.
docker network ls Lists all Docker networks.
@omernaci
omernaci / docker-containers-commands.csv
Created September 29, 2024 10:26
Docker Containers Commands
Command Description
docker ps Lists all running containers.
docker ps -a Lists all containers (including stopped ones).
docker run <image-name> Creates and starts a new container from the specified image.
docker run -d <image-name> Runs a container in detached mode (in the background).
docker run -it <image-name> Runs a container interactively (for terminal access).
docker stop <container-id> Stops a running container.
docker start <container-id> Starts a stopped container.
docker restart <container-id> Restarts a container.
docker rm <container-id> Removes a stopped container.
@omernaci
omernaci / docker-images-commands.csv
Created September 29, 2024 10:24
Docker Images Commands
Command Description
docker images Lists all images stored locally.
docker pull <image-name> Downloads the specified image from a registry.
docker build -t <image-name> . Builds a Docker image from the Dockerfile in the current directory and tags it.
docker tag <image-id> <new-name> Assigns a new tag to an existing Docker image.
docker rmi <image-id> Removes the specified image from your local system.
docker history <image-name> Displays the layers and history of a Docker image.
docker inspect <image-name> Shows detailed information about the specified Docker image.
docker save -o <file-name>.tar <image-name> Saves a Docker image to a .tar archive.
docker load -i <file-name>.tar Loads a Docker image from a .tar archive.
@omernaci
omernaci / docker-compose.yml
Created January 28, 2024 13:26
Zookeeper, Kafka, Schema Registry, Kafka UI
version: '3'
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.2.0
environment:
ZOOKEEPER_CLIENT_PORT: 2181
volumes:
- zookeeper_data:/var/lib/zookeeper/data
- zookeeper_logs:/var/lib/zookeeper/log
@omernaci
omernaci / OrderValidation.java
Created January 17, 2024 10:54
Cyclomatic Complexity
// Reduce complexity of the code
public boolean isOrderValid(Order order) {
if (order != null) {
if (order.getItems() != null && !order.getItems().isEmpty()) {
for (OrderItem item : order.getItems()) {
if (item.getQuantity() > 0) {
// Validate item
} else {
return false;
}
@omernaci
omernaci / AccountOpenedEventHandler.java
Created December 13, 2023 10:22
Event Driven Architecture - Event Versioning
public class AccountOpenedEvent {
private String accountId;
private String customerDetails;
private String accountOpeningDetails;
private int version; // Add a version field
}
@Component
public class AccountOpenedEventHandler {
private List<AccountOpenedEventProcessor> processors;
@omernaci
omernaci / kubernetes-commands.csv
Created June 30, 2023 10:37
Kubernetes Basic Command List
Description Command
Create a pod kubectl create pod <pod-name> --image=<image-name>
Get pods kubectl get pods
Describe a pod kubectl describe pod <pod-name>
Delete a pod kubectl delete pod <pod-name>
Create a deployment kubectl create deployment <deployment-name> --image=<image-name>
Get deployments kubectl get deployments
Scale a deployment kubectl scale deployment <deployment-name> --replicas=<replica-count>
@omernaci
omernaci / BigDecimalExample.java
Created April 13, 2023 17:36
Java BigDecimal Best Practice
import java.math.BigDecimal;
import java.math.RoundingMode;
public class BigDecimalExample {
public static void main(String[] args) {
// Creating BigDecimal objects using the String constructor
BigDecimal value1 = new BigDecimal("123.456");
BigDecimal value2 = new BigDecimal("123.4560");
// Performing arithmetic operations with the HALF_UP rounding mode
@omernaci
omernaci / terminal-operations.csv
Created April 9, 2023 21:24
Java Stream Terminal Operations
Operation Type Description
forEach Terminal Performs an action for each element of this stream.
count Terminal Returns the count of elements in this stream.
reduce Terminal Performs a reduction on the elements of this stream using the provided identity value and accumulation function.
collect Terminal Performs a mutable reduction operation on the elements of this stream using a Collector.
anyMatch Terminal Returns whether any elements of this stream match the provided predicate.
allMatch Terminal Returns whether all elements of this stream match the provided predicate.
noneMatch Terminal Returns whether no elements of this stream match the provided predicate.
findFirst Terminal Returns an Optional describing the first element of this stream or an empty Optional if the stream is empty.
findAny Terminal Returns an Optional describing some element of the stream or an empty Optional if the stream is empty.
@omernaci
omernaci / intermediate-operations.csv
Last active April 9, 2023 21:27
Java Stream Intermediate Operations
Operation Type Description
filter Stateless Returns a new stream consisting of elements that match the given predicate.
map Stateless Returns a new stream consisting of the results of applying the given function to the elements of this stream.
flatMap Stateless Returns a new stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
sorted Stateful Returns a stream consisting of the elements of this stream sorted according to the provided Comparator.
peek Stateless Returns a stream consisting of the elements of this stream additionally performing the provided action on each element as elements are consumed from the resulting stream.
limit Stateless Returns a stream consisting of the elements of this stream truncated to be no longer than the specified maximum size.
skip Stateless Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the