programming

Linux: top memory and CPU consuming processes (ps, sar, scripts, metrics file)

Find top CPU and memory consuming processes on Linux with ps, top, sar, and pidstat; sample output after controlled stress; Bash scripts that append metrics to a file and ideas for email alerts.

Deepak Prasad6 min read
programming

Bash: check if a string contains text, digits, or a prefix ([[ ]], globs, regex)

Bash patterns to see if a string contains a substring or character, if it is only digits, if it starts with a prefix, and how [[ =~ ]] and globs differ— with quoting, empty-string gotchas, and a short locale note.

Deepak Prasad4 min read
programming

Bash trap Ctrl+C (SIGINT): catch, ignore and cleanup with trap

Bash trap Ctrl+C (SIGINT): linux ctrl c signal basics, trap INT and trap ctrl-c patterns, ignore with trap empty string, EXIT cleanup, quoting pitfalls, and subshell vs child-process behavior.

Omer Cakmak4 min read
programming

Bash until vs while loop: exit codes, same counter and when to pick each

Bash until vs while using exit status: bash until loop runs while a command fails, while loop bash runs while it succeeds. Examples for counters, wait until ready, and while read line-by-line.

Deepak Prasad4 min read
programming

Bash script multiple arguments: all args, functions, another script and typeset -f over SSH

Bash multiple arguments with positional parameters, bash pass all arguments via "$@", bash pass multiple arguments to a function, forwarding to another script, and bash pass function over SSH with typeset -f or declare …

Deepak Prasad4 min read
programming

Bash increment variable: add 1, counters, loops and (( )) vs $(( ))

Bash increment variable and bash add 1 to variable with $(( )), ((++)), bash increment variable in loop (for/while), bash increment counter patterns, let, and post vs pre-increment pitfalls.

Deepak Prasad4 min read
programming

Bash format number with commas on Linux: printf, numfmt and script examples

Bash format number with commas using printf thousands grouping, LC_NUMERIC and GNU numfmt, plus a pure Bash comma formatter for integers and decimals. Covers locale (en_US vs en_IN), C/POSIX limits, and readable output …

Deepak Prasad5 min read
programming

JavaScript await: async functions, try/catch, Promise.all, top-level await

How await works in JavaScript: javascript await, js await, async await javascript, await promise inside async functions, sequential vs Promise.all concurrency, try/catch on rejections, await on non-promises, top level …

Olorunfemi Akinlua5 min read
programming

JavaScript factory pattern (functions, classes, and async factories)

JavaScript factory pattern and factory functions: return plain objects, pick implementations by input, constructor-based factories, ES6 class factories, closure privacy, and async factories—with Node-tested output.

Olorunfemi Akinlua5 min read
programming

Nested loops in Java (for, while, do-while, and examples)

Nested loops in Java: nested for, while, and do-while (including mixed loops), Scanner menu example, labeled break, and complexity. Runnable examples with OpenJDK 17-tested output.

Deepak Prasad8 min read
programming

Golang Write to File, Append & Create File (os.WriteFile, OpenFile Examples)

Learn how to write, append, and create files in Golang using os.WriteFile and os.OpenFile. This practical guide covers file writing, appending data, creating files if not exists, flags explanation, real-world examples, …

Antony Shikubu8 min read
programming

Golang Generics Explained (Functions, Structs, JSON & Real Examples)

Learn Golang generics with practical examples including generic functions, structs, interfaces, and JSON parsing. This guide explains type parameters, constraints, real-world use cases, and common errors to help you …

Antony Shikubu7 min read
programming

Golang Optional Parameters (No Default Values? Best Workarounds Explained)

Learn how to implement optional parameters in Golang using variadic functions, struct-based patterns, and pointer parameters. This guide explains why Go does not support default values and shows practical workarounds …

Antony Shikubu7 min read
programming

Golang If Else (Syntax, Multiple Conditions, One-Line & Best Practices)

Learn how to use if, else if, and else statements in Golang with practical examples. This guide covers multiple conditions, logical operators (AND, OR, NOT), one-line if statements, real-world use cases, and best …

Antony Shikubu7 min read
programming

Golang Read File (Line by Line, Entire File, Large Files Explained)

Learn how to read files in Golang using os.ReadFile, bufio.Scanner, and bufio.Reader. This guide covers reading entire files, line-by-line processing, handling large files efficiently, and common errors with practical …

Deepak Prasad7 min read
programming

Read File in Golang with Timeout (Handle Large Files, Scanner Errors & Real Examples)

Learn how to read files in Golang with timeout handling using select, time.After, and context.WithTimeout. This guide covers reading files line by line, in chunks, handling large files, fixing bufio.Scanner errors, and …

Deepak Prasad9 min read
programming

Golang JWT Authentication (Gin + REST API + Middleware Examples)

Learn how to implement JWT authentication in Golang using Gin and PostgreSQL. This step-by-step guide covers user signup, login, JWT token generation, middleware validation, REST API usage, and common errors for building …

Antony Shikubu14 min read
programming

Pytest Logging Explained (Set Log Level, Show Logs, caplog, Fix Issues)

Learn how to configure and use pytest logging effectively. This guide covers setting log levels, enabling live logs, using log_cli and caplog, fixing logs not showing, logging to file, and advanced configurations. …

Deepak Prasad5 min read
programming

Python Set add() Explained (Add Elements, Multiple Items, Common Mistakes)

Learn how to add elements to a set in Python using add() and update() methods. This guide covers adding single and multiple elements, handling duplicates, common mistakes like append() and insert(), and real-world use …

Deepak Prasad7 min read
programming

Python Compare Strings (==, Ignore Case, Substring, Examples)

Learn how to compare strings in Python with practical examples. This guide covers string equality, case-insensitive comparison, substring matching, lexicographic comparison, character-by-character comparison, and …

Deepak Prasad8 min read
programming

Python floor() Function Explained (math.floor, Examples, vs int & round)

Learn how to use floor() in Python with practical examples. Understand math.floor(), differences between floor vs int vs round, handling negative numbers, Pandas and NumPy usage, and common errors. Includes syntax, …

Bashir Alam6 min read
programming

Fix "Setting an Array Element with a Sequence" in Python (NumPy ValueError Explained + Examples)

Learn how to fix the "ValueError: setting an array element with a sequence" in Python and NumPy. Understand inhomogeneous shape errors, causes, real examples, and step-by-step solutions to resolve array shape mismatch …

Azka Iftikhar5 min read
programming

npm run pass arguments (with & without --) – Complete Guide + Examples

Learn how to pass arguments to npm scripts using double dash (--) and without it. Includes real examples, npm_config usage, environment variables, and best practices for Node.js scripts.

Steve Alila4 min read
programming

Python Regex Tutorial with Examples (re Module Cheat Sheet & Use Cases)

Learn Python regex (regular expressions) with practical examples, cheat sheet, and real-world use cases. Understand re module functions like search, match, findall, sub, and split with beginner-friendly explanations and …

Deepak Prasad8 min read
programming

How to Uninstall Golang (Go Compiler) on Linux, macOS, and Windows

Learn how to uninstall Golang (Go compiler) on Linux, macOS, and Windows. This guide explains how to remove Go installed using tarball archives, package managers, Homebrew, or installers, including cleaning environment …

Tuan Nguyen11 min read
programming

Java Arrays vs Collections Explained with Practical Examples

Learn the differences between arrays and collections in Java with practical examples. This guide explains how to create arrays, initialize lists, print arrays, determine collection size, and work with common Java …

Bashir Alam12 min read
programming

Python os.path.join() Explained: Syntax, Examples and Path Handling Guide

Learn how to use Python os.path.join() to safely combine file and directory paths across operating systems. This tutorial explains syntax, examples, multiple arguments, return values, and common use cases such as joining …

Bashir Alam7 min read
programming

Generate UUID in Node.js (NodeJS UUID Generator Guide)

Learn how to generate UUID in Node.js using the uuid package, crypto module, nanoid, and other methods. This guide explains UUID versions, NodeJS UUID generation examples, and best practices for creating unique IDs in …

Steve Alila12 min read
programming

Enhanced For Loop in Java (For-Each Loop Explained with Examples)

Learn how to use the enhanced for loop in Java (also known as the for-each loop) to iterate over arrays, lists, sets, and map entries. This guide explains syntax, practical examples, limitations, comparisons with …

Bashir Alam6 min read
programming

Best IDE for Golang: VS Code, GoLand, Neovim, Zed, and More

Compare the best IDEs and editors for Go development: VS Code, GoLand, Neovim, Zed, LiteIDE, Sublime Text, and Emacs—use cases, trade-offs, setup checklist, and legacy tools to avoid.

Tuan Nguyen13 min read