Skip to content

Instantly share code, notes, and snippets.

@KensoDev
KensoDev / gist:1275672
Created October 10, 2011 15:55
Re-Queue all Resque failed jobs, delete them from the "failed" and put it into the queue
task :requeue_failed do
  (Resque::Failure.count-1).downto(0).each do |i|
    Resque::Failure.requeue(i)
    Resque::Failure.remove(i)
  end
end
@KensoDev
KensoDev / gist:1323004
Created October 28, 2011 18:34
Kill all resque workers
sudo kill -9 `ps aux | grep [r]esque | grep -v grep | cut -c 10-16`
@KensoDev
KensoDev / gist:1323026
Created October 28, 2011 18:41
Echo out all of the resque workers on the machine
echo `ps aux | grep [r]esque | grep -v grep | cut -c 10-16`
@KensoDev
KensoDev / gist:1323028
Created October 28, 2011 18:42
Re-queue all failed workers to the original queue, remove the failed item
task :requeue_failed do
(Resque::Failure.count-1).downto(0).each do |i|
Resque::Failure.requeue(i)
Resque::Failure.remove(i)
end
end
@KensoDev
KensoDev / gist:1340501
Created November 4, 2011 21:13
God configuration for Resque extra workers
rails_env = ENV['RAILS_ENV'] || "production"
rails_root = ENV['RAILS_ROOT'] || "/mnt/data-store/html/gogobot/current"
WORKER_TIMEOUT = 60 * 10 # 10 minutes
# Stale workers
Thread.new do
loop do
begin
`ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
parts = line.split(' ')
@KensoDev
KensoDev / gist:1485969
Created December 16, 2011 13:04
Search for a column in all tables of the database
SELECT * FROM information_schema.`COLUMNS` C WHERE TABLE_SCHEMA = 'your_db_name' and column_name = 'your_column_name'
@KensoDev
KensoDev / gist:1620349
Created January 16, 2012 11:18
Import database - mysql
gunzip < production.sql.gz | mysql {database_name} --user={user} --password={password} --host={host}
all_tables=`mysql {database} -B -N --user={user} --password={password} --host={host} -e "SHOW TABLES;"`
exclude_tables=(table_names)
tables=`comm -2 -3 <(echo ${all_tables} | tr ' ' '\n' | sort) <(echo ${exclude_tables[*]} | tr ' ' '\n' | sort)`
mysqldump {database} ${tables} --user={user} --password={password} --host={host} --skip-lock-tables | gzip > production.sql.gz
@KensoDev
KensoDev / dabblet.css
Created January 23, 2012 17:12
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body, html {
height: 100%;
min-height: 100%;
margin: 0;
padding: 0;
}
div {
@KensoDev
KensoDev / dabblet.css
Created January 24, 2012 16:52
line 4, ../sass/screen.scss
/* line 4, ../sass/screen.scss */
a.button {
display: block;
width: 120px;
height: 35px;
border-radius: 4px;
text-align: center;
line-height: 35px;
text-decoration: none;