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
# karafka.rb | |
class KarafkaApp < Karafka::App | |
setup do |config| | |
# setup | |
end | |
# Unique consumer group for our dynamic consumers | |
DYNAMIC_CONSUMER_GROUP_NAME = "#{ENV['KAFKA_PREFIX']}dyn-group" |
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 "redis-client" | |
## | |
# Emulate the methods of the Redis gem for HealthMonitor | |
# so we can use RedisClient gem instead. | |
# | |
class HealthMonitorRedisClient | |
def initialize | |
# REDIS_CONNECTION_SETTINGS should be defined elsewhere | |
@client = RedisClient.config(**REDIS_CONNECTION_SETTINGS).new_client |
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 | |
## | |
# Construct an exclusion search query for Datadog log search for Tenable IP address ranges. | |
# | |
# Datadog does not seem to be able to reliably use CIDR notation but | |
# if we know the start and end of each IP address range we can construct a single compound query. | |
# Here we retreive the latested published list of IP address ranges and filter that down to | |
# the short list of regions we care about. | |
# |
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
## | |
# Run this with different versions of Ruby and BigDecimal to see different results. | |
# | |
# https://ruby-doc.org/3.2.1/exts/bigdecimal/BigDecimal.html | |
# | |
require "bigdecimal/util" | |
result_float_math = ((111.87 - 99) * 2) | |
puts "= Ruby v#{RUBY_VERSION}" |
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 "benchmark" | |
# https://github.com/zverok/wheretz | |
require "json" # Should be required by wheretz but it isn't currently | |
require "wheretz" | |
# https://github.com/HarlemSquirrel/tzf-rb | |
require "tzf" |
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
## | |
# | |
# https://github.com/anolson/git_diff | |
require 'git_diff' | |
patch = `git diff main -U0 --diff-filter=AM` | |
diff = GitDiff.from_string(patch) | |
diff.files.each do |diff_file| |
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 | |
## | |
# Compare location-biased autocomplete search results from Mapbox and Google Places | |
# | |
require 'json' | |
require 'net/http' | |
QUERIES = [ |
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 | |
begin | |
require "git" | |
require "datadog_api_client" | |
rescue LoadError | |
Gem.install "git" | |
Gem.install "datadog_api_client" | |
require "git" |
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
module Youtube | |
API_KEY = Rails.application.credentials.youtube_api_key.freeze | |
end | |
module Youtube | |
class SomeClass | |
def call | |
puts API_KEY | |
end | |
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
#!/usr/bin/env ruby | |
## | |
# Run one or more specs as many times as you need in a row. | |
# | |
# The files are loaded just once for speed and | |
# failure counts are tracked and reported at the end. | |
# | |
# Provide the number of times and the file(s). | |
# i.e. |
NewerOlder