Skip to content

Instantly share code, notes, and snippets.

View emailrhoads's full-sized avatar

John Rhoads emailrhoads

View GitHub Profile
@emailrhoads
emailrhoads / pulll_current_branch.sh
Created March 30, 2020 15:24
[Only pull current branch] #git
git pull origin $(git rev-parse --abbrev-ref HEAD)
@emailrhoads
emailrhoads / hash_to_csv_to_pg.md
Last active March 30, 2020 21:28
[Load Ruby Hash to CSV into Postgres] #postgres

Hash to CSV

my_json = JSON.parse(File.open("ss_to_census_100k_all_unique_results.json").read);
csv_string = CSV.generate(headers: true) do |csv|
  csv << my_json.first.keys
  my_json.each do |hash|
    csv << hash.values
  end
end;
@emailrhoads
emailrhoads / connect_vs_code_remote.md
Created April 8, 2020 14:49
[Connect VS Code Remote to Virtualbox] #virtualbox

On VM run

sudo apt-get install openssh-server openssh-client
ifconfig
@emailrhoads
emailrhoads / setup_steps
Last active April 8, 2020 16:46
[Setup VirtualBox] #virtualbox
1. Add Storage
2. Display is VBOXSVGA @ 90MB
3. Add Network adapter 2 as HostOnly, promiscuous deny
4. Mount shared folder/drive in settings (may need to do some terminal commands to automount here)
5. Add self to sudo and root group `sudo adduser john sudo` and `sudo usermod -a -G root john`
6. Install posgres and also `sudo apt-get install libpq-dev`
7. Install RBENV, and reshash it
8.
@emailrhoads
emailrhoads / ignore_only_locally.md
Last active April 17, 2020 15:01
[Ignore locally only] #git

Insted of using .gitignore add files to .git/info/exclude

code .git/info/exclude

If you already have files that are changed you'll need to set them as unchanged

git update-index --assume-unchanged .gitmodules
@emailrhoads
emailrhoads / list_pg_enums.sql
Created April 22, 2020 21:37
[List PG Enums] #postgres
select n.nspname as enum_schema,
t.typname as enum_name,
e.enumlabel as enum_value
from pg_type t
join pg_enum e on t.oid = e.enumtypid
join pg_catalog.pg_namespace n ON n.oid = t.typnamespace
@emailrhoads
emailrhoads / branches_and_last_commit_date.sh
Created April 24, 2020 18:37
[see branches and last commit dates] #git
git for-each-ref --sort='-committerdate:iso8601' --format=' %(committerdate:iso8601)%09%(refname)' refs/heads
@emailrhoads
emailrhoads / install_different_pg_versions.md
Last active April 28, 2020 15:09
[Install different PG versions] #postgres

Version 9.6: sudo apt-get install postgresql-9.6 postgresql-contrib

@emailrhoads
emailrhoads / create_new_user_with_password.md
Last active June 4, 2020 19:43
[Create new user] #postgres
  1. sudo su - postgres
  2. createuser --interactive --pwprompt -p 5434 where 5434 is the port of your PG cluster
sudo su - postgres
psql
CREATE USER railsuser WITH PASSWORD 'railsuser' SUPERUSER CREATEDB;
@emailrhoads
emailrhoads / see_file_commit_history.sh
Created April 29, 2020 18:23
[See history of changes for a file] #git
git log -p -- Gemfile