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 | |
require 'fileutils' | |
require 'find' | |
require 'zlib' | |
binaries_dir = File.join Gem.dir, 'binaries' | |
gems_dir = File.join Gem.dir, 'gems' | |
Dir['*/', base: gems_dir].each do |gem| |
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
# mDNS client | |
# | |
# Usage: ruby script.rb "_http._tcp.local." | |
require "socket" | |
require "ipaddr" | |
require "fcntl" | |
require "resolv" | |
module DNSSD |
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
You'll need to update the following variables: | |
- ENV['APP_NAME'] | |
- ENV['COMPANY_ADDRESS'] | |
- ENV['HOST'] | |
Make sure you have app/assets/images/logo.svg for this line: | |
helpers.image_url('logo.svg') | |
And also update the CSS variables to match your color scheme: | |
:root { |
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
#!/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 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 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 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 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 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 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: |
NewerOlder