Skip to content

Instantly share code, notes, and snippets.

View JeffWaltzer's full-sized avatar

Jeff Waltzer JeffWaltzer

View GitHub Profile
@JeffWaltzer
JeffWaltzer / show-relations.rb
Last active August 29, 2015 14:02
LIst all ActiveRecord models with relations
Rails.application.eager_load!
puts ActiveRecord::Base.descendants.map {|m| [ m.name, m.reflections.values.map{|r| "#{r.macro} #{r.name}"} ]}.select{|k,v| v.size>0}.to_h.to_yaml
@JeffWaltzer
JeffWaltzer / tvise.rb
Last active October 25, 2023 14:31
Script for organizing TV shows
#!/usr/bin/ruby
require 'fileutils'
NO_MOVE_LIST=%w{.directory}
def cleanit(s)
s =s.split('/')[-1]
sub =s.split(/(s[0-9])|([0-9]+of)|([0-9]+x[0-9]+)|(201[0-9])|([0-9]{3})/i)
show_name = sub[0]
if show_name.size > 1
#Monkey Patch for debugging code.
if !Rails.env.production?
class Object
def yy(
quick = nil,
message: self.class,
poke: nil,
#!/bin/bash
# Put this in your ~/.git/hooks folder to auto add branch name to git commit messages.
#
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | grep -oE "[A-Z]+-[0-9]+")
if [ -n "$BRANCH_NAME" ]; then
if ! grep -q "$BRANCH_NAME" $1 ; then
echo -en "[$BRANCH_NAME] " | cat - "$1" > /tmp/out && mv /tmp/out "$1"
fi
fi
@JeffWaltzer
JeffWaltzer / diskusage.sh
Last active January 21, 2024 22:32
Find Disk Usage
du -hs $(ls -A) | sort -h