Skip to content

Instantly share code, notes, and snippets.

View 123ish's full-sized avatar

123ish LLC 123ish

View GitHub Profile
@123ish
123ish / add_virtual_column_index_to_ahoy_events.rb
Created November 25, 2020 02:20 — forked from kevinhq/add_virtual_column_index_to_ahoy_events.rb
Virtual Column Index for ahoy_events table
class AddVirtualColumnIndexToAhoyEvents < ActiveRecord::Migration[6.0]
def up
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD properties_id INT AS (JSON_UNQUOTE(properties->"$.id")) STORED;'
)
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD INDEX (properties_id);'
)
end
def down
@123ish
123ish / 11_set_preload.config
Created September 26, 2020 16:33
.ebextensions/11_set_preload.config
# https://brandonhilkert.com/blog/reducing-sidekiq-memory-usage-with-jemalloc/
files:
"/etc/environment":
mode: "000644"
owner: root
group: root
content: |
LD_PRELOAD=/usr/lib64/libjemalloc.so
@123ish
123ish / 03_install.config
Created September 26, 2020 16:29
.ebextensions/03_install.config
## for Aamazon Linux 2
commands:
01-install-libs:
command: yum install -y libwebp-devel libjpeg-turbo-devel ImageMagick-devel
02-setup-epel-repo:
command: |
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
if [ $? -ne 1 ]; then # Exit on any any error except 'nothing to do'
exit 0
@123ish
123ish / 00_rate_limit.conf
Created September 26, 2020 16:22
.platform/nginx/conf.d/00_rate_limit.conf
# Example of nginx configulation file for AL2 Amazon Elastic Beanstalk
# your vpc subnet where ELB resides in
set_real_ip_from 10.0.0.0/8;
# Then you have the configuration like this. Please note real_ip_header and real_ip_recursive have
# to be placed in the bottom of the IP list otherwise the module will not work properly(I’ve spent so much time on this).
real_ip_header X-Forwarded-For;
@123ish
123ish / 01_whenever.sh
Created September 26, 2020 16:10
.platform/hooks/postdeploy/01_whenever.sh
#!/bin/sh
cd /var/app/current/
sudo /opt/elasticbeanstalk/.rbenv/shims/bundle exec whenever --update-crontab
@123ish
123ish / 01_update_bundler.sh
Created September 26, 2020 16:05
.platform/hooks/predeploy/01_update_bundler.sh
#!/bin/sh
# default bundler of Amazon Linux 3.1.1 is 2.1.4, so no need to update
sudo /opt/elasticbeanstalk/.rbenv/shims/gem install bundler -v 2.1.4
@123ish
123ish / 01_yarn.sh
Created September 26, 2020 15:58
.platform/hooks/prebuild/01_yarn.sh
#!/bin/sh
# need to install node first to be able to install yarn
sudo curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum -y install nodejs
# install yarn
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
sudo yum -y install yarn
@123ish
123ish / puma.rb
Last active September 26, 2020 20:52
./config/puma.rb
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
# Specifies the `environment` that Puma will run in.
rails_env = ENV['RACK_ENV'] || "development"
@123ish
123ish / Procfile
Created September 26, 2020 15:34
AL2 Elastic Beanstalk Procfile
web: bundle exec puma -C /var/app/current/config/puma.rb
@123ish
123ish / application.html.erb
Created August 15, 2020 18:03 — forked from kevinhq/application.html.erb
Step-by-Step guide on how to move from Sprockets to Webpacker - application.html.erb
<%# app/views/layouts/application.html.erb %>
<!DOCTYPE html>
<html>
<head>
<!-- add this new application.js -->
<%= javascript_pack_tag 'application' %>
</head>
<body>
<%= yield %>
</body>