Skip to content

Instantly share code, notes, and snippets.

@jjb
jjb / file.md
Last active March 13, 2023 12:00
Using Jemalloc 5 with Ruby.md
View file.md

This is a very quick gist I'm throwing together to get this info and discussion onto google in one place.

For years, people have been using jemalloc with ruby. There are various benchmarks and discussions. Some people say Jemalloc 5 doesn't work as well as Jemalloc 3.

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

The recipe would be something like this (shown with official docker ruby image). I didn't try this yet, don't know if it will build!

@jjb
jjb / 1 intro.md
Last active March 7, 2023 05:15
wrapper script for starting ruby with configured jemalloc 5.md
View 1 intro.md
@jjb
jjb / file.md
Created September 25, 2022 02:44
markdown indentation demo
View file.md
  1. hello
  2. hello
    1. nested
    2. nested
      1. more
      2. more
        1. and again
          puts "hello"
View Notes on rails reloader and executor.md
  • 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
View code.md

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
View code.rb
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
View code.rb
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
View file.md
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
View code.sh
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
View file.md

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|