Skip to content

Instantly share code, notes, and snippets.

@kjavier
kjavier / gist:bc3e0670eb91964a629875f0086a7186
Created November 12, 2020 20:49 — forked from 1v/gist:04901ed17202cddfe42d
God and Puma configuration

God and Puma configuration

Add to Gemfile:

gem 'puma'
gem 'god'

Run in app folder:

bundle install
@kjavier
kjavier / puma.monitrc
Created November 12, 2020 17:04 — forked from sudara/puma.monitrc
Example config needed to use monit with puma, monitoring workers for mem.
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid
@kjavier
kjavier / deploy.rb
Created September 23, 2020 09:47 — forked from gilcierweb/deploy.rb
Mina deploy ruby on rails 5.1 ++
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
# require 'mina/rvm' # for rvm support. (https://rvm.io)
set :application_name, 'my_app'
set :domain, 'my_server'
set :deploy_to, '/home/rails/my_app'
set :repository, '[email protected]:my_user/my_app.git'
set :branch, 'master'
@kjavier
kjavier / setup.sh
Created February 17, 2020 22:20 — forked from lazypower/setup.sh
Setup headless chromium driver for selenium (vagrant flavor, but works with any ubuntu variant)
#!/bin/sh
set -e
if [ -e /.installed ]; then
echo 'Already installed.'
else
echo ''
echo 'INSTALLING'
echo '----------'
@kjavier
kjavier / Vagrantfile
Created September 26, 2019 16:15 — forked from dommmel/Vagrantfile
Vagrantfile for Ruby on Rails application development (rbenv, postgres, node.js)
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
set -e
set -x
cd
sudo apt-get update -y
sudo apt-get install \
@kjavier
kjavier / Vagrantfile
Created September 26, 2019 16:15 — forked from creisor/Vagrantfile
Vagrant file for installing ruby with rbenv
# -*- mode: ruby -*-
# vi: set ft=ruby :
RUBY_V = File.open("./.ruby-version") { |f| f.read }.chomp
$apt_script = <<SCRIPT
sudo apt-get update
sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev libmysqlclient-dev
SCRIPT
@kjavier
kjavier / excitement_validator.rb
Created February 26, 2019 03:18 — forked from yesezra/excitement_validator.rb
Testing custom ActiveRecord validators with rspec and with_model
class ExcitementValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /.*!/
record.errors.add attribute, (options[:message] || "must end with an exclamation point")
end
end
end
@kjavier
kjavier / rspec_model_testing_template.rb
Created November 5, 2015 16:32 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@kjavier
kjavier / maven-333.sh
Created October 26, 2015 14:18 — forked from ervinb/maven-333.sh
Install Maven 3.3.3 on Ubuntu 14.04
#!/bin/sh
sudo apt-get purge -y maven
if ! [ -e .semaphore-cache/apache-maven-3.3.3-bin.tar.gz ]; then (cd .semaphore-cache; curl -OL http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz); fi
sudo tar -zxf .semaphore-cache/apache-maven-3.3.3-bin.tar.gz -C /usr/local/
sudo ln -s /usr/local/apache-maven-3.3.3/bin/mvn /usr/bin/mvn
echo "export M2_HOME=/usr/local/apache-maven-3.3.3" >> ~/.profile
. ~/.profile
echo "Maven is on version `mvn -v`"
@kjavier
kjavier / gist:a278155cb848e8fac891
Last active October 8, 2015 17:25 — forked from trcarden/gist:3295935
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key