Skip to content

Instantly share code, notes, and snippets.

@jjb
jjb / file.md
Last active May 9, 2024 06:26
Using Jemalloc 5 with Ruby.md

For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.

Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.

Ubuntu/Debian

FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
@jjb
jjb / 1 intro.md
Last active March 7, 2023 05:15
wrapper script for starting ruby with configured jemalloc 5.md
@jjb
jjb / file.md
Created September 25, 2022 02:44
markdown indentation demo
  1. hello
  2. hello
    1. nested
    2. nested
      1. more
      2. more
        1. and again
          puts "hello"
  • runner does not use executor in <7, does use it in >=7
  • console does not use executor in <7, not sure about >=7
@jjb
jjb / code.md
Last active January 22, 2022 01:26
single-line process restarter without systemd

example program being monitored - sleep.sh

while [ 1 ]
do
  sleep 1
  echo hello
done
@jjb
jjb / code.rb
Last active November 12, 2021 14:10
Use ruby to test if a port is available on a host, similar to telnet foo 123
require 'socket'
Socket.tcp("example.com", 443, connect_timeout: 1).close
@jjb
jjb / code.rb
Created November 2, 2021 00:36
How to work with raw compressed cache data in Rails
raw = Rails.cache.redis.get( Rails.cache.redis.keys.first)
Marshal.load raw
Marshal.load(raw).instance_variable_get :@value
Zlib::Inflate.inflate Marshal.load(raw).instance_variable_get :@value
Marshal.load Zlib::Inflate.inflate Marshal.load(raw).instance_variable_get :@value
@jjb
jjb / file.md
Last active October 15, 2021 18:25
How to start, stop, or restart postgres installed with macports
sudo port unload postgresql12-server
sudo port load postgresql12-server
@jjb
jjb / code.sh
Created September 29, 2021 10:33
How to stop and start Postgres installed from Macports on MacOS
sudo -u postgres pg_ctl -D /opt/local/var/db/postgresql12/defaultdb stop
sudo -u postgres pg_ctl -D /opt/local/var/db/postgresql12/defaultdb start
@jjb
jjb / file.md
Created September 11, 2021 01:04
Exploring the default behavior for signals in ruby

Ruby doesn't let you inherit default behavior when writing a signal trap

Here's a beginning of an exploration of what default behavior is for each signal:

# https://github.com/ruby/ruby/blob/master/signal.c#L1331-L1358
reserved = %w[SEGV BUS ILL FPE VTALRM]
reserved += %w[KILL STOP] # not listed in code but reserved via some other mechanism i was too lazy to find

Signal.list.keys.each do |signal|