programming

FAISS Python API Tutorial: IndexFlatL2, IndexIVFFlat, add, search, and remove_ids

Practical FAISS Python API guide: install faiss-cpu, NumPy float32 shapes, IndexFlatL2 and IndexFlatIP, add and search, IndexIVFFlat training and nprobe, IndexIDMap and remove_ids, save/load indexes, common dtype and …

Deepak Prasad8 min read
programming

Python Measure Execution Time: time, perf_counter, and timeit

Learn how to measure execution time in Python using time.perf_counter(), timeit, process_time(), and decorators, with examples in seconds, milliseconds, and nanoseconds.

Azka Iftikhar6 min read
programming

Golang Struct Embedding: Composition, Promoted Fields, and Methods

Golang struct embedding and go struct embedding: anonymous embedded fields, promoted fields and methods per the Go spec, composition vs inheritance, pointer embedding, name conflicts, interface embedding, satisfying …

Tuan Nguyen9 min read
programming

Python Marshmallow Tutorial: Schema, Fields, dump(), and load()

Learn Python Marshmallow with examples for creating schemas, using fields, serializing data with dump(), deserializing and validating data with load(), nested schemas, many=True, DateTime formatting, and common errors.

Bashir Alam9 min read
programming

Golang Pointers Tutorial: Address, Dereference, nil, and Pointer Receivers

Learn pointers in Go: pointer types *T, address operator &, dereferencing, nil pointers, passing pointers to functions, pointer receivers, structs, slices and maps, and when not to use pointers.

Antony Shikubu10 min read
programming

Implement a Binary Search Tree in Python: insert, search, delete, traverse

Build a BST in Python with a Node class, iterative insert and search, inorder preorder postorder traversals, delete for leaf one-child and two-child nodes, duplicate policy, complexity, and common pitfalls.

Deepak Prasad12 min read
programming

Nested Dictionary in Python: Create, Access, Update, and Loop

Learn nested dictionaries in Python with examples to create, access, update, add, delete, loop through, flatten, and merge dictionary inside dictionary data.

Bashir Alam8 min read
programming

Python Lambda & Anonymous Functions: Syntax, Examples, map(), filter(), sorted()

Learn Python lambda functions (anonymous functions): syntax, examples with multiple arguments, map(), filter(), sorted(), conditional expressions, limits, common mistakes, and when to use def instead.

Bashir Alam7 min read
programming

Combine Two Arrays as Columns in NumPy: column_stack, hstack, and concatenate

Combine two lists or 1-D NumPy arrays into a two-column 2-D array using numpy.column_stack, with numpy.stack axis=1, numpy.hstack for column-shaped inputs, numpy.concatenate axis=1, row vs column stacking, shape rules …

Deepak Prasad6 min read
programming

Create Simple & Complex Python Package with Examples

This guide will lead you on how to create a Python package which includes setup, configuration, building and publishing. You will learn how to include more files, test locally and version control for successful …

Deepak Prasad18 min read
programming

Python any() and all() Functions: Check If Any or All Items Are True

Learn how Python any() and all() work with lists, strings, dictionaries, truthy and falsy values, generator expressions, short-circuiting, and common mistakes.

Bashir Alam7 min read
programming

Golang Interface Tutorial: Examples, Implementation, and Type Assertion

Learn interfaces in Go with simple examples, including method sets, implicit implementation, interface parameters, empty interface, any, type assertion, printing interface values, composition, pointer receivers, and …

Antony Shikubu13 min read
programming

pip requirements.txt File: Create, Install, and Use with pip

Learn how to use a pip requirements.txt file to install Python dependencies with pip install -r, create the file manually or with pip freeze, add version constraints, and fix common errors.

Omer Cakmak9 min read
programming

Python Add to Dictionary: Add Key-Value Pairs, Update, and Append

Learn how to add to a dictionary in Python using key assignment, update(), setdefault(), |=, and dictionary unpacking, with examples for single keys, multiple keys, lists, nested dictionaries, and existing keys.

Deepak Prasad6 min read
programming

Merge Dictionaries in Python: |, update(), **, and More

Learn how to merge dictionaries in Python using the | operator, update(), ** unpacking, copy(), ChainMap, and more, with duplicate key behavior and Python version differences.

Deepak Prasad8 min read
programming

FileNotFoundError in Python: Causes, Fixes, and Path Examples

Learn what FileNotFoundError (No such file or directory, errno 2) means in Python, why it happens even when the file seems to exist, and how to fix it with correct paths, working directory, pathlib, symlinks, and …

Deepak Prasad11 min read
programming

How to Concatenate Tensors in PyTorch: torch.cat, stack, and shapes

Learn how to concatenate tensors in PyTorch with torch.cat along dim 0 or 1, torch.concat and torch.concatenate aliases, shape rules, stack vs cat, device errors, and a quick reference table.

Bashir Alam8 min read
programming

strconv in Go: parse, format, quote, and common errors

strconv in Go: parse and format integers, floats, and bools, Quote and Unquote, bases with FormatUint and ParseInt, NumError with errors.Is, and when to prefer strconv over fmt.Sscanf.

Deepak Prasad8 min read
programming

Golang SHA-512: Sum512, hex, files, streams, salt verify, and SHA-256 comparison

Golang SHA-512 with crypto/sha512: Sum512 and hex, sha512.New streaming io.Copy, file checksum verify, streams vs one-shot, salt-and-hash demo with verification caveats, SHA-512 vs SHA-256, HMAC, use cases, passwords …

Tuan Nguyen9 min read
programming

Golang Compare Strings: Equality, Ordering, and Case-Insensitive Match

Compare strings in Go with == and !=, lexicographic order with < and >, strings.EqualFold for case-insensitive match, strings.Compare for three-way results, and trimming input before comparing.

Tuan Nguyen5 min read
programming

Golang Command Line Arguments: os.Args, Flags, and Examples

Read command-line arguments in Go with os.Args, use the flag package for named options, validate positional args, parse numbers safely, and understand go run vs a compiled binary.

Tuan Nguyen7 min read
programming

What Is Ampersand in Golang? & and * Pointer Operators Explained

Learn what ampersand means in Go, how & gets a variable address, how * works with pointers, and how & and * are used together in simple examples.

Tuan Nguyen5 min read
programming

Golang Variable Scope: Local, Package-Level, Global, and Block Scope

Learn variable scope in Go, including local variables, package-level variables, global-style variables, block scope, short declarations, shadowing, and best practices.

Deepak Prasad8 min read
programming

Go Import Underscore Explained: Blank Imports and Side Effects

Learn why Go uses underscore before an import path, how blank imports work, when packages are imported for side effects, and how this relates to unused import errors.

Tuan Nguyen9 min read
programming

Golang Web Server Tutorial: Build and Configure an HTTP Server in Go

Learn how to build a Go web server using net/http, configure routes, handlers, ports, timeouts, static files, JSON responses, and graceful shutdown.

Deepak Prasad14 min read
programming

Golang Closure Function: Closures, Captured Variables, and Performance

Learn closures in Go: function values that capture outer variables, how they differ from anonymous functions, returned functions and state, goroutine loop pitfalls, and golang closure performance and escape analysis.

Deepak Prasad7 min read
programming

Golang WaitGroup: sync.WaitGroup Example, Add, Done, and Wait

Learn how to use sync.WaitGroup in Go to wait for goroutines, with Add, Done, Wait, WaitGroup.Go, common mistakes, and practical examples.

Antony Shikubu8 min read
programming

Golang Buffered Channel: Capacity, Blocking, and Buffered vs Unbuffered

Learn buffered channels in Go: make(chan T,n) capacity, len and cap, when send and receive block, buffered vs unbuffered channels, backpressure, deadlocks, choosing buffer size, and practical patterns.

Deepak Prasad6 min read
programming

Import Local Package in Go Without GOPATH: Step-by-Step Go Modules Example

Learn how to import a local Go package without GOPATH using go.mod, module paths, subfolders, exported names, replace directives, and go.work.

Tuan Nguyen8 min read
programming

Golang Channel with Multiple Receivers: Workers, Fan-Out, and Safe Closing

Learn how multiple goroutines read from the same Go channel: each value is received once, fan-out worker pools, closing rules, result channels, buffered vs unbuffered, and why this is not broadcast.

Antony Shikubu9 min read