Skip to content

Instantly share code, notes, and snippets.

View tjl2's full-sized avatar

Tim Littlemore tjl2

  • DICE
  • Cheshire, UK
  • 19:16 (UTC +01:00)
View GitHub Profile
# The ability to disable/enable access to phpMyAdmin on a Rails project that has
# an installation in the public directory.
namespace :phpmyadmin do
desc "Disable access to phpMyAdmin"
task :disable, :roles => :web do
run "echo 'deny from all' > #{current_path}/public/phpmyadmin/.htaccess"
end
desc "Enable access to phpMyAdmin"
task :enable, :roles => :web do
In the context of this cronjob:
/usr/bin/lockrun --lockfile=/path/to/lockrun.collections.batch.execute -- sh -c "NEWRELIC_ENABLE=true $RAKE_SILENT collections:batch:execute --trace"
Does this look right (whole thing outputs to /dev/null, but rake task directs to mail command):
/usr/bin/lockrun --lockfile=/path/to/lockrun.collections.batch.execute -- sh -c "NEWRELIC_ENABLE=true $RAKE_SILENT collections:batch:execute --trace 2>&1 | mail -s "Output from collections_batch_execute" someone@somewhere.com" >> /dev/null 2>&1
desc "Reindex all sunspot models in solr"
task :reindex_sunspot , :roles => :app, :only => {:solr => true} do
run "cd #{release_path} && rake #{rails_env} sunspot:reindex"
end
cd /var/log/engineyard/mongrel/ecr
f=production.log
mv $f $f.tmp && touch $f && chown ecr:ecr $f && monit restart all -g ecr && gzip -c $f.tmp > /data/old_logs/`hostname`/mongrel/ecr/$f-`date +%Y%m%d-%H:%M`.gz && rm $f.tmp
cd /var/log/engineyard/nginx
f=ecr.access.log
mv $f $f.tmp && touch $f && kill -HUP `cat /var/run/nginx.pid` && gzip -c $f.tmp > /data/old_logs/`hostname`/nginx/$f-`date +%Y%m%d-%H:%M`.gz && rm $f.tmp
@tjl2
tjl2 / default.rb
Created October 20, 2010 14:31
Custom chef recipe for nginx rewrites
# Replace "appname" as appropriate for your environment
remote_file "/data/nginx/servers/appname.rewrites" do
owner node[:owner_name]
group node[:owner_name]
mode 0644
source "appname.rewrites"
backup false
action :create
end
#!/usr/bin/env ruby
require "rubygems"
require "mechanize"
def growl(title, message)
ENV['title'] = title
ENV['message'] = message
%x(/usr/local/bin/growlnotify "\$title" -m"\$message")
end
@tjl2
tjl2 / .bashrc
Created January 13, 2011 09:44 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
bundle exec ./script/console
Loading development environment (Rails 2.3.10)
>> class TestQueue
>> @queue = :test
>> def self.perform(thing)
>> logger.debug("Performing thing: #{thing}")
>> end
>> end
=> nil
>> Resque.enqueue(TestQueue, "this thing")
#!/bin/bash
if [ -f ./script/rails ]; then
echo "Looks like Rails 3.x..."
COMMAND='./script/rails runner'
elif [ -f ./script/runner ]; then
echo "Looks like Rails 2.x..."
COMMAND='./script/runner'
fi
service "vixie-cron"
service "sysklogd"
service "nginx"
link "/etc/localtime" do
to "/usr/share/zoneinfo/GB"
notifies :restart, resources(:service => ["vixie-cron", "sysklogd", "nginx"]), :delayed
not_if "readlink /etc/localtime | grep -q 'GB$'"
end