Skip to content

Instantly share code, notes, and snippets.

@MarceloCajueiro
MarceloCajueiro / script.rb
Created July 17, 2018 11:50
Move sidekiq jobs from one queue to another
queue = Sidekiq::Queue.new("default")
queue.each do |job|
if job.klass == "DailyFrequencyCreatorWorker"
DailyFrequencyCreatorWorker.set(queue: 'daily_frequency_creator').perform_async(*job.args)
job.delete
end
end;nil
@ta1kt0me
ta1kt0me / add_frozen_string_literal_comment.rb
Last active May 29, 2022 13:33
Add frozen string literal comment into generated files in rails v5.1.0
module AddFrozenStringLiteralComment
def add_frozen_string_literal_comment(dist)
if File.exist?(dist) && File.extname(dist) == '.rb'
File.open(dist, 'r') do |f|
body = f.read
File.open(dist, 'w') do |new_f|
new_f.write("# frozen_string_literal: true\n" + body)
end
end
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active March 21, 2024 09:16
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@jonathandean
jonathandean / gist:7449772
Last active December 8, 2021 19:15
Installing postgres gem pointing to homebrew installation

I needed to reinstall my postgres gem after upgrading to OS X Mavericks. I used homebrew to install postgres.

Find the path to your postgres config with

brew info postgres

And look for something like: postgres -D /usr/local/var/postgres # serve that database

Now use the --with-pg-config option to point to that directory and use gem install directly instead of bundler for just this one:

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active March 27, 2024 19:48
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'