Skip to content

Instantly share code, notes, and snippets.

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
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?
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
# 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
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];
var array = [{
name: 'anne'
}, {
name: 'jim'
}, {
name: 'sam'
}, {
name: 'kay'
}, {
name: 'olive'
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();
}
var people = [{
name: 'anne',
pets: ['dog', 'cat']
},
{
name: 'jim',
pets: ['dog']
},
{
name: 'sam',
var car = {
colour: 'red',
doors: '5',
topSpeed: '120mph',
engine: 'four-stroke',
power: '200bhp'
};
console.log(car);
{
"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",