Skip to content

Instantly share code, notes, and snippets.

View ryenski's full-sized avatar
🎯
Focusing

Ryan Heneise ryenski

🎯
Focusing
  • Austin, TX
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<donation>
<id type="integer">579779</id>
<persona-id type="integer">60341</persona-id>
<received-on type="date">2010-07-09</received-on>
<amount-in-cents type="integer">57900</amount-in-cents>
<authorization-code nil="true"></authorization-code>
<bank-name></bank-name>
<bank-number></bank-number>
<?xml version="1.0" encoding="UTF-8"?>
<persona>
<birthday type="date" nil="true"></birthday>
<company-name>Innatech</company-name>
<department>Development</department>
<donations-count type="integer">0</donations-count>
<exclude type="boolean">false</exclude>
<gender-id type="integer" nil="true"></gender-id>
<id type="integer">60341</id>
<import-id type="integer" nil="true"></import-id>
# From http://zylstra.wordpress.com/2008/03/12/a-kinder-gentler-phone-number-validation/
validates_format_of :phone,
:message => "must be a valid telephone number.",
:with => /^[\(\)0-9\- \+\.]{10,20} *[extension\.]{0,9} *[0-9]{0,5}$/i
# Preserve and escape HTML in HAML
module Haml
module Filters
module Preserve
include Haml::Filters::Base
def render(text)
text = Haml::Helpers.html_escape(text)
text = Haml::Helpers.preserve(text)
text
end
class Export < ActiveRecord::Base
include ActionView::Helpers::DateHelper
include ActionView::Helpers::NumberHelper
has_attached_file :attachment, :storage => :s3
belongs_to :organization
belongs_to :user
after_create :process
memory_usage = `ps -o rss= -p #{Process.pid}`.to_i # in kilobytes
# Source: http://laurelfan.com/2008/1/15/ruby-memory-usage
# Heroku S3 Database backup task
# by Nick Merwin (Lemur Heavy Industries) 10.08.09
# * dumps db to yaml, gzip's and sends to S3
#
# Setup:
# 1) replace APP_NAME and BACKUP_BUCKET with your info
# 2) add config/s3.yml like so (same as Paperclip's):
# production:
# access_key_id: ...
# secret_access_key: ...
SystemNotifier.deliver_notification "My subject", "My optional message"
# app/mailers/system_mailer.rb
def notification(subject, message=nil)
@recipients = "[email protected]"
@from = "[email protected]"
@sent_on = Time.now
@subject = subject
@body[:message] = message
end