Understanding generic types in Typescript typescript

Understanding generic types in Typescript

Generic types in TypeScript let one function, class, or interface work safely with many data types. What generics are, how a type parameter beats hardcoding a concrete entity type in a validation helper, and honest pros and cons before you use them everywhere.

May 2, 2023

Ruby in browser via WebAssembly

Ruby in browser via WebAssembly

Ruby 3.2 runs in the browser through WebAssembly: embed Ruby in a script tag with ruby-wasm-wasi or drive the Ruby VM from JavaScript and mix it with HTML. Working examples plus honest limits: no threading or networking, and no extra gems without a custom wasm image.

Map vs WeakMap in practice

Map vs WeakMap in practice

Map vs WeakMap in JavaScript comes down to keys and memory: WeakMap only accepts object keys and lets garbage collection reclaim unused entries, while Map holds onto everything. Differences, similarities, and practical guidance on when each one is the right choice.

Anonymous Arguments Passing Improvements in Ruby 3.2

Anonymous Arguments Passing Improvements in Ruby 3.2

Ruby 3.2 adds new syntax for anonymous arguments: forward positional and keyword arguments with bare * and ** and unpack them inside the method, no more digging through kwargs hashes. A before-and-after example shows how much cleaner argument passing gets.

How to write Naive Bayes classification algorithm in Ruby

How to write Naive Bayes classification algorithm in Ruby

Naive Bayes classification in plain Ruby: how prior and posterior probabilities decide the winning class, then a working spam filter that classifies email titles. Also where the algorithm shines: sentiment analysis, recommendations, and fraud detection.

How to auto-remove files from trash in Google Drive

How to auto-remove files from trash in Google Drive

Google Drive trash can quietly eat the space you free up when rotating files like CCTV recordings. A short Google Apps Script fixes it: an emptyTrash function, the Drive API service, and a time-based trigger that wipes the trash every hour, fully automatic and free.