Service | Handle |
---|---|
Bluesky | johncarney.dev |
Mastodon | johncarneyau |
johncarneyau | |
Hive | johncarney |
Post | johncarney |
Flickr | johncarney |
A random list of tracks that comes up in the algorithmic feeds I listen to that I particularly like.
Track | Artist | Country |
---|---|---|
[Gagarin] | [Public Service Broadcasting] | UK |
[As I Went Out One Morning][dps-01] | [Dirty Projectors] | US |
[Make The Road By Walking][msb-01] | [Menahan Street Band] | US |
[Home][vs-01] | [Villagers] | Ireland |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "active_support/all" | |
require "optparse" | |
module Options | |
extend ActiveSupport::Concern | |
included do | |
delegate :arguments, :options, to: :Options |
A module for implementing the Service Object pattern that allows for custom "verbs".
Including CallMe
in your class adds a call
class method that instantiates an
object of the class using the provided arguments and invokes its call
method.
For example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# If you don't already have a pre-push hook in your working copy, simply copy | |
# this into .git/hooks/pre-push in your working copy. If you already have a | |
# pre-push hook, you'll have to integrate it with your existing hook. | |
function current_branch { | |
git rev-parse --abbrev-ref HEAD | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ########################################################################### | |
# | |
# Probes all model associations looking for ones with a scope that call | |
# `with_deleted`. Lists all such associations, along with the location in | |
# source that `with_deleted` is called. | |
# | |
# Usage: | |
# | |
# $ rails runner script/associations-using-with-deleted.rb | |
# |
The arel_extensions
gem has a couple of bugs...
DateSub
doesn't work:
(table[:column] - 10.hours).to_sql
# => NoMethodError: undefined method `to_sql' for nil:NilClass
- For MySQL,
DateAdd
generates a double-minus when given a negative duration:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Custom Psych parser that captures line number information from a YAML file. | |
# | |
# For a project I'm working on I need to be able to determine which line(s) in a YAML | |
# file a particular value comes from. There are a few bits of advice on the internet | |
# about this, the best of them that I've found involves monkey-patching, which is a | |
# fairly low bar for "best" in my opinion. I found it on Stack Overflow: | |
# | |
# https://stackoverflow.com/questions/29462856/loading-yaml-with-line-number-for-each-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Examples | |
# | |
# MyModel.order(MyModel.arel_table[:name].asc.nulls_last) | |
# MyModel.order(MyModel.arel_table[:name].desc.nulls_first) | |
module Arel | |
module NullOrder | |
def nulls_last | |
Arel::Nodes::NullsLast.new self | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: ruby rails-locales-conflicts.rb [<rails root>] | |
require "pathname" | |
require "yaml" | |
class Translations | |
def initialize | |
@translations = Hash.new do |h, k| |
NewerOlder