| #!/usr/bin/env ruby | |
| require "fileutils" | |
| require "tempfile" | |
| # Function to display usage information and exit | |
| def usage | |
| puts <<~USAGE | |
| Usage: #{File.basename(__FILE__)} [directory_path] [file_extension] [--no-subdirs] | |
| - directory_path: Optional. Defaults to 'app/services/scheduling' if not provided. |
| #!/bin/bash | |
| # Usage: script/gather_files <directory_path> [file_extension] | |
| # `script/gather_files app/models` # Gather contents of ALL files in app/models directory | |
| # `script/gather_files app .rb` # Gather contents of all RUBY files in app directory | |
| # Check if directory path is provided | |
| if [ "$#" -lt 1 ]; then | |
| echo "Usage: $0 <directory_path> [file_extension]" | |
| exit 1 |
| # frozen_string_literal: true | |
| # Simple self-contained Ruby file to call OpenAI API endpoints | |
| require "httparty" | |
| require "json" | |
| module OpenAI | |
| class Client | |
| CHAT_API_ENDPOINT = "https://api.openai.com/v1/chat/completions" |
Convert AWS IAM credentials to AWS SMTP credentials
If you do, or want to, use AWS to deploy your apps, you will end up using AWS SES via SMTP when you're launching an app that sends out emails of any kind (user registrations, email notifications, etc). For example, I have used this configuration on various Ruby on Rails apps, however, it is just basic SMTP configurations and crosses over to any framework that supports SMTP sendmail.
There are two ways to go about this:
- EASY WAY: Create an SMTP user via AWS SES [http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-console]
- NOT SO EASY WAY: Create an SMTP password for an existing IAM user [^^ Same link scroll down]
Luckily, you found this MD file and the NOT SO EASY WAY is suddenly copy-pasta... sudo yum....
Development
Open terminal as X86, then run webpack:
arch -x86_64 zsh
yarn install && yarn webpackSetup
Kubernetes Security
NSA/CISA Kubernetes Hardening Guidance
A summary of the key recommendations from each section are:
- Kubernetes Pod security
- Use containers built to run applications as non-root users
- Where possible, run containers with immutable file systems
- Scan container images for possible vulnerabilities or misconfigurations
| # in test_helper.rb (for example) | |
| def mock_env(partial_env_hash) | |
| old_env = ENV.to_hash | |
| ENV.update partial_env_hash | |
| begin | |
| yield | |
| ensure | |
| ENV.replace old_env | |
| end | |
| end |
Kubernetes Oh My Zsh aliases
# This command is used a LOT both below and in daily life alias k=kubectl # Execute a kubectl command against all namespaces alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca' # Apply a YML file
| # frozen_string_literal: true | |
| class ApplicationComponent < ViewComponent::Base | |
| private | |
| # Reference: https://www.youtube.com/watch?v=YVYRus_2KZM&t=302s | |
| def fetch_or_fallback(allowed_values, given_value, fallback) | |
| if allowed_values.include?(given_value) | |
| given_value | |
| else |
| [ | |
| { | |
| "key": "cmd+q", | |
| "command": "-workbench.action.quit", | |
| }, | |
| { | |
| "key": "alt+cmd+.", | |
| "command": "workbench.action.terminal.focusAtIndex1" | |
| }, | |
| { |