Skip to content

Instantly share code, notes, and snippets.

View edavis10's full-sized avatar

Eric Davis edavis10

View GitHub Profile
class Alert < ActiveRecord::Base
def self.delete_stale
execute <<-EOS
DELETE FROM alerts
WHERE alerts.alertable_type = 'Post'
AND alerts.alertable_id IN (
SELECT id FROM posts WHERE deleted = 1
)
EOS
end
@edavis10
edavis10 / delicious.sh
Created December 16, 2010 21:12
Grab the del.icio.us bookmarks into an xml file that is date stamped (auto monthly rotation)
#!/bin/bash
# Grab the del.icio.us bookmarks into an xml file... ick know but it works!
curl --user theadmin:PASSWORD -o /home/edavis/doc/D/delicious/Delicious`date +%d`.xml -O 'https://api.del.icio.us/v1/posts/all'
namespace :uploads do
desc "Symlink uploads to shared path"
task :symlink do
run "rm -Rv #{release_path}/public/wp-content/uploads/"
run "ln -nfs #{shared_path}/uploads #{release_path}/public/wp-content/uploads"
end
end
#
# Core Redmine sync
#
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[instaweb]
local = true
cerberus_project('redmine_sqlite',
:git_url => "git://github.com/edavis10/redmine.git",
:database_yml_source => "/home/#{configuration[:user]}/.cerberus/database.yml.sqlite3",
:rake_task => 'log:clear ci')
#####
# Customize the default logger (http://ruby-doc.org/core/classes/Logger.html)
#
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
#
# Rotate logs bigger than 1MB, keeps no more than 7 rotated logs around.
# When setting a new Logger, make sure to set the log level too.
#
# config.logger = Logger.new(config.log_path, 7, 1048576)
# script/console
include IssuesHelper
include CustomFieldsHelper
# Pick one:
# All issues and projects
File.open('output-file.csv','w') do |f|
f.puts issues_to_csv(Issue.all)
end
# Returns the mail adresses of users that should be notified
def recipients
notified = project.notified_users
# Author and assignee are always notified unless they have been locked
notified << author if author && author.active? && author.notify_about?(self)
notified << entered_by if entered_by && entered_by.active? && entered_by.notify_about?(self)
notified << assigned_to if assigned_to && assigned_to.active? && assigned_to.notify_about?(self)
notified.uniq!
# Remove users that can not view the issue
notified.reject! {|user| !visible?(user)}
def default_assignee_id
if some_setting
"Hardcoded value"
else
read_attribute(:default_assignee_id)
end
end
def default_assignee_id=(v)
if some_setting
should "select the exact matching user first" do
case_sensitive_user = User.generate_with_protected!(:login => 'changed', :password => 'admin', :password_confirmation => 'admin')
# bypass validations to make it appear like existing data
case_sensitive_user.update_attribute(:login, 'ADMIN')
user = User.try_to_login("ADMIN", "admin")
assert_kind_of User, user
assert_equal "ADMIN", user.login
end