Skip to content

Instantly share code, notes, and snippets.

View matt17r's full-sized avatar

Matthew Lindfield Seager matt17r

View GitHub Profile
@matt17r
matt17r / model.rb
Created September 5, 2025 00:23
Time comparison... greater than == more recent than 🤦‍♂️
# I found this confusing to read... Active ones are ones that were read less than seven days ago so why is this a greater than symbol?
scope :active, -> { where("read_at IS NULL OR read_at > ?", 7.days.ago) }
# Of course! A date that is greater than another date is more recent than the other date 🤦‍♂️
scope :active, -> { where("read_at IS NULL OR read_at > ?", 7.days.ago) } # '>' == 'more recent than'
# But I think we can do better than [just] a comment (plus I already had an unread scope, why aren't I using it here???)
scope :unread, -> { where(read_at: nil) }
scope :read_within_past, ->(period) { where("read_at > ?", period.ago) } # '>' == 'more recent than'
scope :active, -> { unread.or(read_within_past(7.days)) }
@matt17r
matt17r / config.rb
Created November 2, 2023 02:56
Options to prevent overly long socket length https://github.com/ruby/debug/issues/982
# shorten user to max 20 characters
def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
user = ENV['USER'] || 'UnknownUser'
user.slice![0-19]
File.join(base_dir, "ruby-debug-#{user}")
end
@matt17r
matt17r / bump.sh
Created November 18, 2021 18:00
Helper script for [Bumpr](getbumpr.com) to send emails via Gmail
#!/bin/sh
# URL encode mailto link using Perl
url="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$2")"
# Then send email via one of the following Gmail accounts
# 1) Default (first logged in) Gmail/Workspace account
open -u "https://mail.google.com/mail/?extsrc=mailto&url=${url}"
@matt17r
matt17r / (Sample) Map of Shared Drive.md
Last active December 5, 2024 15:57
Generate a tree view of Google Shared Drives in Markdown format