Skip to content

Instantly share code, notes, and snippets.

View lewispb's full-sized avatar

Lewis Buckley lewispb

View GitHub Profile
@lewispb
lewispb / test.rb
Created December 22, 2023 00:21
tracepoint
class TestObj
def method_missing(method_name, *args)
if method_name == :works?
true
else
super
end
end
def respond_to_missing?(method_name, include_private = false)
module SessionSystemTestHelper
def sign_in_as(user)
visit root_url # any fast-to-load page will do
cookie_jar = ActionDispatch::TestRequest.create.cookie_jar
cookie_jar.signed[:session_token] = user.sessions.create.token
page.driver.browser.manage.add_cookie(name: "session_token", value: cookie_jar[:session_token], sameSite: :Lax, httpOnly: true)
end
end
@lewispb
lewispb / kredis_bench.rb
Last active February 25, 2022 17:19
KRedis unique list (sorted set) vs unique list (list)
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails"
@lewispb
lewispb / integrationtest.rb
Created February 24, 2022 21:14
ActionDispatch::IntegrationTest
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
@lewispb
lewispb / rufus.rb
Created March 24, 2020 10:24
Find out when a Rufus scheduler cron will run next n times
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
job = scheduler.schedule_cron('0 7 * * 6 America/Denver') { }
job.next_times(10)
homebrew=/usr/local/bin:/usr/local/sbin
export PATH=$homebrew:$PATH
brew doctor