Skip to content

Instantly share code, notes, and snippets.

@danlo
danlo / gist:137212aaa8e4eb9ec411e77cbcb76aa3
Created December 29, 2025 19:09
Documentation about moving from Ruby 3 and less to Ruby 4 and removing CGI from our site.
# Warning: LLM created
Before:
CGI.escape
After:
URI.encode_www_form_component (most often this one)
URI.encode_www_form
# Ruby 3.2+ and Ruby 4: Use URI::DEFAULT_PARSER.escape for custom escaping, but prefer encode_www_form_component for URLs
Before:
EXCLUDE="--exclude-dir=docs --exclude-dir=test --exclude-dir=spec"
for CONST in `grep --include=*.rb $EXCLUDE --no-filename --only-matching --perl --recursive '[A-Z][A-Za-z0-9]+(::[A-Z][A-Za-z0-9]+)+' . | grep -v 'Controller$' | grep -v '^AASM\|AbstractController\|Action\|Active\|Algolia\|Aws\|BigDecimal\|ConnectionPool\|CoreExt\|Devise\|Digest\|Dir\|Dry\|Faker\|Hashie\|OpenSSL\|Postmark\|Rails\|Rake\|Resque\|Rollbar\|Sinatra\|Slim\|URI\|Unicorn\|Zlib\|GraphQL' | sort -u`
do
COUNT=`grep --include=*.rb $EXCLUDE --no-filename --recursive $CONST . | grep -v '^ *#' | wc -l`
if [[ $COUNT -eq 1 ]]
then
echo "########### $CONST ($COUNT)"
echo "grep --include=*.rb -r $CONST . "
grep --include=*.rb $EXCLUDE --recursive --color $CONST .
echo
@danlo
danlo / derpy.rb
Created August 6, 2018 17:31
brain twister
class BaseDoc
include Mongoid::Document
has_one :child, class_name: 'ChildDoc', inverse_of: :parent
field :data, type: String
end
class ChildDoc
include Mongoid::Document

Keybase proof

I hereby claim:

  • I am danlo on github.
  • I am daniello (https://keybase.io/daniello) on keybase.
  • I have a public key ASBX7WAZGbG1o-ibCuM8VXCmS5AXF-5ny7ndnMhoXjn4aAo

To claim this, I am signing this object: