Skip to content

Instantly share code, notes, and snippets.

View adamlogic's full-sized avatar

Adam McCrea adamlogic

View GitHub Profile
@adamlogic
adamlogic / components.foo-bar.js
Last active February 14, 2020 15:05 — forked from givanse/components.foo-bar.js
Ember runloop demonstration with a computed property and an observer
import Ember from 'ember';
export default Ember.Component.extend({
sourceInternal: 'default',
logs: [],
source: Ember.computed('sourceInternal', {
get: function() {
this._log(`[source getter] sourceInternal=${this.get('sourceInternal')}`);
return this.get('sourceInternal');
@adamlogic
adamlogic / adapter_setup_component.rb
Created January 23, 2024 16:07
GoRails Phlex Demo
# frozen_string_literal: true
class AdapterSetupComponent < ApplicationComponent
def initialize(app, process_type)
@app = app
@process_type = process_type
end
def template
render ModalComponent.new do |modal|
@adamlogic
adamlogic / scout.rb
Created February 22, 2024 16:22
Scout APM sampling
# Apply a sample rate to Scout so it only instruments a portion of requests
# or jobs. Here's an example of how to use it in a controller action or job:
# ScoutApm::Transaction.use_sample_rate 0.001
module ScoutApm
module Transaction
# Set SCOUT_SAMPLING=false to disable sampling. This will send all transactions to Scout,
# and very quickly use up our monthly transaction limit.
USE_SAMPLING = ENV["SCOUT_SAMPLING"] != "false"
def self.use_sample_rate(rate)
@adamlogic
adamlogic / router-distribution.sh
Created July 20, 2025 16:54
Show Heroku router distribution amongst dynos
brew install angle-grinder
heroku logs -t -d router -a app-name | agrind '*
| parse regex "(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6})"
| timeslice(parseDate(timestamp)) 1m as time
| logfmt
| count as reqs,
count(at == "error") as errors,
avg(connect) as avg_connect,
avg(service) as avg_service