Skip to content

Instantly share code, notes, and snippets.

@tsipiniuk
tsipiniuk / 1-Nginx-Unicorn-Rails-DO-Ubuntu-16.md
Created June 22, 2020 17:18 — forked from aquaflamingo/1-Nginx-Unicorn-Rails-DO-Ubuntu-16.md
Ubuntu 16.04 Unicorn+Nginx, PostgreSQL, active_storage, Amazon S3 on Digital Ocean

🚂 Deploy Ubuntu 16.04 Rails Server on Digital Ocean

using Unicorn, Nginx, PostgreSQL, active_storage, Amazon S3. Combined summary of all guides.

💧 1. Basic Droplet/SSH Set Up

Create Droplet: Ubuntu 16.04

Your root password is e-mailed to you.

@tsipiniuk
tsipiniuk / nginx_pagination_fix.conf
Created September 8, 2018 10:38 — forked from chris/nginx_pagination_fix.conf
Nginx rewrite rule to change ?page pagination URL's to /p style
if ($request_uri ~* ^(.+)\?page=1$) {
set $dom_prefix $1;
set $args '';
rewrite ^(.*)$ $scheme://$host$dom_prefix permanent;
break;
}
if ($request_uri ~* ^(.+)\?page=(\d+)$) {
set $dom_prefix $1;
set $page $2;
set $args '';
@tsipiniuk
tsipiniuk / 1. ELK.install
Created August 8, 2018 08:18 — forked from PavloBezpalov/1. ELK.install
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
INSTALL JAVA
$ sudo apt-get update && sudo apt-get install default-jre
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch
$ sudo update-rc.d elasticsearch defaults 95 10
$ sudo service elasticsearch restart
$ sudo service elasticsearch status
@tsipiniuk
tsipiniuk / attachment.rb
Created May 15, 2018 11:56 — forked from madwork/attachment.rb
Polymorphic attachments with CarrierWave and nested_attributes
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
@tsipiniuk
tsipiniuk / readme.md
Created April 4, 2018 22:18 — forked from yosukehasumi/readme.md
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano
@tsipiniuk
tsipiniuk / controller.rb
Created October 3, 2015 07:39 — forked from joakimk/controller.rb
A way to lazy load partials in Rails 3
class Controller
include LazyLoad
def show
@model = Model.find(...)
respond_to do |format|
format.html do
@html_specific_data = Model.find(...)
end
@tsipiniuk
tsipiniuk / confirm.js
Last active August 29, 2015 14:21 — forked from askehansen/confirm.js
$.rails.allowAction = function(element) {
var message = element.data('confirm');
if (!message) {
return true;
}
bootbox.confirm(message, function(result) {
if (result) {
$.rails.handleMethod(element);
}