Rails is the well known and popular web framework built upon ruby. Ruby’s Exceptional Creatures is a resource from HoneyBadger that documents common ruby exception.
Improving Ruby Test Performance particularly RSpec test suites.
speedscope is a flamegraph tool
Improving Rails Performance
bootsnap improves rails application boot times through caching
Fixing implicit declaration error during ruby gem build1
Getting the memory size of an objecthacks
- Note that this doesn’t do anything for finding the references of an object
Delegation
Memory bloat and management
- get_process_mem gem
- jemalloc is an alternate implementation of malloc that emphasizes fragmentation avoidance
Halve Your Memory Usage with these 12 Weird Tricks is a conference topic by Nate Berkopec on rails app memory techniques
Setting up a Ruby Gem
As of early 2024:
bundle gem <NEW GEM NAME>
will create the new gem folder with rspec setup properly.- Add a
CHANGELOG.md
file. - Create a new github repo matching the gem name, set it in the gemspec and then use that to set subsequent links
- Create a
LICENSE
file and set the license in the gemspec - Add CI with github actions
- Add Coverage with coveralls and CI
- Setup gem publishing with github actions
Better command line option parsing in rake taskshacks
When passing args to a rake you end up with positional args being your only option, and you have to do some escaping in zsh, so a rake task call looks like this:
If you would like to use named args, you can use ARGV and make a call like this:
In your rake task you parse these args:
This will give you an array like:
Warning!
This will do some strange things to
gets
. The solution here is to call$stdin.gets
rather than the nakedgets
1. Amiridis, P. Fixing the implicit declaration of function error when installing ruby gems. https://petros.blog/2020/10/02/fixing-the-implicit-declaration-of-function-error-when-installing-ruby-gems/ (2020).