Skip to content

Instantly share code, notes, and snippets.

View jonathan-wheeler's full-sized avatar

JWheel jonathan-wheeler

View GitHub Profile
@jonathan-wheeler
jonathan-wheeler / benchmark_memory_multi_tenant.rb
Created August 20, 2018 20:58
Benchmarks for reducing query_conditions_for_initial_load memory load
y = 1
Benchmark.memory do |x|
x.report(:master_large_multi_tenant_tenant_test) do
y.times do
ActiveRecord::Base.establish_connection(adapter: :postgresql, database: :large_multi_tenant_tenant_test).connection
ActiveRecord::Base.clear_active_connections!
end
end
x.report(:patch_large_multi_tenant_tenant_test) do
class DummyTables
def self.create_tables
100.times do |table_ref|
ActiveRecord::Schema.define do
create_table "table#{table_ref}" do |t|
t.integer :int_col
t.string :string_col
t.uuid :uuid_col
t.hstore :hstore_col
t.json :json_col
@jonathan-wheeler
jonathan-wheeler / index.js
Created March 15, 2017 18:04
Lambda function to synchronize no objects between two diffrent S3 Buckets
// adapted from http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
// set environment vars
var DESTINATION_BUCKET = process.env.DESTINATION_BUCKET
// get reference to S3 client
/* Taken zigmob's (http://forums.macrumors.com/showthread.php?t=1742566) workaround a step further
And added some triggers to clean up these dodgy character combinations (ff, fi, fl).
Still crashes on initial message read but saves having to manually run the sql query eve time a message contains the character combinations */
-- Working well for me so far --
CREATE TRIGGER insert_Ff AFTER INSERT ON ZWAMESSAGE
BEGIN
UPDATE ZWAMESSAGE
SET ZTEXT = replace( ZTEXT, 'ff', 'f f')
WHERE ZWAMESSAGE.ZTEXT like '%ff%';