Skip to content

Instantly share code, notes, and snippets.

View hayduke19us's full-sized avatar
🐙

matthew sullivan hayduke19us

🐙
View GitHub Profile
# To prevent memory leak possibilities with user errors there are constraints.
#
# * Only allows one subscriber to be active at a time. When
# instantiated it always removes all QuerySubscribers subscribed to the :client.
# * It requires a block of assertions where the instantiated monitor is
# available for access to the #query_count.
# * It is meant for a single instantiated use, and removes the subscriber from
# the client's @monitoring#subscribers Hash after the block executes. It also
# clears the recorded queries from the subscriber.
# This means you can use the QueryMonitor as many times as you like in one off
#!/usr/bin/env ruby
require 'uri'
require 'net/http'
require 'json'
require 'bigdecimal'
require 'securerandom'
# Usage
require 'byebug'
require 'benchmark/ips'
require 'csv'
RESOURCES = 30
BLOCKING_TIME = 3
class SuperUploader
THREAD_MAX = 10
attr_reader :outgoing, :thread_max, :queue, :results, :threads, :switch
require 'benchmark/ips'
require 'benchmark/memory'
# For use within a spec. Three methods must be provided within the current
# namespace. #performance_object, #performance_a, and #performance_b.
# The object is the object with the methods to be measured.
# The performance a and b are the methods to be compared.
# The original is #performance_a.
#
# Example use
class PropertyAttributes
attr_reader :raw_data, :cache
def initialize(cache)
@cache = cache
@raw_data = to_object cache.raw_data
end
def to_object(raw_data)
OpenStruct.new Hash[raw_data.map { |k, v| [k, to_struct_attributes(v)] }]
function setModalElementByClass(class_name, inner_html) {
var element = document.getElementsByClassName(class_name)[0]
if (element) {
element.innerHTML = inner_html;
} else {
console.log('Missing modal element class: ' + class_name)
}
}
require 'benchmark/ips'
require 'benchmark/memory'
# For use within a spec. Three methods must be provided within the current
# namespace. #performance_object, #performance_a, and #performance_b.
# The object is the object with the methods to be measured.
# The performance a and b are the methods to be compared.
# The original is #performance_a.
#
# Example use
import * as d3 from 'd3';
import css from './pie.css'
var contentSuppliers = require('./reports/suppliers.csv')
var margin = { top: 40, right: 20, bottom: 30, left: 20 };
var width = 600 - margin.left - margin.right;
var height = 360 - margin.top - margin.bottom;
var radius = Math.min(width, height) / 2;
var color = d3.scaleOrdinal(d3.schemeCategory20b);
class SupplierAmenities
attr_reader :file
attr_accessor :mapped
def initialize(file)
@file = file
end
def to_hash
CSV.new(File.read(file), headers: true).to_a.map(&:to_hash)
require 'httparty'
module MultiRequest
extend ActiveSupport::Concern
def multi_request_queue
@multi_request_queue ||= RequestQueue.new
end
class RequestQueue