Skip to content

Instantly share code, notes, and snippets.

View drwl's full-sized avatar

Andrew W. Lee drwl

View GitHub Profile
@drwl
drwl / bundler_script.rb
Last active June 19, 2019 02:39
Get all explicitly defined gems and those gem's depencies
require 'bundler'
GEMFILE_LOCK_PATH = 'Gemfile.lock'.freeze
lockfile_text = File.read(GEMFILE_LOCK_PATH)
lockfile = Bundler::LockfileParser.new(lockfile_text)
explicit_gems = lockfile.dependencies.values
implicit_gems = lockfile.specs.reduce([]) { |gems, spec| gems += spec.dependencies }.uniq(&:name)
all_gems = (explicit_gems + implicit_gems).uniq(&:name).sort_by(&:name)
  • /app/lib/decorates/%MODEL_NAME%/*.rb
  • /app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb
# Using these pry gems
# gem "pry"
# gem "pry-rails"
# gem "pry-byebug"
# gem "pry-stack_explorer"
# gem "pry-doc"
# gem "pry-state"
# gem "pry-toys"
# gem "pry-rescue"
@drwl
drwl / some_files.rb
Created November 19, 2020 06:50
example of autoload not playing well
# ~/workspace/autoload-example ls -l
# total 24
# -rw-r--r-- 1 andrew.lee 588821037 86 Nov 18 22:42 mod.rb
# -rw-r--r-- 1 andrew.lee 588821037 94 Nov 18 22:47 not-working.rb
# -rw-r--r-- 1 andrew.lee 588821037 76 Nov 18 22:45 works.rb
# mod.rb
module Mod
class Foo
def self.call
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/leea/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@drwl
drwl / foo.rb
Created June 12, 2023 19:55
prettifying defaults
# The column object we get from AR has a default value that's String
# [4] pry(#<AnnotateRb::ModelAnnotator::ColumnAnnotation::AttributesBuilder>)> rcol = @column.instance_variable_get("@column")
# => #<ActiveRecord::ConnectionAdapters::PostgreSQL::Column:0x000000010e19ea60
# @collation=nil,
# @comment=nil,
# @default="0",
# @default_function=nil,
# @generated="",
# @name="duration_minutes",
# @null=true,
@drwl
drwl / stuff.rb
Created February 15, 2024 07:44
unexpected ripper output when subscribing to events
file = <<~FILE
# typed: strong
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
#
module Admin