How to remove a committed file from Git history forever git

How to remove a committed file from Git history forever

Committed an .env file with secrets to Git? Three steps remove it from history forever: add it to .gitignore, rewrite every commit with git filter-branch, then git push --force the cleaned history. Exact commands included, plus what the rewrite does to your repository.

Jan 8, 2024

Add commit message validator using Ruby and Lefthook ruby

Add commit message validator using Ruby and Lefthook

Enforce consistent commit messages with a small Ruby script and Lefthook: a commit-msg hook that reads .git/COMMIT_EDITMSG, validates prefixes like feat, fix, or docs against a regex, and rejects bad messages before they land. Full script and Lefthook config included.

Jan 1, 2024

How to work with JSONB column in pure Ruby on Rails

How to work with JSONB column in pure Ruby on Rails

JSONB columns in Ruby on Rails without extra gems: use store_accessor to read and write keys like normal attributes, set sensible defaults, and validate required keys with a small module. Practical code you can drop into a PostgreSQL-backed Rails app.

Understanding Record type in Typescript

Understanding Record type in Typescript

The Record utility type in TypeScript builds object types with fixed keys and value types. A worked example shows Record<Keys, Type> with union keys: restricting IDs to chosen literals and mixing User and AdminUser values, so the compiler flags missing or extra entries.

What is ETag and how to use it in Rails for caching?

What is ETag and how to use it in Rails for caching?

ETags let browsers skip downloading content that has not changed. What entity tags are in HTTP, then the Rails caching toolkit: stale?, fresh_when, expires_in, expires_now, public requests, and http_cache_forever, each shown with a concrete controller example.

Adjusting padding bottom for navigation in iOS and Android

Adjusting padding bottom for navigation in iOS and Android

Bottom navigation sitting too close to the screen edge on iPhone X and newer? The fix for iOS and Android PWAs is the safe area: use CSS env(safe-area-inset-bottom) to adjust the bottom padding so the bar clears rounded corners and the home indicator.

Understanding the Singleton Pattern in Javascript

Understanding the Singleton Pattern in Javascript

The Singleton pattern in JavaScript ensures one shared instance with a global access point. A practical implementation using an object literal and Object.freeze, a shared bucket example, and where a singleton fits: configuration, logging, or a central data store.

What is instance and class variable in Ruby?

What is instance and class variable in Ruby?

Instance variables versus class variables in Ruby: what @ and @@ actually mean, why an @ variable set at the class level stays empty when read from an instance, and how @@ values are shared by every instance. Short code samples make each behavior easy to verify.

Extend, prepend and include in Ruby

Extend, prepend and include in Ruby

Extend, prepend, and include in Ruby each add module code to a class differently: prepend puts the module before the class so its methods win, extend adds class methods, include adds instance methods. Short runnable examples show how each changes the method lookup chain.

Understanding TypeScript Function Generators

Understanding TypeScript Function Generators

TypeScript function generators can pause and resume execution, returning values one at a time instead of all at once. What generators are, how yield works in a simple example, and a practical number sum generator that shows where they beat regular functions.

Powerful switch statement with pattern matching in Ruby

Powerful switch statement with pattern matching in Ruby

Pattern matching in Ruby turns case statements into a precise switch over data shapes: match and destructure hashes from an API response, combine several patterns in one branch, capture values across patterns, and validate configuration. Ruby 2.7+ syntax examples.

How to set up XML in Grape API

How to set up XML in Grape API

XML support in Grape API takes two steps: register the additional content_type so endpoints accept and return application/xml, then change the root element name of the XML output. Complete Ruby examples built around a products endpoint you can adapt to your API.

Multiple ways to execute a shell command via Ruby

Multiple ways to execute a shell command via Ruby

Running shell commands from Ruby: system, backticks, exec, the IO class, spawn, and Open3.popen3 compared with pros and cons, from quick one-liners to capturing stdout, stderr, and exit status, so you can pick the right method for scripts and production code.

Database shrading and database partitioning in Rails

Database shrading and database partitioning in Rails

Database sharding in Rails step by step: create a separate database per shard, wire them up in database.yml, and query across them. Plus how sharding differs from partitioning, with a native PostgreSQL partitioning example done through Rails migrations.

Sidekiq basic_fetch and super_fetch differences

Sidekiq basic_fetch and super_fetch differences

Sidekiq basic_fetch vs super_fetch: open source Sidekiq fetches jobs with BRPOP and loses them when a process crashes, while Sidekiq Pro's super_fetch uses RPOPLPUSH with private per-process queues to recover orphaned jobs. What that means for queue reliability.