Skip to content

Instantly share code, notes, and snippets.

@pivotalneutron
pivotalneutron / gist:1055856
Created June 30, 2011 08:22
Removing stale resque workers from Redis
# When resque workers are no longer around, but records of them are still sitting around in Redis...
def remove_resque_workers worker, ips
ips.each do |ip|
eval("
def worker.to_s
'#{ip}:*'
end
")
worker.unregister_worker
@pivotalneutron
pivotalneutron / gist:994591
Created May 27, 2011 03:32
Extracting failed IDs from migration jobs and requeueing them
Resque::Failure.all(28044, Resque::Failure.count - 28044).each do |j|
next unless j["retried_at"].nil?
e = j["error"]
ids = e[(e.index('[')+1)...e.index(']')].split(', ').map(&:to_i)
Jobs::MigrateLegacyUsers.submit_job(ids)
end
@pivotalneutron
pivotalneutron / gist:966089
Created May 11, 2011 08:05
Removing nodes & clients from chef server
numbers_to_delete = (10..20).to_a # or any array of numbers you need to operate on
name_prefix = 'server-name-prefix-' # will be used in a search, ie: "name:server-name-prefix-11"
names_to_delete = numbers_to_delete.map { |i| "#{name_prefix}#{i}" }
nodes_to_destroy = search(:node, names_to_delete.map { |n| "name:#{n}" }.join(" OR "))
nodes_to_destroy.each { |n| n.destroy }
clients_to_destroy = search(:client, names_to_delete.map { |n| "name:#{n}" }.join(" OR "))
clients_to_destroy.each { |c| c.destroy }
#!/usr/bin/env bash
usage() {
printf "
Usage:
rvm-install-system-wide [options]
Options: