Skip to content

Instantly share code, notes, and snippets.

View MyklClason's full-sized avatar

Mykl Clason MyklClason

  • Wisconsin, United States
View GitHub Profile
@MyklClason
MyklClason / c9pg.txt
Last active April 26, 2024 18:41
Cloud9 workspace setup with Rails and Postgresql | Copy/Pastable Script
sudo service postgresql start
sudo sudo -u postgres psql
CREATE USER username SUPERUSER PASSWORD 'password';
\q
. ~/.bashrc
echo "export USERNAME=username" >> ~/.bashrc
echo "export PASSWORD=password" >> ~/.bashrc
. ~/.bashrc
sudo sudo -u postgres psql
@MyklClason
MyklClason / _footer.html.erb
Last active August 4, 2017 03:15
Bootstrap Rails Application.html layout with separated nav and footer
@MyklClason
MyklClason / c9_backup_download_restore_db_heroku.txt
Last active August 17, 2017 18:46
Cloud9: Pull database from Heroku via backup, download and restore.
heroku pg:backups:capture
heroku pg:backups:download
pg_restore --verbose --clean --no-acl --no-owner -U ubuntu -d app_development latest.dump
# 1. Delete everything except the hidden .c9 folder
# 2. Setup aliases
# Setup Postgres database
sudo service postgresql start
sudo sudo -u postgres psql
CREATE USER username SUPERUSER PASSWORD 'password';
\q
echo "export USERNAME=username" >> ~/.profile
echo "export PASSWORD=password" >> ~/.profile
. ~/.profile
@MyklClason
MyklClason / version1b.rb
Last active January 30, 2018 05:50
Reset all RoR Postgres ID counters via rails console
Rails.application.eager_load!
ActiveRecord::Base.descendants.map { |m| ActiveRecord::Base.connection.reset_pk_sequence!(m.table_nam‌​e) }
@MyklClason
MyklClason / instructions.md
Last active March 10, 2018 10:20
Rails + Elm + Cloud9: Basic setup instructions

Setup Instructions

  1. Upgrade Rails to 5.1+ for webpacker integration
  2. Run nvm install node && nvm alias default stable to use latest version of node.
  3. Install Yarn
  4. Add webpack-dev-server and configure as below.
  5. Run rails new elm_on_rails --webpack
  6. Run rails webpacker:install if needed.
  7. Run rails webpacker:install:elm
  8. Add <%= javascript_pack_tag "javascript_filename_without_extension" %> to an html view.
@MyklClason
MyklClason / model_sizes.rb
Last active April 5, 2018 00:10
Get counts of all model records in the database via Ruby code (can be used in the console). Useful for determining what's using up heroku database row limits.
Rails.application.eager_load!
ActiveRecord::Base.descendants.map { |m| [m.name, m.all.size] }.sort_by { |m, s| -s }
# Print on seperate lines
# puts ActiveRecord::Base.descendants.map { |m| [m.name, m.all.size] }.sort_by { |m, s| -s }.map(&:inspect)
@MyklClason
MyklClason / copy-paste.bash
Last active October 30, 2018 03:13
EXPO APP
nvm install node && nvm alias default stable
npm install -g expo-cli
expo init
expo login
expo start --tunnel
@MyklClason
MyklClason / bootstrap_flash_helper.rb
Last active June 4, 2022 21:23
Bootstrap Flash Helper Bootstrap 4/5
# Modified from the Twitter Bootstrap Rails gem's Bootstrap Flash Helper (bootstrap 3) for Bootstrap 4
# Place in the helpers folder
module BootstrapFlashHelper
ALERT_TYPES = [
:primary,
:secondary,
:success,
:danger,
:warning,
:info,
@MyklClason
MyklClason / rails_guide.md
Last active April 26, 2024 18:49
AWS Cloud9 Rails Setup Guide (and migration from c9.io) for Rails 7.1

Overview

Warning: This guide intended for Rails 6.1. (It may not be complete)

This is direction for Migration from c9.io to AWS Cloud9 or to simply setup AWS Cloud9 for Rails Development, after you follow the cloud9 migration directions and created a workspace, keeping in mind the Workspace settings Section below.

Be sure you are using the right version of rails. You may need to remove rails and rail-ties and install rails 6.1. Check online for how (search how to reinstall rails with a specific version)