Skip to content

Instantly share code, notes, and snippets.

View Drowze's full-sized avatar

R Gibim Drowze

View GitHub Profile
# 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
@Drowze
Drowze / datadog_distribute_tracing.rb
Last active June 4, 2025 17:34
Minimal custom datadog distributed tracing
# 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
@Drowze
Drowze / Generating the SDK.md
Created April 18, 2025 13:53
Using Zitadel with Ruby (gRPC)

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
@Drowze
Drowze / settings.rb
Created March 20, 2025 15:42
Using dry-configurable to store app settings.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'dry-configurable'
end
require "singleton"
class Settings
@Drowze
Drowze / .pryrc
Created October 18, 2024 18:20
Avoid overwriting irb history with pry (when opening a pry session inside an existing irb session)
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
@Drowze
Drowze / README.md
Last active October 11, 2024 13:13
Useful OpenAPI notes and ideas
  • Linting an open api description

    npx @redocly/cli lint swagger/openapi.json
  • Generating doc hmtl page for the description

npx @redocly/cli build-docs swagger/openapi.json

@Drowze
Drowze / .irbrc
Last active September 4, 2024 16:51
My .irbrc - with some hacks here and there; definitely not something you'd want in a production environment!
# 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
@Drowze
Drowze / create_jwt.sh
Created March 4, 2024 19:19 — forked from shu-yusa/create_jwt.sh
Generate private and public keys, and create JWT and JWKs
#!/bin/sh
## Requires openssl, nodejs, jq
pack() {
# Remove line breaks and spaces
echo "$1" | sed -e "s/[\r\n]\+//g" | sed -e "s/ //g"
}
generate_keys_and_token() {
local prefix=$1
{
"keyMappings": "map gc closeOtherTabs\n\n\" option-f on a mac\nmap <a-ƒ> LinkHints.activateModeWithQueue\n\n\" option-p on a mac\nmap <a-π> togglePinTab\n\n\" \\-esc should pass esc (to close a modal on a site)\nmap \\ passNextKey",
"newTabUrl": "pages/blank.html",
"searchEngines": "w: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia\ng: https://www.google.com/search?q=%s Google\ny: https://www.youtube.com/results?search_query=%s Youtube\ngm: https://www.google.com/maps?q=%s Google maps\nd: https://duckduckgo.com/?q=%s DuckDuckGo\naz: https://www.amazon.co.uk/s/?field-keywords=%s Amazon\n\n# More examples.\n#\n# (Vimium supports search completion Wikipedia, as\n# above, and for these.)\n#\n# g: https://www.google.com/search?q=%s Google\n# l: https://www.google.com/search?q=%s&btnI I'm feeling lucky...\n# y: https://www.youtube.com/results?search_query=%s Youtube\n# gm: https://www.google.com/maps?q=%s Google maps\n# b: https://www.bing.com/search?q=%s Bing\n# d: https://d