In particular the update from 2022-04-26 23:54:00 UTC
For the protection of our customers, we will not be reconnecting to GitHub until we are certain that we can do so safely, **which may take some time
require 'benchmark/ips' | |
# This is a quick bemchmark to compare the performance of ways to convert | |
# an integer to a base32 string, we want to comare a low-level way to do it | |
# that uses bit shifting and a high-level way that uses the Integer#digits | |
# | |
# Turns out using the digits(32) method is faster than using bit shifting... | |
# unless you turn on --yjit in which case the bit shifting loop is better | |
# | |
# Here are the results on my machine: |
module Searchable | |
extend ActiveSupport::Concern | |
included do | |
include PgSearch::Model | |
class_attribute :searchable_attributes, default: [] | |
class_attribute :searchable_internal_attributes, default: [] | |
multisearchable against: [ | |
:searchable_attributes_text, | |
:custom_searchable_text |
#!/usr/bin/env ruby | |
# Run this program on the commandline as: | |
# | |
# ruby day-1.rb <filename of csv> | |
# | |
# The output will be a prettified JSON representation of the result | |
# | |
require 'csv' |
In particular the update from 2022-04-26 23:54:00 UTC
For the protection of our customers, we will not be reconnecting to GitHub until we are certain that we can do so safely, **which may take some time
#!/usr/bin/env ruby | |
require 'optimist' | |
require 'thread' | |
require 'socket' | |
opts = Optimist::options do | |
opt :host, "Hostname to connect to", default: "127.0.0.1" | |
opt :port, "Port to connect to", default: 4332 | |
opt :timeout, "Connection timeout", type: :integer |
This is code associated with the blog post ...
% bundle exec ./send-bench.rb | |
Warming up -------------------------------------- | |
native 973.581k i/100ms | |
symbol 476.433k i/100ms | |
string 355.763k i/100ms | |
frozen 417.573k i/100ms | |
constant-frozen 356.666k i/100ms | |
instance_eval 738.433k i/100ms | |
singleton_method 468.459k i/100ms | |
subclass 794.878k i/100ms |
#!/usr/bin/env ruby | |
line_number = 0 | |
unique_counts = Hash.new(0) | |
filename = ARGV.shift | |
abort "filename needed" unless filename | |
File.open(filename) do |f| | |
header = f.readline.strip |
class CreatePgSearchDocuments < ActiveRecord::Migration[6.0] | |
def self.up | |
create_table :pg_search_documents do |t| | |
t.text :content | |
t.string :searchable_type | |
t.uuid :searchable_id | |
t.tsvector :content_tsvector | |
t.timestamps null: false | |
end |
require 'logger' | |
class LogFormatter | |
MSG_FORMAT = "%s -- %5s : %s\n".freeze | |
DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N".freeze | |
attr_accessor :datetime_format | |
def initialize | |
@datetime_format = nil |