Skip to content

Instantly share code, notes, and snippets.

View duffyjp's full-sized avatar

Jacob Duffy duffyjp

View GitHub Profile
@duffyjp
duffyjp / ubuntu_vm_quickstart.sh
Last active March 3, 2021 19:08
This is an ever evolving script I run on new Ubuntu VMs under Hyper-V.
#!/bin/bash
echo "Set Timezone to CST"
timedatectl set-timezone America/Chicago
echo "Update Apt"
apt-get update -qq
echo "Remove Unused Default Packages"
apt-get remove -y --purge snapd cloud-init lxd
@duffyjp
duffyjp / screenshot.sh
Last active February 16, 2022 17:11
Script to open Chrome in app mode and resize to 1024x768 (Mac / Linux)
#!/bin/bash
url=${1:-http://localhost:3000}
# FYI: If your URL has an & you need to pass the argument in quotes.
# Chrome app mode doesn't work without the http/https part.
if [[ $url = *"http"* ]]; then
echo $url
else
url="http://${url}"
@duffyjp
duffyjp / profile.sh
Last active December 5, 2022 20:38
Shows interesting information in your terminal
#!/bin/bash
#
# Displays the following in your terminal:
#
# ╔────────────╦──────────╦─────────────╦─────────────╦───────╗
# ║ CPU: 68.7% ║ MEM: 53% ║ DISK: 788GB ║ profile.git ║ arm64 ║
# ╚────────────╩──────────╩─────────────╩─────────────╩───────╝
#
# Usage: * To display the above in new terminals, save this script to a file
# and add a call to the top of your ~/.profile
@duffyjp
duffyjp / paper_trail_bug_report_template.rb
Created June 8, 2017 19:09
Trying to reproduce an issue with default scopes and paper_trail starting with Rails 5.1
# Use this template to report PaperTrail bugs.
# Please include only the minimum code necessary to reproduce your issue.
require "bundler/inline"
# STEP ONE: What versions are you using?
gemfile(true) do
ruby "2.3.1"
source "https://rubygems.org"
gem "activerecord", "5.1.1"
gem 'rspec', '3.6.0'
@duffyjp
duffyjp / references_bug.rb
Created August 26, 2016 19:05
Rails 5.0.0/5.0.0.1 ActiveRecord::QueryMethods - references testcase
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
@duffyjp
duffyjp / factory_spec.rb
Created August 17, 2016 13:19
Rspec test to verify all Rails models have a FactoryGirl factory, and that each factory creates a valid model instance
# FactoryGirl factory verifier
# Jacob Duffy
# https://github.com/duffyjp
#
# Starts with all table names, then finds all models using each table.
# Verifies each model has a factory and that it is able to save!
require 'rails_helper'
describe "Factory" do
@duffyjp
duffyjp / pure_visibility.css
Last active March 23, 2016 23:45
Foundation 5 compatible visibility classes for Pure CSS
/* https://gist.github.com/duffyjp/5118bba6a98648f7fb3c
Foundation's Visibility Classes ported to Pure CSS
This is for Foundation 5, they changed it totally in 6
I only did the show-for classes, not the hide-for
-- duffyjp
show-for-small-up
show-for-small-only
@duffyjp
duffyjp / test.sh
Created November 12, 2015 16:58
Parallel Tests & Rspec shell script - Intelligently runs single spec with rspec or folder(s) / full suite with parallel_rspec. Shows nice summary at the end.
#!/bin/bash
start_time=`date +%s`
RAILS_ENV="test"
rm db/test.sqlite3*
if [[ $1 == *".rb"* ]]
then
echo "Testing with RSpec"
bundle exec rspec $1