Skip to content

Instantly share code, notes, and snippets.

@benweint
benweint / go.mod
Created December 12, 2023 06:07
Go maps vs. SQLite for very simple ops
module github.com/benweint/sqlite-demo
go 1.20
require github.com/mattn/go-sqlite3 v1.14.18 // indirect
@benweint
benweint / package.json
Created December 4, 2023 18:45
pnpm signal handling issue repro case
{
"name": "pnpm-signals",
"private": true,
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "node signals.js"
},
"author": "",
"license": "ISC"
@benweint
benweint / poolsim.py
Created March 11, 2023 06:02
Connection pool metastability simulation
#!/usr/bin/env python
import simpy
import random
import math
import pandas
import matplotlib
import matplotlib.pyplot as plt
# Represents a shared database instance with a fixed CPU allocation.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCu9eMRYwWS5Z1bLjpfPfKzuvQhKOhGX0Q7KLPOf3rkgsyZ8mJGGnKMAjpDFeH7MIjwQ1au9Gp3tc+ENbnyjHhtRDUkajTjU6odq2DYMUuGJo5JJTbUFPOrHcTn5kgDpc4a9XTT+7EHS9gC8SjGzsxqTMf1WafoaKrDH2WS3vdo91MMmsmDJorro0FjWcN1gkGlXkqqxdUuiQjY19NAEetCyoMOxnmjFI4qFF7U4L1ynHVUfGyE0XOUru1YgAOYvncNoSShkFqoln7fSPE6lLz1GBt6e5KDOhpVSRU/S5FLmFBGUg8ajG7UzokFE1QE2Oqg8KJTAF42gr5xRMIkH/D ben@Bens-MacBook-Pro.local
@benweint
benweint / hs_err_pid14830.log
Created July 27, 2015 22:55
node jmx crash
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f000c94109a, pid=14830, tid=139638219114368
#
# JRE version: 6.0_35-b35
# Java VM: OpenJDK 64-Bit Server VM (23.25-b01 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.13.7
# Distribution: Ubuntu 14.04 LTS, package 6b35-1.13.7-1ubuntu0.14.04.1
# Problematic frame:
@benweint
benweint / sidekiq-sampler.rb
Created April 10, 2015 19:55
Recording Sidekiq job counts by job class and queue name to New Relic Insights
require 'sidekiq/api'
if File.basename($0) == 'sidekiq'
Thread.new do
loop do
begin
t0 = Time.now
qcount = 0
njobs = 0
@benweint
benweint / db_metrics.rb
Created February 18, 2015 05:48
DB metrics broken out by host
ActiveSupport::Notifications.subscribe('sql.active_record') do |name, start_time, end_time, guid, opts|
connection_id = opts[:connection_id]
if connection_id
conn = ObjectSpace._id2ref(connection_id)
if conn
config = conn.instance_variable_get(:@config)
if config
host = config[:host]
adapter = config[:adapter]
if host && adapter
@benweint
benweint / allocs.rb
Last active August 29, 2015 14:15
rbx allocation counting
#!/usr/bin/env ruby
def log_allocated_objects
value = Rubinius::Metrics.data[:'memory.large.objects.total']
puts "memory.large.objects.total = #{value}, class = #{value.class}"
end
loop do
log_allocated_objects
10000.times { Object.new }
@benweint
benweint / forwardabletest.rb
Last active August 29, 2015 14:14
forwardable
#!/usr/bin/env ruby
require 'benchmark'
require 'forwardable'
class Horse
def bark(n); end
end
class ForwardedHorse
@benweint
benweint / results.txt
Last active August 29, 2015 14:13
rbx segv in ossl_raise
Running "agent_only" for Envfile entry 0
Starting tests in child PID 35877 at 2015-01-20 11:22:53 -0800
ffi2-generators (0.1.1), json (1.8.2), metaclass (0.0.4), minitest (4.7.5), mocha (0.14.0), newrelic_rpm (3.9.9), racc (1.4.12), rack (1.4.5), rack-test (0.6.2), rb-readline (0.5.2), rubysl (2.1.0), rubysl-abbrev (2.0.4), rubysl-base64 (2.0.0), rubysl-benchmark (2.0.1), rubysl-bigdecimal (2.0.2), rubysl-cgi (2.0.1), rubysl-cgi-session (2.0.1), rubysl-cmath (2.0.0), rubysl-complex (2.0.0), rubysl-continuation (2.0.0), rubysl-coverage (2.0.3), rubysl-csv (2.0.2), rubysl-curses (2.0.1), rubysl-date (2.0.8), rubysl-delegate (2.0.1), rubysl-digest (2.0.3), rubysl-drb (2.0.1), rubysl-e2mmap (2.0.0), rubysl-english (2.0.0), rubysl-enumerator (2.0.0), rubysl-erb (2.0.2), rubysl-etc (2.0.3), rubysl-expect (2.0.0), rubysl-fcntl (2.0.4), rubysl-fiber (2.0.0), rubysl-fileutils (2.0.3), rubysl-find (2.0.1), rubysl-forwardable (2.0.1), rubysl-getoptlong (2.0.0), rubysl-gserver (2.0.0), rubysl-io-console (2.0.0), rubysl-i