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 WorkingDayCalculator | |
def self.working_days_from_now(number) | |
new(Date.today).add_working_days(number) | |
end | |
attr_reader :date | |
def initialize(date) | |
@date = date | |
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 BankHolidayUpdateWorker | |
DataRetrievalError = Class.new(StandardError) | |
include Sidekiq::Worker | |
include Sidekiq::Status::Worker | |
UPDATE_INTERVAL = 2.days | |
def perform | |
return true if last_updated.updated_at > UPDATE_INTERVAL.ago | |
return last_updated.touch if stored_data_current? |
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 BankHoliday < ApplicationRecord | |
serialize :dates, Array | |
scope :by_updated_at, -> { order(updated_at: :asc) } | |
before_validation :populate_dates | |
validates :dates, presence: true | |
def self.dates | |
BankHolidayUpdateWorker.perform_in 10.seconds |
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
# frozen_string_literal: true | |
class BankHolidayRetriever | |
UnsuccessfulRetrievalError = Class.new(StandardError) | |
API_URL = 'https://www.gov.uk/bank-holidays.json' | |
DEFAULT_GROUP = 'england-and-wales' | |
def self.dates | |
new.dates(DEFAULT_GROUP) | |
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
function onEdit(e) { | |
new Date().toLocaleString("en-GB", {timeZone: "Europe/London"}) | |
var user = Session.getActiveUser().getEmail(); | |
var oldValue = e.oldValue | |
var sName = e.source.getActiveSheet().getSheetName(); | |
if(sName == "Standards Assurance Table") { | |
var mA1 = e.range.getA1Notation().split(":")[0]; |
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
var array = [{ | |
name: 'anne' | |
}, { | |
name: 'jim' | |
}, { | |
name: 'sam' | |
}, { | |
name: 'kay' | |
}, { | |
name: 'olive' |
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
for (let i = 0; i < people.length; i++) { | |
console.group('person:' + people[i].name); | |
console.group('pets'); | |
for (let j = 0; j < people[i].pets.length; j++) { | |
console.log(people[i].pets[j]); | |
} | |
console.groupEnd(); | |
console.groupEnd(); | |
} |
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
var people = [{ | |
name: 'anne', | |
pets: ['dog', 'cat'] | |
}, | |
{ | |
name: 'jim', | |
pets: ['dog'] | |
}, | |
{ | |
name: 'sam', |
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
var car = { | |
colour: 'red', | |
doors: '5', | |
topSpeed: '120mph', | |
engine: 'four-stroke', | |
power: '200bhp' | |
}; | |
console.log(car); |
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
{ | |
"Start obvious console.log()": { | |
"prefix": "slog", | |
"body": [ | |
"console.log('%c <<< log start >>> ', 'color: black; background-color: yellow');" | |
], | |
"description": "Make it obvious you are starting a console.log()" | |
}, | |
"End obvious console.log()": { | |
"prefix": "elog", |
NewerOlder