Skip to content

Instantly share code, notes, and snippets.

@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
@sephraim
sephraim / dropbox.rb
Last active May 10, 2023 18:43
[Ruby SFTP]
# frozen_string_literal: true
require 'net/sftp'
module Integrations
module Google
# Upload feed file(s) & fileset descriptor(s) to the Google Partner SFTP dropbox
#
# @see Google Dropbox SFTP setup: https://support.google.com/youtube/answer/3071034
#
@sephraim
sephraim / sftp.md
Created April 12, 2023 15:05
[sftp command line tool] using public key authentication

SFTP via the command line

Command

Use the following command to connect to an SFTP dropbox using public key authentication. Common locations for private key files include ~/.ssh/id_rsa and ~/.ssh/id_ed25519.

sftp -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes -o PasswordAuthentication=no -o HostKeyAlgorithms=+ssh-rsa -i /path/to/private/key -P 19321 [email protected]

In the command above, we're using the sftp command with various options:

@sephraim
sephraim / aws_s3_bucket_resource.rb
Last active March 24, 2023 16:18
[AWS S3 client in Ruby]
# Create an instance of an AWS S3 resource (bucket)
class S3Bucket
def self.fetch
s3 = Aws::S3::Resource.new(
Aws::Credentials.new(
Rails.configuration.aws_uploader_access_key_id,
Rails.configuration.aws_uploader_secret_access_key
),
)
s3.bucket(Rails.configuration.aws_bucket)
@sephraim
sephraim / create_zip_file.rb
Created March 20, 2023 16:47
[Create a zip file]
# Zip file
#
# @private
#
# @return [String] path to file
def zip_file
zfilename ||= 'example.zip'
zfile ||= Tempfile.new(zfilename) # you can also create a non-temp file so that it's not in the tmp directory
Zip::File.open(zfile.path, Zip::File::CREATE) do |zip|
['path/to/file1', 'path/to/file2'].each do |filepath|