Skip to content

Instantly share code, notes, and snippets.

View REPL gem install & require
begin
require 'awesome_print'
AwesomePrint.irb!
rescue LoadError
Gem.install('awesome_print')
retry
end
ap '👋🌎'
View export_tables.rake
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
View ruby install issues.md

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)
View puts_here.rb
# frozen_string_literal: true
# rubocop:disable
def puts_here(symbol: "*")
puts symbol + caller(1..1).first + symbol * 50
if block_given?
yield
puts symbol + caller(1..1).first + symbol * 50
end
end
@rob-murray
rob-murray / asdf_install_ruby_ssl.sh
Created Apr 14, 2020
ASDF - Install Ruby with SSL
View asdf_install_ruby_ssl.sh
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 Nov 24, 2022
A regex to check UK Company numbers - ie the reference assigned to companies in the UK via Companies House
View UK Company Number regex
/^((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))))$/
View rails new skip
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
View pi-docker.sh
#!/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" \
View fix macos default icons
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3; killall Dock; killall Finder