Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
@searls
searls / react-was-a-mistake.md
Last active October 15, 2025 23:32
I asked Bing Chat, "Write a blog post in the style of Justin Searls about why React was a mistake."

React was a mistake

I know what you’re thinking: “Not another React rant!” But hear me out. I’m not here to bash React for its performance, its ecosystem, or its popularity. I’m here to argue that React was a mistake because it fundamentally changed the way we think about web development, and not for the better.

React introduced a new paradigm for building web applications: components. Components are reusable pieces of UI that can have their own state, logic, and rendering. Components can be composed together to form complex interfaces, and React takes care of updating the DOM when the component state changes.

Sounds great, right? Well, not so fast. There are some serious drawbacks to this approach that are often overlooked or ignored by React enthusiasts.

First of all, components are not a natural fit for the web. The web is based on documents, not applications. Documents are structured by HTML elements, styled by CSS rules, and enhanced by JavaScript behaviors. HTML, CSS, and JavaScript are designed t

@searls
searls / keybindings.json
Last active April 28, 2023 16:47
VS Code 1.77 added the `runCommands` command, which is basically a macro that you can define right in your keybindings file by chaining multiple commands together. In this case I bound individual test runs, file-scoped tests, and full Rake tasks to command-R + modifiers. (The `m` CLI is the m gem, which allows running minitests by file and line)…
[
{
"command": "runCommands",
"key": "cmd-r",
"args": {
"commands": [
"workbench.action.files.save",
"workbench.action.terminal.focus",
{
"command": "workbench.action.terminal.sendSequence",
@searls
searls / cops_to_csv.rb
Created March 28, 2023 14:34
Ruby file to convert a Rubocop YAML file (rubocop-rails in this case) to a CSV for the purpose of evaluating the rules
# Purpose: Generate a CSV file from the rubocop-rails config file
#
# Usage: ruby driver.rb [csv_file_name] # defaults to rubocop-rails.csv
require "yaml"
require "csv"
def doc_url(cop_name)
squished = cop_name.downcase.delete("/")
"https://docs.rubocop.org/rubocop-rails/cops_rails.html##{squished}"
@searls
searls / tailwind.config.js
Created March 21, 2023 23:40
A sample Tailwind configuration file, heavily inspired by @PixelJanitor
function spacing () {
const scale = Array(201)
.fill(null)
.map((_, i) => [i * 0.5, `${i * 0.5 * 8}px`])
const values = Object.fromEntries(scale)
values.px = '1px'
values.xs = '2px'
values.sm = '4px'
return values
}
@searls
searls / standard_on_rails.diff
Created February 19, 2023 19:30
This is the only diff remaining when I ran a brand new rails app through `standardrb --fix` for the first time.
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 87ec21e..9f34f1b 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -53,7 +53,6 @@ Rails.application.configure do
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
-
# Raises error for missing translations.
@searls
searls / rails_bisect_step
Created February 1, 2023 20:34
Used in conjunction with [this script](https://gist.github.com/searls/5c6b77213dbc7202ca39f4e70d975eee) to make it easier to git bisect rails apps whose database changes during the affected sha range
#!/usr/bin/env bash
# Usage:
#
# First, be sure you're running `git bisect start --no-checkout`, so you can
# checkout the bisect head yourself and do some pre-flight stuff like rewind
# migrations
#
# $ git bisect good
# Bisecting: 22 revisions left to test after this (roughly 5 steps)
#!/usr/bin/env bash
# Useful when you want to git bisect in a rails app and know
# you need to `bin/rake db:migrate VERSION="SOMETHING"` before
# you check out the next commit so the database is in the right
# state, but you don't know what SOMETHING is.
# Usage:
#
# $ migration_version_at_ref <REF>
@searls
searls / 1_painful.rb
Last active January 18, 2023 17:43
Here's an example of a refactor I did while test-driving a class using Ruby and Mocktail
# The core problem here is mixing levels of abstraction
# This unit has two jobs. It delegates one and retains (most of) the
# other. That means it's doomed to be partially hands-off
# (simply trusting whatever result ProposesAgent sends back)
# and otherwise hopelessly in the weeds (requiring
# a test to care not only whether the save was valid but how/why)
module Proposals
class ProposesAgent
Result = Struct.new(:success?, :proposal, :error_messages, keyword_init: true)
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use Puma as the app server
gem 'puma'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
@searls
searls / index.html
Last active November 11, 2025 22:57
Mobile styling overrides for NetlifyCMS to make it more responsive-ish.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
</head>
<body>