This file contains 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
class Reporter | |
class << self | |
def run_example_report(person,start_date,end_date) | |
sd_string = start_date.strftime("%Y%m%d") | |
ed_string = end_date.strftime("%Y%m%d") | |
filename = "#{person.name}_report_for_#{sd_string}_#{ed_string}" | |
self.run_report(filename,"EXAMPLE") do |sheet| | |
sheet.add_row [person.name] |
This file contains 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 :db do | |
desc "abort rake if using bad memory techniques" | |
task :safety_migrate => :environment do | |
path = "#{RAILS_ROOT}/db/migrate/" | |
migration_directory = Dir.new(path) | |
proceed = true | |
migration_directory.each do |file| | |
if file != "." and file != ".." | |
migration = File.open("#{path}#{file}") | |
text = migration.read |
This file contains 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
class File | |
def uber_gets(delimiter) | |
segment = "" | |
self.each_byte do |byte| | |
char = byte.chr | |
if char == delimiter | |
yield segment | |
segment = "" | |
else | |
segment = "#{segment}#{char}" |
This file contains 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
require 'roo' | |
require 'csv' | |
class SpreadsheetParser | |
def self.parse(file) | |
name = file.path | |
if name =~ /\.csv/ | |
CSV::Reader.parse(file).each do |row| | |
yield row |
This file contains 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
class BjJob < ActiveRecord::Base | |
set_table_name "bj_job" | |
set_primary_key "bj_job_id" | |
end |
This file contains 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
def restore_from_destroyed_string(string,clss) | |
clean_string = string.gsub(/>, #<[A-Za-z0-9]+\sid:/,'}, {:id=>'). | |
gsub(/,\s([A-Za-z0-9_]+):\s/,', :\1=> '). | |
gsub(/>\]$/,"}]"). | |
gsub(/^\[#<[A-Za-z0-9]+\sid:/,"[{:id=>") | |
attr_array = eval(clean_string) | |
attr_array.each do |attrs| | |
success = clss.new(attrs).save | |
puts "creating object #{attrs[:id]}...#{success}" | |
end |
This file contains 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
class ActiveSupport::TestCase | |
#... | |
def assert_contains(collection,item) | |
assert_not_nil collection.index(item) | |
end | |
def assert_does_not_contain(collection,item) | |
assert_nil collection.index(item) | |
end |
This file contains 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
# | |
# Cookbook Name:: whenever | |
# Recipe:: default | |
# | |
ey_cloud_report "whenever" do | |
message "starting whenever recipe" | |
end | |
# Set your application name here |
This file contains 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
module Moonshado | |
class Sms | |
cattr_accessor :sent_messages | |
def deliver_sms | |
raise MoonshadoSMSException.new("Invalid message") unless is_message_valid?(@message) | |
data = {:sms => {:device_address => format_number(@number), :message => @message.to_s}} | |
self.class.sent_messages ||= [] |
This file contains 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
=form_for(brand,:url=>save_brand_content_path,:html => { :multipart => true }) do |f| | |
=hidden_field_tag :brand_id,brand.id | |
-if content | |
=hidden_field_tag :content_type,content.class.to_s | |
=hidden_field_tag :id,content.id | |
#page_header | |
#brand_name | |
=f.text_field :name | |
= image_tag(brand.logo.url(:medium)) | |
=f.file_field :logo |
OlderNewer