Skip to content

Instantly share code, notes, and snippets.

View joshRpowell's full-sized avatar
🏠
Working from home

Josh Powell joshRpowell

🏠
Working from home
  • Fort Lauderdale, FL
View GitHub Profile

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@joshRpowell
joshRpowell / results.txt
Created October 4, 2022 19:53 — forked from bbugh/results.txt
Benchmarking for checking if one array contains another in Ruby
Warming up --------------------------------------
subtract 233.432k i/100ms # higher is better
bitwise & == 164.352k i/100ms
bitwise & size 218.548k i/100ms
bitwise & [] 200.794k i/100ms
contains_all 74.648k i/100ms
contains_all_count 112.634k i/100ms
set 19.238k i/100ms
set cached 194.675k i/100ms
all? include? 144.048k i/100ms
@joshRpowell
joshRpowell / avatar_uploader.rb
Created September 20, 2022 19:52 — forked from jovanmaric/avatar_uploader.rb
Testing shrine validations with RSpec
# app/uploaders/avatar_uploader.rb
class AvatarUploader < Shrine
plugin :validation_helpers
Attacher.validate do
validate_mime_type_inclusion %w[image/jpeg]
validate_max_size 10.megabytes
end
end

Dockerfile

# Build rarely changed system libraries
FROM phusion/passenger-ruby27:1.0.16 AS builder

ENV RAILS_ENV=${RAILS_ENV:-production}
ENV NODE_ENV=${RAILS_ENV:-production}
ENV RACK_ENV=${RAILS_ENV:-production}
ENV PASSENGER_APP_ENV=${RAILS_ENV:-production}
@joshRpowell
joshRpowell / example_activejob.rb
Created August 5, 2021 22:05 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
# frozen_string_literal: true
require 'irbtools'
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
if defined? Rails
@joshRpowell
joshRpowell / README.md
Created July 25, 2020 12:10 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@joshRpowell
joshRpowell / Gemfile
Created June 26, 2020 22:43 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@joshRpowell
joshRpowell / ruby2.5.0-command
Last active January 11, 2020 07:33
rvm install ruby 2.5.0 on macOS 10.13.2
•100% [I] ➜ rvm get master && rvm list known
Downloading https://get.rvm.io
Downloading https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer.asc
Verifying /Users/jpowell/.rvm/archives/rvm-installer.asc
gpg: Signature made Sat Sep 9 15:49:18 2017 EDT
gpg: using RSA key E206C29FBF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" [unknown]
gpg: Note: This key has expired!
Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3
Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17
•100% [I] ➜ rvm install ruby --debug
ruby-2.5.0 - install
Log prefix: /Users/jpowell/.rvm/log/1514463883_ruby-2.5.0/
Log filesystem: NFS
Log max name length: 250
Log file: /Users/jpowell/.rvm/log/1514463883_ruby-2.5.0/remove.src.log
[2017-12-28 07:24:43] __rvm_rm_rf
__rvm_rm_rf () {
__rvm_rm_rf_verbose "$@"
}