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 GeoBoundingBox | |
attr_accessor :lat, :lon, :distance | |
WGS84_MAJOR_AXIS = 6378137 | |
WGS84_MINOR_AXIS = 6356752.3142 | |
WGS84_FLATTENING = 1 / 298.257223563 | |
def initialize(lat, lon, distance) | |
@lat = lat |
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
Date.prototype.startOfWeek = function() { | |
var dayOfMonth = this.getDate() - this.getDay(); | |
var month = (dayOfMonth > 0) ? this.getMonth() : this.getMonth() - 1; | |
var year = (month > 0) ? this.getFullYear() : this.getFullYear() - 1; | |
if (dayOfMonth < 0) { | |
dayOfMonth = this.getDaysInMonth(month) - (dayOfMonth * -1) | |
} |
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 Paperclip | |
class Attachment | |
def default_url(style_name = default_style) | |
interpolate(@default_url, style_name) | |
end | |
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 temporal_greeting(user, time_zone = ActiveSupport::TimeZone["Wellington"]) | |
hour = Time.now.in_time_zone(time_zone).hour | |
case hour | |
when 6..12 | |
"Good morning #{user.first_name}!" | |
when 12..17 | |
"Afternoon, #{user.first_name}." | |
when 17..12 | |
"Evening #{user.first_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
# use me to deliver emails plz kthx | |
class Notifier | |
class Job | |
VALID_ARGUMENT_TYPES = [ String, Integer, Symbol, ActiveRecord::Base ] | |
cattr_accessor :ar_prefix | |
@@ar_prefix = "%OMGSERIALIZEDAR%" | |
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
# use me to deliver emails plz kthx | |
class Notifier | |
class Job | |
def self.perform(name, args) | |
NotifierMailer.send(name, *args).deliver! | |
end | |
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 String | |
def capitalize_first | |
dup.capitalize_first! | |
end | |
def capitalize_first! | |
self[0, 1] = self[0,1].upcase; self | |
end | |
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
module ActionMailer | |
class Base | |
def deliver_with_noob_protection!(mail = @mail) | |
[:to, :cc, :bcc].each do |recipient_group| | |
old_emails = mail.send(recipient_group) | |
unless old_emails.nil? |
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
// TODO: perhaps change most/all live previews to inherit from this? | |
LivePreview = Class.create({ | |
initialize: function(preview_fields) { | |
preview_fields.each(function(field_id) { | |
var field = $(field_id) | |
var div = $(field_id + "_preview"); |
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
<script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load("visualization", "1", {packages:["linechart", "columnchart"]}); | |
google.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('string', 'Day'); | |
data.addColumn('number', 'Logged Entries'); |