Skip to content

Instantly share code, notes, and snippets.

View emailrhoads's full-sized avatar

John Rhoads emailrhoads

View GitHub Profile
@emailrhoads
emailrhoads / pg_dump_import.md
Last active November 12, 2020 19:06
[Import PG Dump] Create new pg ddump import #gemini #postgres

Create new database

dropdb gemini_development
createdb gemini_development

Restore your dump

Postgres 9/10

@emailrhoads
emailrhoads / rebuild_gemini.md
Last active March 26, 2020 15:50
[Rebuild Test Database] #rails #rspec

If getting farts about environment var not being set

bundle exec rails db:environment:set RAILS_ENV=test
export RAILS_ENV=test

Gemini & where db:structure is involved

RAILS_ENV=test bundle exec rake db:drop db:create db:structure:load db:migrate db:seed
@emailrhoads
emailrhoads / resize_vm.sh
Created December 19, 2019 14:55
[Resize VM from scratch] #virtualbox
cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS
VBoxManage modifyhd --resize 100000 ~/VirtualBox\ VMs/CMIT\ Environment/MartyDemo.vdi
# Then install the parted ISO & run VM & repartition
@emailrhoads
emailrhoads / diag.txt
Created December 19, 2019 14:56
[Marty Diag] #marty
VIEW DIAGS
diag?op=health
diag?op=<smaller>
@emailrhoads
emailrhoads / stop_nginx.sh
Last active March 12, 2020 15:50
[Stop NGINX] nginx autostarts on ubuntu blocking port 3000 #linux
#STOP NGINX
systemctl stop nghttpx.service # halt service
systemctl disable nghttpx.service # disable on startup
@emailrhoads
emailrhoads / running_queries_mssql.sql
Created December 19, 2019 14:58
[Active Queries] #msssql
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
@emailrhoads
emailrhoads / .bash_aliases
Last active April 26, 2021 15:54
[Bash aliases] for keyword shortcuts #linux
alias xxcomp='find . | grep ".*\.rb$" | xargs -L 1 ruby -c | grep -v "Syntax OK"'s
alias xxfocus='bundle exec rspec --tag focus --format documentation'
alias xxrc='git diff-tree -r --no-commit-id --name-only @\{u\} | xargs bundle exec rubocop -a'
alias xxdbreset='RAILS_ENV=test bundle exec db:drop db:create db:structure:load db:migrate'
# rake
alias dbms='bundle exec rake db:migrate:status'
alias be='bundle exec'
alias datav0='bundle exec rake data:migrate VERSION=0'
function dbdown() { bundle exec rake db:migrate:down VERSION=$1; }
@emailrhoads
emailrhoads / restart_postgres.sh
Last active March 12, 2020 15:49
[Restart Postrgres] on ubuntu #postgres
sudo systemctl restart postgresql
@emailrhoads
emailrhoads / launch_postgres_console.sh
Last active October 23, 2021 14:07
Launch Postgres Console #postgres
sudo su -
su postgres
psql
@emailrhoads
emailrhoads / regen_gemini_dbs.sh
Last active December 6, 2021 16:42
Rebuild structure and dumps #gemini
git checkout origin/master db/structure.sql
git checkout origin/master spec/lib/gemini/tie_20*/dump.psql
RAILS_ENV=test be rake db:drop db:create db:structure:load db:migrate
RAILS_ENV=test be rake gemini:update_dump_files
git checkout origin/master db/structure.sql
RAILS_ENV=test be rake db:drop db:create db:structure:load db:migrate
git status
git add db/structure.sql
git add spec/lib/gemini/tie_20*/dump.psql
git commit -m "regen structure and dumps"