This file contains hidden or 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
# Algorithm taken from ATO website. | |
def valid_abn?(abn) | |
WEIGHTS = [10,1,3,5,7,9,11,13,15,17,19] | |
tmpabn = abn.split("").map{|c| c.to_i} | |
tmpabn[0] = tmpabn[0] - 1 | |
checksum = (0..10).inject(0) do |sum, i| | |
sum + (tmpabn[i].to_i * WEIGHTS[i]) | |
end | |
return (checksum % 89) == 0 | |
end |
This file contains hidden or 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 Geolocatable | |
def acts_as_geolocatable(options = {}) | |
options = {:lat => 'lat', :lng => 'lng'}.merge(options) | |
write_inheritable_attribute :acts_as_geolocatable_options, options | |
class_inheritable_reader :acts_as_geolocatable_options, options | |
include Geolocatable::Model |
This file contains hidden or 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
!#/usr/env ruby | |
require 'json' | |
require 'uri' | |
# Removes repeated USER records from one of the AMQP queues. | |
# | |
# USAGE: ruby queue_fix.rb queue_name, email_address | |
# | |
# This will dump the whole queue to a temp file. (In case anything goes wrong) | |
# it will strip out the user messages containing the email provided then |
This file contains hidden or 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
!#/usr/env ruby | |
require 'json' | |
require 'uri' | |
# Removes repeated messages from one of the AMQP queues. | |
# | |
# USAGE: ruby queue_uniq.rb "queue_name" | |
# | |
# This will dump the whole queue to a temp file. (In case anything goes wrong) | |
# it will strip out any messages with the duplicated payloads then |