Skip to content

Instantly share code, notes, and snippets.

View pvrt's full-sized avatar

Pavel R pvrt

View GitHub Profile
@tobernguyen
tobernguyen / deploy_rails_app.md
Last active December 31, 2023 21:05
Ruby on Rails Deployment on DigitalOcean

Ruby on Rails Deployment on DigitalOcean

Prequisites

  • HTTP server nginx
  • Rails web server passenger
  • Database PosgreSQL
  • Deployment utility mina

Step 1 - Create your droplet

@breim
breim / deploy.sh
Last active February 15, 2018 12:34
Deploy rails 4 with postgresql
### ssh to root in terminal with your server ip
ssh root@123.123.123.123
### Create new user
adduser deploy
### Set new users privileges
visudo
### Find user privileges section
@nicolas-besnard
nicolas-besnard / elasticsearch.sh
Last active March 12, 2018 13:18
Nginx + Puma + Rails + Capistrano on Ubuntu 14.04
#!/usr/bin/env bash
install_elasticsearch() {
echo " * -- Elasticsaerch -- *"
echo " * Update"
sudo apt-get -qq -y update
echo " * Install JDK"
sudo apt-get -qq -y install openjdk-7-jre-headless
echo " * Download deb (V1.4.2)"
@scarfacedeb
scarfacedeb / 1.form.html.haml
Last active January 18, 2023 22:35
Form with multiple button in rails
/ Form excerpt
= f.button t(".save"), class: "btn"
= f.button t(".publish"), class: "btn", name: "publish"
= f.button t(".test"), class: "btn", name: "test"
@seancdavis
seancdavis / image.rb
Last active January 12, 2022 14:06
Rails has_many :through Polymorphic Association (http://goo.gl/lxmehk)
# app/models/image.rb
class Image < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
end
@dfurber
dfurber / a_turbolinks_spinner.md
Last active January 30, 2018 07:32
Add a loading indicator to turbolinks so the user knows when pages are loading.
@hopsoft
hopsoft / db.rake
Last active May 22, 2024 22:53
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@denji
denji / nginx-tuning.md
Last active June 9, 2024 20:33
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@madwork
madwork / attachment.rb
Last active July 25, 2021 09:13
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
@johndagostino
johndagostino / template.rb
Last active May 4, 2018 11:22
rails application template.rb
gem('mysql2')
gem('compass')
gem('zurb-foundation')
gem('puma')
gem('dalli')
gem('omniauth')
gem('omniauth-twitter')
gem('health_check')
gem('kaminari')
gem('newrelic_rpm')