Skip to content

Instantly share code, notes, and snippets.

Ethan Vizitei evizitei

Block or report user

Report or block evizitei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rails_reporter.rb
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 = "#{}_report_for_#{sd_string}_#{ed_string}"
self.run_report(filename,"EXAMPLE") do |sheet|
sheet.add_row []
View db.rake
namespace :db do
desc "abort rake if using bad memory techniques"
task :safety_migrate => :environment do
path = "#{RAILS_ROOT}/db/migrate/"
migration_directory =
proceed = true
migration_directory.each do |file|
if file != "." and file != ".."
migration ="#{path}#{file}")
text =
View better_file_iteration.rb
class File
def uber_gets(delimiter)
segment = ""
self.each_byte do |byte|
char = byte.chr
if char == delimiter
yield segment
segment = ""
segment = "#{segment}#{char}"
View gist:331103
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
View bj_job.rb
class BjJob < ActiveRecord::Base
set_table_name "bj_job"
set_primary_key "bj_job_id"
View active_record_lazurus_project.rb
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=> ').
attr_array = eval(clean_string)
attr_array.each do |attrs|
success =
puts "creating object #{attrs[:id]}...#{success}"
View collection_test_helper.rb
class ActiveSupport::TestCase
def assert_contains(collection,item)
assert_not_nil collection.index(item)
def assert_does_not_contain(collection,item)
assert_nil collection.index(item)
evizitei / default_whenever.rb
Created Oct 29, 2010
Whenever Chef Recipe on EY AppCloud
View default_whenever.rb
# Cookbook Name:: whenever
# Recipe:: default
ey_cloud_report "whenever" do
message "starting whenever recipe"
# Set your application name here
evizitei / moonshado_env.rb
Created Nov 13, 2010
This is put into your cucumber env.rb file to collect all messages sent through Moonshado in an array that you can check later in your scenario.
View moonshado_env.rb
module Moonshado
class Sms
cattr_accessor :sent_messages
def deliver_sms
raise"Invalid message") unless is_message_valid?(@message)
data = {:sms => {:device_address => format_number(@number), :message => @message.to_s}}
self.class.sent_messages ||= []
View brand_editor.html.haml
=form_for(brand,:url=>save_brand_content_path,:html => { :multipart => true }) do |f|
=hidden_field_tag :brand_id,
-if content
=hidden_field_tag :content_type,content.class.to_s
=hidden_field_tag :id,
=f.text_field :name
= image_tag(brand.logo.url(:medium))
=f.file_field :logo
You can’t perform that action at this time.