Skip to content

Instantly share code, notes, and snippets.

View dimanyc's full-sized avatar

Dimitry Nazarov dimanyc

View GitHub Profile
@eebs
eebs / sql_statement_profiling.rb
Created December 17, 2019 21:29
spec/support/sql_statement_profiling.rb
RSpec.configure do |config|
example_sql_counts = Hash.new(0)
config.around(:example) do |procsy|
sql_count = 0
callback = ->(*args) { sql_count +=1 }
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
procsy.call
end
@thestrabusiness
thestrabusiness / backend_usage.rb
Created March 4, 2023 15:04
React + ActionCable Example
class GameChannel < ApplicationCable::Channel
def subscribed
game = Game.find(params[:id])
stream_for game
end
end
## When the game state changes
GameChannel.broadcast_to(game, GameSerializer.render(game))