Keith Schacht’s Weblog

Subscribe

October 2024

📝 I’m loving Rails Stimulus; check out this example. #

I’m working on a site that has a left column for navigation. Standard stuff. But I wanted a simple control that lets you hide and show the left column.

When I first started using Stimulus, I would create a left_column_controller.js. Within it, in the connect() and disconnect() methods I would add and remove listeners. It worked, but it was verbose and I wasn’t enjoying Stimulus. Later, I refactored all my stimulus controllers to extract common interactions. Now I finally “get” Stimulus and I’m loving it!

Read more ▾

🔗 The FTC is finally making it easier to cancel (#).

The US Federal Trade Commission is taking action against subscriptions that are difficult to get rid of. On Wednesday, it adopted a final “click-to-cancel” rule requiring businesses to make canceling a subscription as easy as signing up.

This is bad. It’s another small crack in the glory days of web and mobile startups. I’ve had my share of frustrating subscriptions that are hard to cancel, so I’m sympathetic to this. But anyone who has tried to start a retail business is aware of just how difficult it is to navigate a web of regulations to get your store open. Those regulations don’t come all at once, they’re added one “reasonable” regulation at a time, slowly strangling the startup ecosystem.

#permalink 10/18/24, 6:41 pm / regulation, startups

🔗 Kindle Scribe Review (#). I occasionally think about buying a Remarkable writing tablet. I tried it in the store and was pretty impressed. But I really like the idea of a single device that is both a Kindle reading device along with a digital notebook. I use my iPad almost daily for writing notes, reading books, and the other iPad stuff (email web). It works well enough for reading & writing, but I’d love to try this Kindle Scribe to see how much better it is at those two. Note to self: find a friend who has one.

#permalink 10/18/24, 6:55 pm / gadgets

🔗 Tips for terminal colors (via HN) # I increasingly prefer text user interfaces over graphical interfaces. As one example, I switched from the github GUI to lazygit TUI a couple years ago and love the speed and keyboard shortcuts. I think about converting a couple of my utilities to solid TUI so this may be helpful when figuring out colors.

#permalink 10/18/24, 7:13 pm / tui

🔗 A complete map of all neurons and the connections in a fruit fly (via HN) #

The brain contains 10^5 neurons and 10^8 synapses that enable a fly to see, smell, hear, walk and fly. Flies engage in dynamic social interactions18, navigate over distances19 and form long-term memories20. Portions of fly brains have been reconstructed from electron microscopy images, which have sufficient resolution to reveal the fine branches of neurons and the synapses that connect them. The resulting wiring diagrams of neural circuits have provided crucial insights into how the brain generates social21,22, memory-related23 or navigation24 behaviours.

I wonder how long it will be before we can run a complete simulation of this brain on silicon? Maybe there is missing information still such as the weight between neural connections.

#permalink 10/18/24, 7:18 pm / bci

🔗 John Carmack on Functional Programming (via HN) #

A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. In a multithreaded environment, the lack of understanding and the resulting problems are greatly amplified, almost to the point of panic if you are paying attention. Programming in a functional style makes the state presented to your code explicit, which makes it much easier to reason about, and, in a completely pure system, makes thread race conditions impossible.

A significant part of John Carmack’s intelligence is his ability to recognize the importance of having principles while not shunning pragmatic tradeoffs.

#permalink 10/18/24, 8:03 pm / language-design, Carmack

💬 from Daniel Miessler (via) #

Fill in this sentence.

"I believe one of the biggest problems in the world is _ _ _ _ , which is why I'm _ _ _ _ ."

Are you happy with your answer? ... Once you've found your sentence, you’ve then found a molten core for a thriving career. And not just your career, but maybe your life as well.

Everything builds off of how you are useful to the world.

This is a really great essentialization. I think his sentences has an incorrect bias against the arts so I'd reword the sentence to, "I believe one of the most important things in the world is _ _ _ _ , why is why I'm _ _ _ _ ."

Notably, I'm deep in the process of revisiting my own answer to this question.

#permalink 10/25/24, 5:23 pm / life-design

💡 TIL: Ruby can chain methods and right-assign #

I just learned that ruby supports re-writing this:

total = plus_shipping(with_taxes(subtotal(items)))

As:

subtotal(items).then { |subtotal| with_taxes(subtotal) }.then { |total| plus_shipping(total) } => total
from davetron

💡 TIL: Rails migrations can include an up_only part #

When writing a migration in Rails and you need to do one thing which can’t be automatically reversed, I always convert a def change to up and down. It turns out you can slip in an up_only block:

class AddFieldsToUsers < ActiveRecord::Migration[7.1]
  def change
    add_column :users, :first_name, :string
    add_column :users, :last_name, :string

    up_only do
      User.delete_all
    end
  end
end
from RubyCademy

📝 Ruby Sorbet is too verbose, can the syntax be improved? #

Awhile back when I was ramping up on Typescript, I was leaning into the benefits of types. In the Ruby world, Sorbet is the most common way to add types so I gave that a shot. In the end, I ripped it out. I spent more time wrangling type checking then the time it spent catching bugs, and one of the issues was the verbose syntax. But recently I came up with a novel solution to this problem. First, here is the verbose syntax — you end up declaring all your arguments twice:

sig { params(name: T.untyped, nickname: String).returns(Integer) }
def greet(name, nickname)
  puts "Hello, #{name}! Your nickname: #{nickname}"
  name.length
end

Read more ▾

2024 » October

MTWTFSS
 123456
78910111213
14151617181920
21222324252627
28293031