Running with patch
$ QUEUE_ADAPTER=async ./fix-preview-image-race-condition.rb
Yields
Creating a post and uploading a video
#!/usr/bin/env ruby | |
begin | |
repo = `git remote -v`.split("\n").find { |line| | |
line.include?("github.com") | |
}.split("\t")[1].match(/git@github.com:(.*).git/)[1] | |
system "open https://github.com/#{repo}" | |
rescue | |
warn "No github remote found" |
class ValidatesDeeply | |
Failure = Struct.new(:model, :message) | |
Result = Struct.new(:valid?, :failures) | |
def validate(model, visited = Set.new) | |
return Result.new(true) if visited.include?(model) | |
visited.add(model) | |
combine_results(Result.new(model.valid?, extract_failures(model)), *validate_associations(model, visited)) | |
end |
:root, | |
.light { | |
--accent: 183 64 233; | |
--accent-bright: 183 64 233; | |
--accent-light: 217 155 244; | |
--bg-primary: 249 249 249; | |
--bg-secondary: 230 230 230; | |
--border-primary: 17 24 39; |
const css4ColorsToLegacyRgbaPlugin = { | |
postcssPlugin: 'these-colors-dont-run', | |
Once (root) { | |
root.walkDecls((decl) => { | |
const rgbRegex = /rgb\((\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s*(?:\/\s*(\d+\.?\d*))?\)/g | |
decl.value = decl.value.replace(rgbRegex, (match, r, g, b, a) => { | |
if (!a || a === '1' || a === '1.0') { | |
return `rgb(${r}, ${g}, ${b})` | |
} else { | |
return `rgba(${r}, ${g}, ${b}, ${a})` |
# Leverages the BroadcastLogger introduced in Rails 7.1 to wrap the current | |
# logger in a new logger that broadcasts to both the current logger and $stdout | |
# | |
# (Announcement: https://rubyonrails.org/2023/9/29/this-week-in-rails) | |
# | |
# If the current logger already broadcasts to $stdout, it will not be wrapped, | |
# making it safe to call this method multiple times without knowing the current | |
# logging "sitch". | |
# | |
# Usage probably looks something like this: |
/* preventScrollWhenSoftKeyboardAppearsIfThereIsPlentyOfRoom(event) | |
* | |
* Attach this handler to `touchstart` on any UI control that brings up the keyboard when you don't want iOS | |
* MobileSafari to scroll when a user taps it. Assumes that the input is near the top of the page and the user has | |
* not scrolled down (specific to my case, sorry!) | |
* | |
* requires top-level CSS directives so we can add it to the body: | |
* ``` | |
* .prevent-ios-focus-scrolling { | |
* position: fixed; |
Running with patch
$ QUEUE_ADAPTER=async ./fix-preview-image-race-condition.rb
Yields
Creating a post and uploading a video
TIL this script helped me figure out that
Not awesome things that happen in this case:
class FeedsController < ApplicationController | |
def index | |
@posts = Post.with_visuals.order(published_at: :desc) | |
end | |
end |
You grok SOLID. You practice TDD. You've read Sandi's book…twice. You rewatch Destroy All Software monthly. You can pronounce GOOS. You know your stuff!
But some of your coworkers say your code is too complex or confusing for them. You might rush to conclude that must be a them problem.
But doubt lingers: what if they're right?