Skip to content

Instantly share code, notes, and snippets.

View edavis10's full-sized avatar

Eric Davis edavis10

View GitHub Profile
@edavis10
edavis10 / main.rb
Created August 26, 2011 20:28
watchr file to auto build my docbook PDF
@auto_generated_files = [
"xsl/fo.xml"
]
watch("(.*.[xml|xsl])") {|m| rebuild(m[1]) unless @auto_generated_files.include?(m[1]) }
def rebuild(file_change)
puts "[watchr] Rebuilding because #{file_change} changed"
system("rake")
puts "[watchr] Waiting for changes"
require "bundler/capistrano"
set :application, "chiliproject"
set :repository, "git@projects.littlestreamsoftware.app.git"
set :scm, :git
set :git_enable_submodules,1
# fast_remote_cache is better but requires a plugin
set :deploy_via, :remote_cache
# set :deploy_via, :fast_remote_cache
@edavis10
edavis10 / 1.rb
Created August 9, 2011 22:37
Refactoring
def validate_status_changes
return if changes.keys == ["status"]
return if changes["status"].present? && changes["status"].second == "open"
return if changes["status"].present? && changes["status"].first == "open"
errors.add_to_base(:cant_update_locked_deliverable) if locked?
errors.add_to_base(:cant_update_closed_deliverable) if closed?
end
#!/usr/bin/env ruby
system ARGV.join(' ')
@edavis10
edavis10 / .irbrc
Created May 16, 2011 23:49 — forked from gilesbowkett/user.rb
it doesn't have to be complicated
# Append the user's .railsrc.rb to the load modules, that way it's loaded
# after the rails ENV and everything else...
if $0 == 'irb' && ENV['RAILS_ENV']
IRB.conf[:LOAD_MODULES] << File.dirname(__FILE__) + '/.railsrc' # ~/.railsrc.rb, requires .rb
end
desc "Send a test email to the user with the provided login name"
task :test, :login, :needs => :environment do |task, args|
# uses args[:login]
end
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 12e7707..8326310 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -339,8 +339,16 @@ class MailHandler < ActionMailer::Base
user.lastname = '-' if user.lastname.blank?
user.login = user.mail
- user.password = ActiveSupport::SecureRandom.hex(5)
+ password = ActiveSupport::SecureRandom.hex(5)
<?xml version="1.0" encoding="UTF-8"?><issues type="array" limit="25" total_count="678" offset="0"><issue><id>1000</id><project name="Optimized modular data-warehou" id="2"/><tracker name="Bug" id="1"/><status name="New" id="1"/><priority name="Normal" id="4"/><author name="Tony Stark" id="24"/><assigned_to name="Minerva Zieme" id="16"/><parent id="834"/><subject>Grass-roots leading edge utilisation</subject><description>Maybe tomorrow I'll want to settle down - until tomorrow I'll just keep moving on. Ulysses, fighting evil and tyranny with all his power and with all of his might. Rolling down to Dallas - who is providin' my palace?.
Every stop I make I make a new friend; Can't stay for long just turn around and I'm gone again. Hong Kong Phooey number one super guy, Hong Kong Phooey quicker than the human eye. I've gotten burned over Cheryl Tiegs and blown up for Raquel Welch, but when I end up in the hay it's only hay, hey hey. Every stop I make I make a new friend; Can't stay for long just turn around
module ActionController
module RequestForgeryProtection
def verify_authenticity_token
verified_request? || handle_unverified_request
end
def handle_unverified_request
reset_session
end
@edavis10
edavis10 / secure_password.rb
Created February 2, 2011 16:55
Simple script to create random passwords
#!/usr/bin/ruby
require 'rubygems'
require 'active_support'
(3..6).each do |b|
puts ActiveSupport::SecureRandom.hex(b)
end