Skip to content

Instantly share code, notes, and snippets.

@roberthopman
roberthopman / routes_to_csv.rb
Last active March 25, 2025 19:19 — forked from adamdullenty/routes_csv.rake
copy paste rails routes to csv
# Add as Rake task or Rails console
class CSVFormatter
def initialize
@buffer = []
end
def result
@buffer.join("\n")
end
@roberthopman
roberthopman / bidi-example.rb
Created May 5, 2025 06:59 — forked from dieter-medium/bidi-example.rb
This proof of concept demonstrates how to generate a PDF from a local HTML file using plain Ruby and WebDriver BiDi. The script starts Chromedriver in headless mode, creates a new browsing context via BiDi, navigates to the specified local file (using a placeholder for the file path), and prints the page as a PDF over a WebSocket connection. No …
#!/usr/bin/env ruby
# see:
# https://w3c.github.io/webdriver-bidi/#command-browsingContext-print
# https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
# https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/examples/print_example.py
# https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/examples/_helpers.py
require 'net/http'