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 / 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 / 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 / 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 / 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 / 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) }
# 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 / 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
@MyklClason
MyklClason / _footer.html.erb
Last active August 4, 2017 03:15
Bootstrap Rails Application.html layout with separated nav and footer
@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 / gist:4868769b6deec9deac7b4236896241fc
Created July 8, 2017 00:35
S3 IAM Template. Update the date and replace BUCKET_NAME with correct S3 bucket
{
"Version": "YYYY-MM-DD",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET_NAME",
"arn:aws:s3:::BUCKET_NAME/*"
]