Skip to content

Instantly share code, notes, and snippets.

@sephraim
sephraim / README.md
Last active April 2, 2024 20:21
[Resolving "bundler requires Ruby version >= 3.0.0" in Dockerfile]

If you try to build your Ruby Dockerfile and get the following error(s):

 => ERROR [app base 4/4] RUN gem install bundler                                                                                                                                                                                                  24.1s
------
 > [app base 4/4] RUN gem install bundler:
24.10 ERROR:  Error installing bundler:
24.10 	The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.4.22. Try installing it with `gem install bundler -v 2.4.22`
24.10 	bundler requires Ruby version >= 3.0.0. The current ruby version is 2.6.10.210.
------
@sephraim
sephraim / README.md
Last active January 3, 2024 22:25
[Install Ruby via asdf]

1.) Upgrade asdf itself

If installed via homebrew...

brew update && brew upgrade

If installed via curl...

asdf update
@sephraim
sephraim / .ruby-version
Created December 19, 2023 21:41
[Ruby version files]
# Put this in your .ruby-version file
3.2.2
# Put this in your Gemfile
ruby file: '.ruby-version'
# ... which is equivalent to:
ruby '3.2.2'
# Source: https://twitter.com/RubyCademy/status/1736747484154593748
@sephraim
sephraim / gh_actions_local.sh
Created November 16, 2023 20:30
[Run GitHub Actions locally] Use the Nektos `act` command to run actions locally
# Run workflow on a MacOS 13 Ventura runner
act -W .github/workflows/<WORKFLOW_NAME>.yml -P self-hosted=sickcodes/docker-osx:ventura
@sephraim
sephraim / create_steamos_recovery_drive.sh
Last active February 1, 2025 14:09
[Create SteamOS recovery drive] Using Mac or Linux, create a SteamOS disk image flash drive to recover, repair, or re-image your Steam Deck
# NOTE: This process takes ~16 minutes on an M1 Mac
# RESOURCES:
# - https://www.cyberciti.biz/faq/how-to-create-disk-image-on-mac-os-x-with-dd-command/
# - https://help.steampowered.com/en/faqs/view/1B71-EDF2-EB6D-2BB3
# STEPS:
# 1.) Download the SteamOS .img.bz2 file from here: https://help.steampowered.com/en/faqs/view/1B71-EDF2-EB6D-2BB3
@sephraim
sephraim / 0_README.md
Created September 1, 2023 07:24
[Override Dockerfile / Gemfile for local development] # Add the following files to your project root

Key points

  • Run docker compose run web bundle && docker compose build to update your Gemfile.lock before building the image
  • Gemfile.dev should be nearly identical to Gemfile but also contain development gems such as 'debug' and 'solargraph-rails'
  • Dockerfile.dev should be nearly identical to Dockerfile, except for the FROM image version, COPY Gemfile.dev Gemfile, COPY Gemfile.lock Gemfile.lock, and possibly using the root user
  • Remember to revert your Gemfile.lock before committing, e.g. git checkout develop -- Gemfile.lock
@sephraim
sephraim / docker-compose.yml
Created August 9, 2023 18:01
[Docker Compose + Traefik] Reverse proxying + customizing localhost domains using Traefik
services:
traefik:
image: traefik:2.10
command: --api.insecure=true --providers.docker
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
rails1:
@sephraim
sephraim / 0_README.md
Last active August 15, 2023 21:17
[Docker setup for Ruby gem development]

Example commands

Start a bash session

docker compose build && docker compose run client bash

Run tests

docker compose build && docker compose run client rspec
@sephraim
sephraim / sql_server_connection.R
Created July 6, 2023 22:36
Connect to SQL Server with R
# REQUIREMENTS:
# 1.) Your computer must be connected to the same network as the SQL Server,
# likely either through VPN or VDI.
# 2.) You will need to have the SQL Server driver installed. Admins can install
# it directly, but non-admins should be able to install it indirectly by
# installing Azure Data Studio.
library(DBI)
library(odbc)
@sephraim
sephraim / read_write_yaml.rb
Last active May 21, 2023 15:44
[Read / write YAML file]
require 'json'
require 'openstruct'
require 'yaml'
FILE_PATH = '/path/to/file.yml'
### LOAD YAML FILE AS A YAML OBJECT ###
yaml = YAML.load_file(FILE_PATH) # with string keys
yaml = JSON.parse(YAML.load_file(FILE_PATH).to_json, symbolize_names: true) # with symbol keys