Recent
Nov. 26, 2024
💡 TIL: pick is the single-value version of pluck in Rails #
Instead of doing
Messages.pluck(:user_id).firstyou can do
Messages.pick(:user_id)
💡 TIL: Rails ActiveRecord has a .sole method #
I just learned about `sole` and `find_sole_by`. They ensure that only a single record is returned and will raise if there is something other than one. It’s the equivalent of:
api_keys = user.api_keys.where(key: key) if api_keys.length == 1 api_key = api_keys.first elsif api_keys.length == 0 raise "No records found!" else raise "More than one matching record found!" end
🔗 Rails web-based database admin (#). A rails gem that gives you a web-based interface to your database.
🔗 Vampire game based around AI voice: SUCK UP! (#) This is one of the best examples I’ve seen of games creatively incorporating LLMs. You are a vampire character, you walk up to houses in a neighborhood and as the player you actually talk aloud to your computer and the NPCs talk back. You have to convince these NPCs to let you into their house.
💡 TIL: NASA’s Dragonfly probe to Saturn’s Titan in 2028 #
In 2028 NASA is launching a spacecraft to Saturn’s moon Titan to study its habitability in a mission named Dragonfly. It will land in 2034. They’re sending a drone powered by a radioisotope thermoelectric generator so they can visit a variety of sites. Titan is notable because it’s believed to have a similar chemistry to ancient earth. Past probes have measured the contents of the atmosphere and confirmed it contains a mix of hydrocarbons. The surface contains a lot of water ice and scientists believe there is a water ocean in the interior of the moon.
Nov. 13, 2024
🔗 The first state-of-the-art coding LLM that runs locally (#). This Qwen2.5-Coder-32B should run locally in about 20-30 gb of ram and assessments show it to be better than 4o at coding but not quite as good as Claude 3.5.
Nov. 3, 2024
🔗 Jina AI tool for simplifying webpages (#). This is a really handy tool for simplify a webpage before passing it into an LLM. It turns HTML into semi-structured markdown.
🔗 Using LLM to process video (#). I have done a lot of experimenting with passing screenshots into an LLM to give it additional context, but I really want to try passing video directly into the LLM. I believe Gemini is the only one that supports it. This is a summary of Simon Willison’s recent experiment with Gemini for video.
🔗 Automating app development with LLM (#). I keep automating more of my day-to-day programming using various tools, and this guy did a clever wrap around LLM. He writes a unit test in python, passes it to LLM, and it writes the code necessary to get the test to pass. This technique could prove useful for what I want to do with rails development.
🔗 SQLite now runs on Cloudflare edge (#). There is so much innovation happening with SQLite these days and now it appears that Cloudflare lets you run it at edge nodes. I don’t quite understand the significance of this, but now I don’t have to think of Cloudflare as a way to help handle large spikes in traffic to static pages. Simon Willison elaborates on this development.
🔗 Fair Source (#). I’ve been keeping an eye on this initiative started by Sentry. One of the most common ways I see product companies utilizing open source is to release their software via open source and then make money by running a paid version of the service for people who don’t want to self-host.
With this approach, it can undermine your business strategy if someone else decides to run a competing version of your hosted service using your open source software. I believe this was Sentry’s primary motivation. I’ve also seen talk of Business Source License (BSL) but am unsure of the difference between this and Fair Source. Some day I may dig into this.
🔗 Emoji Favicon (#). When building a new site, populating the favicon is more annoying than it should be. It’s something I often put off. But this site will serve you any emoji as a favicon.
🔗 Andressen and Horowitz on AI Robots (#). In this discussion between Andreessen and Horowitz, they pointed out that we are on the verge of embodied AI being a generally useful too. My key takeaway was this:
General purpose robots could do everything from be assistants in your home, build houses, fight wars, etc. This is being made possible by all the software advances in AI in addition to the hardware advances in actuators, batteries, and vision systems.
The U.S. currently leads on the software side of AI, but China has a significant lead on the hardware side. The U.S. has basically made manufacturing illegal in the U.S. through environmental regulation, minimum wage requirements, and unions so U.S. companies have outsourced more advanced hardware to China. Now more than ever, with our strained relationship with China, we need to build these capabilities in the U.S. and at the same time U.S. regulators have their eyes on regulating the software AI capabilities.
Oct. 29, 2024
📝 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
💡 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 endfrom RubyCademy
💡 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) } => totalfrom davetron
Oct. 25, 2024
💬 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.
Oct. 18, 2024
🔗 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.
🔗 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.
🔗 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.
🔗 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.
🔗 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.
Oct. 16, 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!
May 17, 2024
📝 Using Hotwire it was simple to build inline title editing #
After generating the Rails scaffolding for my “Conversation” model, it was just a few steps to do inline editing:
- Modify conversations/_conversation.html.erb to wrap it in a turbo-frame
- Modify conversations/_form.html.erb partial to wrap it in the same turbo-frame so that the form will replace the displayed title
- Add a tiny bit of stimulus to enable submit on enter/blur and to enable discard with Escape