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:
| 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 |
| # 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. |
| import time | |
| import json | |
| import websocket | |
| import threading | |
| import gevent | |
| import logging | |
| import dateutil | |
| import datetime | |
| from websocket import create_connection |
I hereby claim:
To claim this, I am signing this object:
| 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); |
| SELECT value, id, similarity | |
| FROM other_table | |
| CROSS JOIN LATERAL ( | |
| SELECT similarity(master_table.value, other_table.value) as similarity | |
| FROM master_table | |
| ORDER BY similarity DESC | |
| LIMIT 1 | |
| ) l |
| require 'concurrent' | |
| require 'concurrent-edge' | |
| # require 'benchmark' | |
| # require 'pry' | |
| # rails... | |
| #require './config/environment' | |
| class Roo::Base | |
| def each_sheet_concurrently(&block) |
| class Roo::Base | |
| def each_sheet_concurrently(&block) | |
| jobs = Concurrent::Array.new | |
| self.sheets.each do |name| | |
| jobs << Concurrent.future { | |
| block.call(self.sheet(name)) | |
| } | |
| end | |
| Concurrent.zip(*jobs).value |
| #file_path = some excelx file with 6 sheets..... | |
| ## WITH DUP | |
| roo = Roo::Spreadsheet.open file_path | |
| jobs = Concurrent::Array.new | |
| roo.each_with_pagename do |name, sheet| | |
| local_sheet = sheet.dup |
| require 'concurrent' | |
| require 'benchmark' | |
| def process_sheets(sheets) | |
| all_dependencies = Concurrent::Array.new | |
| sheets.each_pair do |name, rows| | |
| rows.each do |val| | |
| all_dependencies.push(Concurrent::Future.execute {val*2}) | |
| end |