This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :delayed_job do | |
task :kill_stale_processes => :environment do | |
pid_list = IO::popen('ps aux|awk "{if (\$11 ~ \"delayed_job\") print \$2}"') | |
pids = pid_list.read.split(/\W+/) | |
pids.each do |pid| | |
%x[kill -9 #{pid}] | |
end | |
puts "Killed unresponsive delayed_job pids: #{pids.join(', ')}" if pids.any? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove all files in a directory /backup/sql which are older than 7 days | |
find /backup/sql -mtime +168 -type f -name '*.sql' -exec rm {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We want the account namespace routes available only if subdomains are specified | |
constraints(:subdomain => /[A-Za-z0-9]/) do | |
namespace :account do | |
resources :users | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Which folder is eating up the space? | |
du -s * | sort -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To fix unicode character errors in mysql | |
# => Put this file in lib and require it in environment.rb | |
require 'mysql' | |
class Mysql::Result | |
def encode(value, encoding = "utf-8") | |
String === value ? value.force_encoding(encoding) : value | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pretty commified numbers | |
module ApplicationHelper | |
def format_num(num, delim = ',') | |
number_with_precision(num, :precision => 2, :separator => '.', :delimiter => ',') | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.platform = Gem::Platform::RUBY | |
s.name = 'saas' | |
s.version = '0.1' | |
s.description = 'A generic modular application.' | |
s.required_ruby_version = '>= 1.8.7' | |
s.author = 'Anup Narkhede' | |
s.require_path = 'lib' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'saas', :require => 'saas', :path => 'lib/saas' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MyApp/lib/saas/config/routes.rb | |
Rails::Application.routes.draw do |map| | |
namespace :saas do | |
resources :sessions | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Saas/lib/saas.rb | |
module Saas | |
require File.expand_path('../../config/engine', __FILE__) | |
end |
NewerOlder