Skip to content

Instantly share code, notes, and snippets.

require 'net/http'
require 'benchmark'
def make_request(sleep_mins, read_timeout = 1)
puts "sleep_mins=#{sleep_mins} mins read_timeout=#{read_timeout} mins"
uri = URI.parse 'http://localhost:4040'
request = Net::HTTP::Get.new("/sleep?m=#{sleep_mins}")
Net::HTTP.start(uri.host, uri.port, read_timeout: (read_timeout * 60)) do |http|
begin
require 'awesome_print'
AwesomePrint.irb!
rescue LoadError
Gem.install('awesome_print')
retry
end
ap '👋🌎'
namespace :export do
desc <<-DESC.strip_heredoc
Export tables listed as YAML
Usage: `rails export:tables TABLES=users,posts,comments`
DESC
task tables: :environment do
models = ENV["TABLES"].split(",").map do |name|
name.to_s.classify.constantize
rescue NameError
nil

Error

rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.4 using ruby-build 20220713)
# frozen_string_literal: true
# rubocop:disable
def puts_here(stuff = nil)
black_background_white_text = "\e[30;47m"
reset = "\e[0m"
puts([black_background_white_text, "*" * 20, self.class.name, "---", caller(1..1).first, "*" * 20, reset].join(" "))
if block_given?
yield
@rob-murray
rob-murray / asdf_install_ruby_ssl.sh
Created April 14, 2020 20:14
ASDF - Install Ruby with SSL
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" asdf install ruby 2.6.5
@rob-murray
rob-murray / UK Company Number regex
Last active February 4, 2024 02:12
A regex to check UK Company numbers - ie the reference assigned to companies in the UK via Companies House
/^((AC|ZC|FC|GE|LP|OC|SE|SA|SZ|SF|GS|SL|SO|SC|ES|NA|NZ|NF|GN|NL|NC|R0|NI|EN|\d{2}|SG|FE)\d{5}(\d|C|R))|((RS|SO)\d{3}(\d{3}|\d{2}[WSRCZF]|\d(FI|RS|SA|IP|US|EN|AS)|CUS))|((NI|SL)\d{5}[\dA])|(OC(([\dP]{5}[CWERTB])|([\dP]{4}(OC|CU))))$/
rails new app_name \
--database=postgresql \
--skip-action-cable --skip-action-mailer --skip-active-storage \
--skip-sprockets --skip-action-mailbox --skip-action-text \
--skip-bundle --skip-keeps --skip-spring --skip-test \
--skip-coffee --skip-system-test --skip-turbolinks
#!/bin/bash
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp \
-p 80:80 \
-p 443:443 \
-e TZ="Europe/London" \
linters:
LineLength:
max: 40