Skip to content

Instantly share code, notes, and snippets.

View ioquatix's full-sized avatar
⚖️
Let's make it scalable!

Samuel Williams ioquatix

⚖️
Let's make it scalable!
View GitHub Profile
@ioquatix
ioquatix / stress.rb
Created June 3, 2022 06:42
Small stress test of async-http server (unimportant), client and barrier with timeout.
#!/usr/bin/env ruby
require 'async/container'
require 'async/barrier'
require 'async/http'
require 'async/io/shared_endpoint'
Console.logger.debug!
endpoint = Async::HTTP::Endpoint.parse('http://127.0.0.1:9294')
$ gem-codesearch "fptr->fd" | egrep -v "tauplatform|mruby-io|ruby/io.c|ruby/file.c|ruby/ext|rubylib/file.c|ossl_ssl\.c"
2015-05-30 /srv/gems/aarontc-serialport-1.4.0/ext/native/posix_serialport_impl.c: return (fptr->fd);
2015-05-30 /srv/gems/aarontc-serialport-1.4.0/ext/native/win_serialport_impl.c: return (HANDLE) _get_osfhandle(fptr->fd);
2017-01-10 /srv/gems/abaci-0.3.0/vendor/bundle/gems/nio4r-1.2.1/ext/nio4r/nio4r.h:# define FPTR_TO_FD(fptr) fptr->fd
2010-10-28 /srv/gems/amardaxini-ruby-gd-0.8.0/GD.c: #define FILE_POINTER_FOR_CREATE_FROM fdopen(fptr->fd, "r")
2020-03-09 /srv/gems/argon-1.3.1/vendor/bundle/ruby/2.7.0/gems/nio4r-2.5.2/ext/nio4r/nio4r.h:# define FPTR_TO_FD(fptr) fptr->fd
2009-08-28 /srv/gems/arika-ruby-termios-0.9.6/termios.c:#define FILENO(fptr) (fptr->fd)
2010-04-16 /srv/gems/astro-em-http-request-0.2.10/ext/buffer/em_buffer.c:#define FPTR_TO_FD(fptr) (fptr->fd)
2017-01-26 /srv/gems/autocompl-0.2.2/test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/ext/nio4r/nio4r.h:# define
TERMINAL NEED NULLS? TYPE CTL-N WHILE THIS TYPES:
*** WELCOME TO CBBS/CHICAGO ***
*** WARD AND RANDY'S COMPUTERIZED BULLETIN BOARD SYSTEM ***
-----> CONTROL CHARACTERS ACCEPTED BY THIS SYSTEM:
DEL/RUBOUT ERASES LAST HAR. TYPED (AND ECHOS IT)
CTL-C CANCEL CURRENT PRINTING
CTL-K 'KILLS' CURRENT FUNCTION, RETURNS TO MENU
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", git: "https://github.com/rails/rails.git"
# If you want to test against edge Rails replace the previous line with this:
# gem "rails", github: "rails/rails", branch: "main"
@ioquatix
ioquatix / connections.md
Last active October 2, 2025 01:35
Show how `with_connection` and `lease_connection` interact.

Permanent Connection Checkout

Rails 7.2 defaults:

Highscore.connection
# => #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x000000000080e8 env_name="development" role=:writing>

With config.active_record.permanent_connection_checkout = :disallowed:

@ioquatix
ioquatix / test.rb
Created February 21, 2025 10:24
Dump task hierarchy from another thread
#!/usr/bin/env ruby
require "async"
request = ::Thread::Queue.new
thread = Thread.new do
while true
sleep 10