With buf.gen.yaml as:
version: v2
plugins:
- remote: buf.build/grpc/ruby:v1.71.0
out: gen
include_imports: true
- remote: buf.build/protocolbuffers/ruby:v30.2
out: gen| {} |
| # frozen_string_literal: true | |
| # Simple datadog trace parser/debugger | |
| # | |
| # To run, simply: | |
| # $ rackup -p 8126 | |
| require 'roda' | |
| require 'pry' | |
| require 'msgpack' |
| # Unsubscribe from all repositories of a given organization, | |
| # except from thoses where you're a contributor | |
| set org myorg | |
| set username johndoe | |
| for repo in (gh api /orgs/$org/repos --paginate | jq -r '.[] | select(.archived == false).name') | |
| if gh api /repos/$org/$repo/contributors | jq >/dev/null -e --arg username "$username" 'map(.login) | index($username)' | |
| gh api -XPUT /repos/$org/$repo/subscription -F "subscribed=true" -F "ignored=false" | jq -c | |
| else | |
| gh api -XDELETE /repos/$org/$repo/subscription |
| # Following datadog patterns, see: | |
| # https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/tracing/contrib/karafka/distributed/propagation.rb | |
| # https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/tracing/contrib/karafka/patcher.rb#L27-L49 | |
| class MyCustomPropagation < Datadog::Tracing::Distributed::Propagation | |
| def initialize( | |
| propagation_style_inject:, | |
| propagation_style_extract:, | |
| propagation_extract_first: | |
| ) | |
| super( |
| name | age | |
|---|---|---|
| john doe | 12 | |
| albert francis | 16 |
With buf.gen.yaml as:
version: v2
plugins:
- remote: buf.build/grpc/ruby:v1.71.0
out: gen
include_imports: true
- remote: buf.build/protocolbuffers/ruby:v30.2
out: gen| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'dry-configurable' | |
| end | |
| require "singleton" | |
| class Settings |
| require 'readline' | |
| def __flush_history | |
| Readline::HISTORY.slice!(0..-1) | |
| end | |
| def __restore_history(irb_history) | |
| __flush_history | |
| irb_history.each { |line| Readline::HISTORY << line } | |
| end |
Linting an open api description
npx @redocly/cli lint swagger/openapi.jsonGenerating doc hmtl page for the description
npx @redocly/cli build-docs swagger/openapi.json
| # frozen_string_literal: true | |
| # rubocop:disable Style/Documentation | |
| IRB.conf[:SAVE_HISTORY] = 10_000 | |
| alias r require | |
| %w[json securerandom yaml pp pry pry-byebug redis zlib base64].each do |lib| | |
| r lib | |
| rescue LoadError |