Skip to content

Instantly share code, notes, and snippets.

@jjb
jjb / shipyard-shell.sh
Created June 22, 2023 17:48
Shipyard Shell
#!/usr/bin/env sh
# usage
# shipyard-shell PRNUMBER SERVICENAME
# shipyard-shell 6187 postgres
# shipyard-shell 6187 api
pr=$1
service=$2
identifier=`shipyard get environments | grep pr$pr | xargs | cut -w -f1` # xargs to remove leading and trailing whitespace
@jjb
jjb / file.md
Created June 20, 2023 02:15
How to see which rubocop file is being evaluated

If you are in a situation where rubocop is hanging on a file but you don't know which one, afaik there is no way to have rubocop pring each filename as it runs it. None of the formatters do this and there is no verbose mode. Even --debug does not do this.

Here is a hack to (very slowly) invoke rubocop once for each candidate file:

bundle exec rubocop --list-target-files > files.txt
cat files.txt | xargs -L1 -n1 bundle exec rubocop # this works on macos/bsd, use --verbose instead of -t on linux
@jjb
jjb / apt-file.sh
Last active June 13, 2023 17:41
The equivalent of redhat/centos yum whatprovides for debian/ubuntu
apt update
apt install -y apt-file
apt-file update
apt-file find psql
apt-file find bin/psql
apt-file find postgresql.conf
apt-file find --fixed-string convert # equivalent of .*convert.*, way too much
apt-file find --fixed-string /usr/bin/convert # need to know exact path
apt-file find --regexp '.*bin/convert$' # bingo. would also pick up .../sbin/
@jjb
jjb / file.rb
Created May 13, 2023 01:36
in MacOS, temporarily set the clipboard to something, and then set it back, using ruby
old=`pbpaste`
`echo '#{ENV['THE_TEXT']}' | pbcopy`
3.downto(0) do |second|
`osascript -e 'display notification "Reseting clipboard in #{second} seconds" with title "TMP Clipboard"'`
sleep 1
end
`echo '#{old}' | pbcopy`
@jjb
jjb / file.md
Last active April 28, 2025 03:04
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