Skip to content

Instantly share code, notes, and snippets.

SELECT similarity(stored_value, 'my comparison value') as similarity
FROM all_store_values
ORDER BY similarity DESC, stored_value
LIMIT 1
CREATE INDEX trgm_idx ON all_store_values USING gist (stored_value gist_trgm_ops);

Keybase proof

I hereby claim:

  • I am whistlerbrk on github.
  • I am whistlerbrk (https://keybase.io/whistlerbrk) on keybase.
  • I have a public key ASDPjMGW6_Th7qNz5ji2Cw3G4eXb_LVGrKjnyfb46ulRewo

To claim this, I am signing this object:

@kshahkshah
kshahkshah / locustfile.py
Created June 15, 2017 19:06
locust file with websockets integration, reduced example
import time
import json
import websocket
import threading
import gevent
import logging
import dateutil
import datetime
from websocket import create_connection
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 8 }.to_i
threads threads_count, threads_count
# Specifies the `environment` that Puma will run in.
require 'concurrent-ruby'
require 'logger'
request_queue = Queue.new
job_stats = Concurrent::Array.new
# we have a few ways of experimenting
# one, by changing the amount of time a job takes
processing_time_factor = 1.0