Skip to content

Instantly share code, notes, and snippets.

View ryenski's full-sized avatar
🎯
Focusing

Ryan Heneise ryenski

🎯
Focusing
View GitHub Profile
SystemNotifier.deliver_notification "My subject", "My optional message"
# app/mailers/system_mailer.rb
def notification(subject, message=nil)
@recipients = "sysadmin@example.com"
@from = "sysadmin@example.com"
@sent_on = Time.now
@subject = subject
@body[:message] = message
end
# 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: ...
memory_usage = `ps -o rss= -p #{Process.pid}`.to_i # in kilobytes
# Source: http://laurelfan.com/2008/1/15/ruby-memory-usage
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
# 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
# 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
<?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>
<?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>
<?php
class Push_Highrise{
var $highrise_url = ''; // your highrise url, e.g. http://yourcompany.highrisehq.com
var $api_token = ''; // your highrise api token; can be found under My Info
var $task_assignee_user_id = ''; // user id of the highrise user who gets the task assigned
var $category = ''; // the category where deals will be assigned to
var $errorMsg = "";
@ryenski
ryenski / gist:1120376
Created August 2, 2011 15:08
catch/throw
marble_jar = 0
count = 0
catch :jar_is_full do
1000000000000.times do |marble|
count += 1
# grab a random-sized marble
marble = rand(9)