Skip to content

Instantly share code, notes, and snippets.

View fdocr's full-sized avatar
🤓

Fernando Valverde fdocr

🤓
View GitHub Profile
@fdocr
fdocr / sidekiq_delete_jobs.md
Created August 2, 2023 19:33 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
@fdocr
fdocr / utility_server.sh
Last active February 27, 2023 15:51
A quick and dirty way to setup a Redis+Postgres utility server with docker
# Update-Upgrade & Install docker
apt update
apt full-upgrade
# Docker -> https://docs.docker.com/engine/install/ubuntu/
# Redis (https://hub.docker.com/_/redis)
mkdir redis_data
docker run --name redis -d --restart always -p 6379:6379 -v /root/redis_data:/data redis redis-server --save 60 1 --loglevel warning --requirepass <password>
# PG (https://hub.docker.com/_/postgres)
#!/usr/bin/env ruby
require 'httparty'
url = ''
concurrency = 15
threads = []
concurrency.times do |i|
threads << Thread.new do
#!/usr/bin/env ruby
require 'httparty'
url = 'https://google.com'
concurrency = 15
threads = []
concurrency.times do |i|
threads << Thread.new do
@fdocr
fdocr / rails7_upgrade.md
Created January 3, 2022 20:51
Rails7 Upgrade Checklist
  1. Gemfile && bundle update
  2. Remove Webpacker+Spring
  3. rails app:update
    1. YOLO -> Upgrade load_defaults version in config/application.rb to 7.0
    2. or configure defaults (as suggested)
  4. Install script of new gems
    1. bin/rails importmap:install
    2. bin/rails turbo:install
    3. bin/rails tailwindcss:install
  5. Move assets from webpacker -> importmap folders
@fdocr
fdocr / ruby_gem_rvm_hacks.sh
Last active December 31, 2021 15:41
Ruby Gem/RVM hacks
# Apple Sillicon
rvm gemset empty
gem install bundler -v '2.3.4' # Or more recent version
bundle config set force_ruby_platform true
bin/setup && bin/startup
# https://superuser.com/q/451032
lsof -nti:XXXX | xargs kill -9
# Rails
lsof -nti:3000 | xargs kill -9
# Webpacker dev server
lsof -nti:3035 | xargs kill -9
@fdocr
fdocr / rPi Temperature
Created July 26, 2020 03:47
Raspberry Pi parsed Temperature measurement
vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*'
# Find PID of process
lsof -n -i4TCP:3000
kill -9 [PID]
@fdocr
fdocr / heroku_migrations.gist
Last active November 4, 2019 17:16
Ruby on Rails Database management using Rake on Heroku
heroku run DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rake --trace db:schema:load
heroku run rake --trace db:migrate
heroku run rake --trace db:seed