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 TestAlert < AlertComposer | |
set_alert :name => 'Test alert', | |
:description => 'budget reached and get alerts', | |
:level => 'error', # or 'warning', 'danger' or default => 'info' | |
:flash => true # default false, to ensure system notification is flashed to get attention | |
def notify receiver, related_id, extra={} | |
"this is test system alert :) or return nil to avoid" | |
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
require 'goliath' | |
require 'active_record' | |
require 'active_support' | |
#require 'em-synchrony' | |
#require 'em-synchrony/em-http' | |
# The location of the Rails app to integrate | |
RAILS_APP ||= "#{File.expand_path File.dirname(__FILE__)}/../.." |
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 Array | |
def rassoc obj, place=1 | |
if place | |
place = place.to_i rescue -1 | |
return if place < 0 | |
end | |
self.each do |item| | |
next unless item.respond_to? :include? |
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
Loading development environment (Rails 3.2.3) | |
1.9.3p194 :001 > l = Location.new 'San Francisco' | |
=> #<Location id: nil, locatable_id: nil, locatable_type: nil, ip: nil, country: "US", state: "California", state_abbreviation: "CA", county: nil, city: "San Francisco", street: nil, address: "San Francisco", zip: "94103", lat: #<BigDecimal:6ea81b0,'0.37775002E2',18(45)>, lng: #<BigDecimal:6ea7f58,'-0.122418297E3',18(45)>, walkscore: nil, transit_score: nil, avg_school_rating: nil, created_at: nil, updated_at: nil> | |
1.9.3p194 :002 > ap l | |
#<Location:0x00000006b82e18> { | |
:id => nil, | |
:locatable_id => nil, | |
:locatable_type => nil, | |
:ip => nil, | |
:country => "US", |
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 'net/imap' | |
class MailWatcher | |
Server = 'imap.gmail.com' | |
Username = '' | |
Password = '' | |
Folder = 'INBOX' | |
PollingInterval = 60 | |
CheckFileLocation = "#{File.dirname(__FILE__)}/../../tmp/checks/" |
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 ApplicationController < ActionController::Base | |
... | |
before_filter :handle_redirect_loop_if_appears | |
... | |
after_filter :set_session_back_url | |
... | |
def handle_redirect_loop_if_appears |
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 'csv' | |
module CSVReports | |
class Base | |
attr_accessor :columns, :column_separator, :row_separator | |
def initialize items, columns=[] | |
@items = items | |
self.columns = columns |
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
Food | |
1405 - Amol/Renuka | |
184 - Omkar/Shruti | |
0 - Yogesh/Radhika | |
490 - Pushkar/Tejal | |
___________________ | |
2079 that means 520 per couple | |
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 'active_support/core_ext' | |
class PricingCalc | |
attr_reader :bill, :usage | |
def initialize entire_usage | |
@bill = 0 | |
@usage = 0 | |
@entire_usage = entire_usage | |
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
ActiveAdmin.register_page "Dashboard" do | |
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") } | |
content :title => proc{ I18n.t("active_admin.dashboard") } do | |
# div :class => "blank_slate_container", :id => "dashboard_default_message" do | |
# span :class => "blank_slate" do | |
# span "Welcome to Active Admin. This is the default dashboard page." | |
# small "To add dashboard sections, checkout 'app/admin/dashboards.rb'" | |
# end |
OlderNewer