Skip to content

Instantly share code, notes, and snippets.

View gangelo's full-sized avatar
:octocat:
Got codez?

Gene M. Angelo, Jr. gangelo

:octocat:
Got codez?
View GitHub Profile
# This should be cloned to your .oh-my-zsh/custom/themes folder.
ARROW=%{$fg_bold[red]%}>$reset_color
RETURN=%{$fg[red]%}⮐$reset_color
PROMPT=$'\
$ARROW%{$fg_bold[yellow]%}%D{%a %b %d, %Y %-I:%M:%S %p}%{$reset_color%}\
$ARROW%{$fg_bold[cyan]%}%~%{$reset_color%}$(git_prompt_info)%{$reset_color%}\
\
%n@%m $ARROW%{$reset_color%}'
@gangelo
gangelo / auto-set-node-version.sh
Created October 10, 2025 18:49
Auto set node version - add to ~/.zshrc
# Goes in .zshrc
# Automatically switch Node version when entering a directory with .nvmrc
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
@gangelo
gangelo / code.md
Last active August 22, 2025 11:58
GRF Session Extend code

Rails 8 Multi-App Session Synchronization Solution

Architecture Overview

This solution uses ActionCable for real-time notifications and AJAX requests for session management. Redis serves as both the session store and ActionCable's pub/sub backend.

Important Constraints

  • ActionCable cannot access the session directly - Sessions are tied to HTTP, not WebSockets
  • All session modifications must go through controllers via AJAX requests
@gangelo
gangelo / git-stats
Last active November 14, 2024 16:42
Displays git stats for a repro
#!/bin/bash
# Get the user's email from Git configuration
default_email=$(git config --get user.email)
# Get the current year
default_year=$(date +%Y)
# Prompt the user for their email, using the default from Git config
read -p "Enter your email (default: $default_email): " user_email
@gangelo
gangelo / arel_blank_condition.rb
Last active October 3, 2024 13:02
Arel method that dynamically creates a blank condition named function that can me used to check a table column for blank?
def blank_condition_for(model:, attr:)
table = model.arel_table
trimmed_attr_value = Arel::Nodes::NamedFunction.new('TRIM', [table[attr]])
table[attr].eq(nil).or(trimmed_attr_value.eq(''))
end
# Usage
model = User
@gangelo
gangelo / .gitignore
Created August 31, 2024 12:31
.gitignore file for RoR
# Git Ignore File for Ruby on Rails Development
#
# If you want to use this globally:
# $ touch ~/.gitignore_global
# Copy the contents of this file into ~/.gitignore_global
# $ git config --global core.excludesfile ~/.gitignore_global
# --- Operating System Files ---
# macOS system files
.DS_Store
@gangelo
gangelo / build-rails-apps.md
Last active August 31, 2024 12:38
Various dev stuff
@gangelo
gangelo / dev-env-tools.txt
Last active March 22, 2024 14:27
Dev env tools list
git hub command-line tool: brew install gh
git stuff - https://github.com/scmbreeze/scm_breeze
fuzzy finder (fzf): https://github.com/junegunn/fzf
rails groutes: https://gist.git.uscis.dhs.gov/spmarcia/1efd716f99bc8d441d0006cbe9f4fff0
function ghpr() {
GH_FORCE_TTY=100% gh pr list | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down | awk '{print $1}' | xargs gh pr checkout
}
@gangelo
gangelo / get-chromedriver.rb
Last active May 20, 2024 13:11
Downloads and installs chromedriver for use in rails tests, using capybara.
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
require 'net/http'
require 'tmpdir'
class ChromedriverDownloader
def self.download
new.download
@gangelo
gangelo / add-ruby.sh
Last active May 20, 2024 13:10
Install new ruby version for M1 macs
#/bin/bash
# Place in ~/bin
echo "Enter the ruby you want to install. E.g. 2.7.6"
echo "NOTE: if the ruby version you want to install is not found,"
echo "run `brew upgrade ruby-build` to update the ruby build list"
echo "and try again.
read ruby_version
if [ -x "$(command -v rvm)" ]; then