Skip to main content

3 posts tagged with "cheatsheat"

View All Tags

· 2 min read

Images

docker images                   # List all images
docker pull <image_name> # Pull an image from Docker Hub
docker build -t <image_name> . # Build an image from the current directory
docker rmi <image_id> # Remove an image

Containers

docker ps                       # List running containers
docker ps -a # List all containers
docker run <image_name> # Create and start a container
docker exec -it <container_id> bash # Access a running container's shell
docker stop <container_id> # Stop a running container
docker rm <container_id> # Remove a container

Volumes

docker volume ls                # List all volumes
docker volume create <volume_name> # Create a volume
docker run -v <volume_name>:/path/in/container <image_name> # Mount a volume to a container

Networks

docker network ls               # List all networks
docker network create <network_name> # Create a network
docker run --network=<network_name> <image_name> # Connect a container to a network

Compose

docker-compose up               # Start services defined in a docker-compose.yml
docker-compose down # Stop and remove services defined in a docker-compose.yml

Registry

docker login                    # Log in to a Docker registry
docker push <image_name> # Push an image to a registry
docker pull <registry>/<image_name> # Pull an image from a registry

System

docker info                     # Display system-wide information
docker version # Show the Docker version
docker system prune # Remove all stopped containers, unused networks, and dangling images

Dockerize Applications

docker build -t <image_name> .         # Build a Docker image
docker run -p <host_port>:<container_port> <image_name> # Run a Docker container

· 2 min read

Git Basics

git init
git clone <repository_url>
git status

Staging and Commits

git add <file(s)>
git commit -m "Commit message"
git reset --soft HEAD^ // Undo Last Commit (Keep Changes)
git reset --hard HEAD^ // Undo Last Commit (Discard Changes)

Branching

git branch <branch_name>
git checkout <branch_name>
git checkout -b <branch_name>
git merge <branch_name>
git branch -d <branch_name>

Remote Repositories

git remote add <remote_name> <repository_url>
git push <remote_name> <branch_name>
git pull <remote_name> <branch_name>

Logging and History

git log
git show <commit_hash>
git diff

Miscellaneous

touch .gitignore  // Ignore Files (Create .gitignore)
git checkout -- <file(s)> // Undo Changes in Working Directory
git reset HEAD <file(s)> // Undo Staged Changes

Cherry-pick

git cherry-pick <commit_hash>

Rebase

git rebase <base_branch>
git rebase -i <base_branch> // Interactive rebase

Squash Commits during Rebase

// Change "pick" to "squash" for the commits you want to squash
// Follow on-screen instructions to edit the commit messages
git rebase -i <base_branch>

Amend the Last Commit

git commit --amend

Stash Changes

git stash
git stash save "Stash message"

Apply Stashed Changes

git stash apply
git stash pop // Apply and remove from stash

View Stash List

git stash list

Show Differences with Stash

git stash show -p <stash_id>

Discard Stashed Changes

git stash drop <stash_id>
git stash clear // Remove all stashes

Tagging

git tag <tag_name>  // Create lightweight tag
git tag -a <tag_name> -m "Tag message" // Create annotated tag
git push origin <tag_name> // Push tag to remote

Submodules

git submodule add <repository_url> <path>  // Add submodule
git submodule update --init --recursive // Initialize submodules
git submodule foreach git pull origin master // Update submodules

Git Configurations

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Show Configurations

git config --list

· 2 min read
  1. c# basic(datatype, exception, ...) -> important
  2. Algorithm (bubble sort, selected sort, ...) -> quick view
  3. OOP (4 ) -> important
  4. SOLID (5) -> quick view
  5. C# advance (delegate, generic, async ) -> optional
  6. SQL(join(8), understand func vs store procedure) -> important
  7. Linq -> quick view
  8. ef core -> quick view
  9. webapi -> optional

Create and Build Projects

dotnet new console -n MyConsoleApp    // Create a new console application
dotnet new webapi -n MyWebApi // Create a new Web API project
dotnet build // Build the project

Run Applications

dotnet run                            // Run the application
dotnet run --project <project_path> // Run a specific project
dotnet watch run // Run with file watching

Add Dependencies

dotnet add package <package_name>     // Add a NuGet package
dotnet restore // Restore dependencies

Generate Code

dotnet new classlib -n MyLibrary      // Create a class library
dotnet add reference <project_path> // Add a project reference
dotnet publish -c Release // Publish the application

Unit Testing

dotnet new xunit -n MyTests           // Create xUnit test project
dotnet test // Run tests

Entity Framework Core

dotnet ef migrations add <migration_name>    // Add a migration
dotnet ef database update // Apply migrations

Publish and Deploy

dotnet publish -c Release --self-contained // Publish a self-contained application

Package Management

dotnet nuget push -k <api_key> -s <source> <package.nupkg>    // Publish a NuGet package

ASP.NET Core Identity

dotnet new identity -n MyIdentityApp   // Create an ASP.NET Core Identity project

Azure Functions

dotnet new func -n MyFunction          // Create an Azure Functions project

Clean Up

dotnet clean                          // Clean the build output