RSSAmplifier

Blog

Keith Schacht's Weblog

keithschacht.comRSS feed ↗30 posts

Latest posts

with_options is some nice syntax sugar in Rails

with_options is some nice syntax sugar in Rails When a series of validations (in an ActiveRecord model) all share the same conditional or when a series of before_actions (in a controller) do, with_options is a nice grouping. Tags: Rails

Oat is a Minimal UI library

Oat is a Minimal UI library If I were to lean into a new UI library, this would likely be it. It’s the most minimal yet complete library that I’ve seen. It’s basically shadcn meets semantic HTML. Tags: UI

Remember Clippy: Screen-aware voice AI in the browser

A friend and I built a browser prototype that answers questions about whatever’s on your screen using getDisplayMedia, client-side wake-word detection, and server-side multimodal inference. Try it here: clippy.keithschacht.com Best in Chrome. Desktop only. No sign up. Hard parts: Getting the model to point to specific UI elements Keeping it coherent across multi-step workflows (“Help me create a…

Task Master: Voice-first todo list that updates live as you talk

I built a demo of a voice AI task manager. You speak naturally and it updates your visible task list in real time. Try it here: taskmaster.keithschacht.com Web-based. Desktop or mobile. No sign up. I find it helpful to talk aloud to figure out my priorities. I’ve wired up voice AI to many daily routines and this task manager is one of the most useful. In the morning, I sit down at my computer with…

Tests within a ruby's class

Tests within a ruby's class This is a clever trick for adding tests inside the same file that defines the methods.

Check for test coverage

Check for test coverage I should consider adding an automated test coverage checker to help with AI coding. I notice that AI agents are particularly bad at realizing that code is untested, it loves to mock things.

Modern CSS techniques

Modern CSS techniques Another great write-up about the 37signals Fizzy app, this one breaks down how to structure CSS for a complex project without using Tailwind.

Useful patterns in Fizzy

Useful patterns in Fizzy A great write-up of 10 new patterns in the 37signals Fizzy app which could be applied elsewhere.

Rails Notes

Rails Notes I forget about the rails notes command to pull out all the TODO's within a codebase. There's even more that can be done with this command

Methods on associations

Methods on associations I never knew you could include methods inside ActiveRecord associations: ``` class Book has_many :reviews do def featured = where(featured: true).first end end book.reviews.featured ```

SuperClaude [on Rails]

SuperClaude [on Rails] I've started to feel Claude Code is a bit superior to Cursor and find myself using it more. It's interesting to see multiple projects popping up that add a bit of scaffolding around the utility: The two notable ones I might try are SuperClaude and Claude on Rails .

Async meetings

Async meetings I've long heard about the Amazon approach to meetings and have been intrigued. But people who have actually done it report mixed feelings to me. And the process is quite prescriptive and feels a bit heavy so I've yet to try it. But this article did a really good job of articulating what I think might be the fundamental insight of Amazons meetings. And it proposes a variety of ways…

Setting up Android phone to work with Apple Watch and iMessage

Here are the key steps I went through to my Android phone to work with iMessage and with my Apple Watch. This was all done on AT&T. I suspect it's similar for all U.S. carriers but I haven't tried it on any others. I first got my Apple Watch working, which wasn't too bad, except I wanted full support for iMessages both on my watch and on my Android phone. That is the hard part, but the steps below…

Web Components Tutorial

Web Components Tutorial A great tutorial on using web components.

with_defaults is a better named alias

`with_defaults` is the same as `reverse_merge` in rails but much better named. Tags: Rails

Bundler can be configured to auto install

No more pulling down changes to a project and realizing I need to run `bundle install`. Run this command once on a dev machine and it'll auto install whenever new gems are needed: `bundle config --global auto_install true`. Tags: Ruby

React in Rails is gaining momentum with Inertia

I am seeing more activity around an elegant way to utilize React in Rails. I plan to try this out soon and these articles are a good starting point. There is even a shadcn starter project which is part of my motivation. Tags: Rails

Query optimization in rails

It's been awhile since I've gone deep on optimizing queries in rails. Over the years I've settled into two default approaches: (1) drop into raw SQL and write CTEs that help get a clean set of the final activerecord objects I'm looking for, or (2) add various cache columns to tables such as last_comment_id to greatly simplify the SQL. I came across this discussion online that did a great job of…

A clever CSS-only hack for blurry placeholder images

A clever CSS-only hack for blurry placeholder images This little bit of code, gives you a nice blurry placeholder with no JS required: <img src="…" style="--lqip:192900">

How to import any JS library without a build system

How to import any JS library without a build system I often come across an NPM module and want to import it into an app I’m building which does not make use of a javascript build. It’s quite tricky! This article breaks down the complete set of options for doing this. And when that fails we can bundle a single NPM module .

Updating a rails view component with hotwire

Updating a rails view component with hotwire This is a good pattern for wrapping a rails view partial with a light class to enable more easily updating them with Hotwire. Tags: Rails

Ruby's clamp method reduces conditionals

You can constrain a variable to be within a range using clamp: 5.clamp(1, 10) # => 5 -3.clamp(1, 10) # => 1 15.clamp(1, 10) # => 10 Tags: Ruby

Regex within string square brackets

I've always known that Ruby supports ranges within a string's square brackets. So in addition to the simple `name[4]` I can do `name[2..4]` and `name[2...]` and `name[-1]`. But I just learned you can put regex in the square brackets for more dynamic substring selectors: `"me+abc123@email.com"[/.+\+(.+)@(.+)/, 2]` will give you the subdomain of the email address. It even works with named capture…

Elegant solution to versioning an API

The couple times I've done API versioning it was with /v1/ or v1.domain.com. Both of these are the generally recommended pattern within rails. This article outlines a querystring based approach to API versioning and a much more flexible implementation strategy that avoids a lot of duplication and code maintenance. via Tags: Rails

A programmable wireless eink display

A programmable wireless eink display This is a clever little product: it’s an eink display that is fully programmable and you can wirelessly update. I’m sure I could use this for a future project. Tags: gadgets

Dynamic routing to a controller's action

Dynamic routing to a controller&#x27;s action If you have a rails form which has multiple submit buttons such as Publish and Unpublish , you can easily route those to corresponding actions within the controller with this clever hack. Tags: Rails

Quoting Dario’s interview with Lex Friedman

Dario from Anthropic is the most articulate and thoughtful person I’ve found on the subject of AI. In this interview he made a fantastic point I had not heard: Let’s say it was 1995 and Moore’s Law was making computers faster and everyone was saying, “some day we’ll have super computers and we’ll be able to sequence the genome and do all these great things.” But there is no discrete point where we…

Campsite Rails codebase

Campsite Rails codebase There are not a lot of great open source rails projects to learn from, but lately I’ve seen some notable discussion about this one. I’m bookmarking it so I remember to dig in at some point and see what I learn. Tags: Rails

Avo - Rails Admin

Avo - Rails Admin There are a few different gems for building Rails internal admin dashboards. Next time I build one I want to do a deep dive and see if I like any of them. This is a new one I came across that looks interesting. Tags: Rails

YouTube: Death Spiral of Army Ants

YouTube: Death Spiral of Army Ants A phenomenon where army ants follow each other in circles, sometimes until they die — and thus known as an “ant death spiral” — was captured on camera at a university in Venezuela. Biologist Javier David Uzcategui Gonzalez filmed the footage at Simon Bolivar University in Miranda, describing the occurrence as “very rare”. In an August 2020 tweet, Gonzales…