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/bin/env ruby -w | |
| ## Using ruby's standard OptionParser to get subcommand's in command line arguments | |
| ## Note you cannot do: opt.rb help command | |
| ## other options are commander, main, GLI, trollop... | |
| # run it as | |
| # ruby opt.rb --help | |
| # ruby opt.rb foo --help | |
| # ruby opt.rb foo -q | |
| # etc |
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
| # frozen_string_literal: true | |
| module Packer | |
| # A special packer class for globally identifiable objects. It takes a global ID and packs it as a String, then rehydrates it as a GlobalID lookup. | |
| class GloballyIdentifiable | |
| def self.from_pack(uri) | |
| GlobalID::Locator.locate(uri) | |
| end | |
| def initialize(identifiable) |
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
| # frozen_string_literal: true | |
| class RingBuffer | |
| Nothing = Data.define | |
| EMPTY = Nothing.new | |
| attr_reader :size | |
| def initialize(capacity:) | |
| @capacity = capacity |
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
| require_relative 'tuple_space' | |
| class Cache | |
| def initialize | |
| @memory = TupleSpace.new(reaper_period_in_secs: 10, expires_in_secs: 60) | |
| end | |
| def get(request) | |
| @memory[request] | |
| 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
| [Unit] | |
| Description=Docker Image Prune | |
| [Service] | |
| Type=oneshot | |
| ExecStart=/usr/bin/docker image prune -f | |
| WorkingDirectory=/tmp |
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
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = :transaction | |
| end | |
| config.before(:each, js: true) do |
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
| # after reviewing /etc/defaults/periodic.conf I have decided | |
| # to disable these items in jails | |
| daily_status_disks_enable="NO" | |
| daily_status_network_enable="NO" | |
| daily_status_uptime_enable="NO" | |
| # not needed on jails | |
| daily_ntpd_leapfile_enable="NO" |
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
| #!/bin/bash | |
| usage() { | |
| cat << EOF | |
| Usage: $0 [OPTION]... COMMAND | |
| Execute the given command in a way that works safely with cron. This should | |
| typically be used inside of a cron job definition like so: | |
| * * * * * $(which "$0") [OPTION]... COMMAND | |
| Arguments: |
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
| assets | |
| business | |
| accounts receivable | |
| bank | |
| personal | |
| accounts receivable | |
| bank | |
| cash | |
| gifts | |
| online |
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
| # Example: Lazy.new(lambda { |id| API::HackerNews.item(id) }, 0) | |
| class Lazy | |
| attr_reader :value | |
| def initialize(function:, value:) | |
| @function = function | |
| @value = value | |
| @cached = nil | |
| @is_cached = false |