Find an explanation, explore a subject.

Search across Loksewa resources and Tech Insights.
Press Esc to close Search PSC Computer
REFERENCE & LEARNING

Technical cheat sheets

Search Git, Docker, Next.js 16, and PyTorch commands. Copy a command to adapt it to your project.

38 commands

Git · Repository status
git status --short

Show staged, changed, and untracked files.

Git · Create branch
git switch -c feature/my-change

Create and switch to a branch.

Git · Stage selected file
git add path/to/file

Stage a file for the next commit.

Git · Commit
git commit -m "feat: add feature"

Commit the staged changes.

Git · Unstaged diff
git diff

Inspect changes outside the staging area.

Git · Staged diff
git diff --cached

Inspect changes queued for commit.

Git · Recent history
git log --oneline --graph -15

Show recent commits and branches.

Git · Update remote references
git fetch --prune

Refresh references and remove deleted remote branches.

Git · Save unfinished work
git stash push -u -m "work in progress"

Stash changes, including untracked files.

Git · Undo a published commit
git revert <commit>

Create a new commit reversing a previous change.

Docker · Build image
docker build -t my-app:latest .

Build from the current Dockerfile.

Docker · Run container
docker run --rm -p 3000:3000 my-app:latest

Run an image and expose its port.

Docker · List running containers
docker ps

Show running containers.

Docker · Container logs
docker logs -f <container>

Follow standard output and error.

Docker · Open shell
docker exec -it <container> sh

Open a shell in a running container.

Docker · Start Compose stack
docker compose up -d

Start services in the background.

Docker · Stop Compose stack
docker compose down

Stop and remove the stack containers.

Docker · List volumes
docker volume ls

Show persistent volumes.

Docker · Inspect image
docker image inspect my-app:latest

Inspect image metadata.

Next.js · Development server
npm run dev

Start the project development script.

Next.js · Production build
npm run build

Build and prerender eligible pages.

Next.js · Production server
npm run start

Serve the previously built app.

Next.js · Client component
'use client';

Place at the top of interactive browser components.

Next.js · Async route parameters
const { slug } = await params;

Read App Router dynamic parameters in Next.js 16.

Next.js · Static routes
export function generateStaticParams() { return [{ slug: "intro" }]; }

Enumerate dynamic pages for build-time generation.

Next.js · JSON response
return Response.json({ ok: true });

Return JSON from an App Router route handler.

Next.js · Proxy protection
export function proxy(request) { /* authorize or rewrite */ }

Next.js 16 uses proxy.ts in place of middleware.ts.

Next.js · Metadata
export const metadata = { title: "My page" };

Define metadata in a server page or layout.

PyTorch · Create tensor
x = torch.tensor([1.0, 2.0, 3.0])

Create a float tensor.

PyTorch · Tensor shape
x.shape

Inspect dimensions.

PyTorch · Select device
device = "cuda" if torch.cuda.is_available() else "cpu"

Use an available GPU, otherwise CPU.

PyTorch · Move model
model = model.to(device)

Place model parameters on the selected device.

PyTorch · Track gradients
x = torch.tensor([1.0], requires_grad=True)

Enable automatic differentiation.

PyTorch · Backpropagation
loss.backward()

Calculate gradients from a scalar loss.

PyTorch · Optimization step
optimizer.zero_grad()
loss.backward()
optimizer.step()

Clear gradients, backpropagate, and update parameters.

PyTorch · Inference
model.eval()
with torch.inference_mode():
    output = model(x)

Evaluate without gradient tracking.

PyTorch · Save weights
torch.save(model.state_dict(), "weights.pt")

Persist model parameter tensors.

PyTorch · Load weights
model.load_state_dict(torch.load("weights.pt", weights_only=True))

Load trusted weights into the matching model.