All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
Options included below:
- Using Docker
docker-compose
- Using Homebrew
brew
This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew
any longer. Instead consider adding a barebones docker-compose.yml
for each project and run docker-compose up
to start each project's mysql service.
My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.
As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.
I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.
So, in order to profile your worker, add this to your Sidekiq configuration:
if ENV["PROFILE"]
class CorsMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
default_headers = { | |
'Access-Control-Allow-Origin' => '*', | |
'Access-Control-Allow-Methods' => 'GET, POST, DELETE, PUT, PATCH, OPTIONS', | |
'Access-Control-Allow-Headers' => 'Content-Type, api_key, Authorization, origin' |
module CarrierWave | |
module MiniMagick | |
def toaster_filter | |
manipulate! do |img| | |
img.modulate '150,80,100' | |
img.gamma 1.1 | |
img.contrast | |
img.contrast | |
img.contrast | |
img.contrast |
YARD CHEATSHEET http://yardoc.org
May 2020 - updated fork: https://gist.github.com/phansch/db18a595d2f5f1ef16646af72fe1fb0e
cribbed from http://pastebin.com/xgzeAmBn
Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.
# MySQL. Versions 4.1 and 5.0 are recommended. | |
# | |
# Install the MySQL driver: | |
# gem install mysql2 | |
# | |
# And be sure to use new-style password hashing: | |
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
development: | |
adapter: mysql2 | |
encoding: utf8 |