Skip to content

Instantly share code, notes, and snippets.

View esshka's full-sized avatar
🏠
Working from home

Eugeny esshka

🏠
Working from home
View GitHub Profile
require 'digest'
# Get SHA256 Hash of a file
puts Digest::SHA256.hexdigest File.read "data.dat"
# Get MD5 Hash of a file
puts Digest::MD5.hexdigest File.read "data.dat"
# Get MD5 Hash of a string
puts Digest::SHA256.hexdigest "Hello World"
# Get SHA256 Hash of a string using update
sessions:
signed_in: 'Signed in successfully.'
signed_in_first_time: "MY CUSTOM WELCOME GREETING. DO NOT FORGET TO READ OUR GUIDELINE!"
signed_out: 'Signed out successfully.'
module Paperclip
class Watermark < Processor
# Handles watermarking of images that are uploaded.
attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options, :watermark_path, :watermark_offset, :overlay, :position
def initialize file, options = {}, attachment = nil
super
geometry = options[:geometry]
@file = file
@crop = geometry[-1,1] == '#'
class User
has_attached_file :photo,
processors: [:watermark],
styles: {
medium: {
geometry: "300x300>",
watermark_path: "#{Rails.root}/public/images/watermark.png",
auto_orient: false
},
thumb: "100x100>",
module Paperclip
class Annotation < Thumbnail
attr_accessor :annotation_text
def initialize(file, options = {}, attachment = nil)
super
@geometry = options[:geometry]
@annotation_text = options[:annotation_text]
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdminApproveReview
end
module RailsAdmin
module Config
module Actions
class ApproveReview < RailsAdmin::Config::Actions::Base
set :domain, ENV["domain"]
set :application, domain
set :user, ENV["user"]
set :destination, ENV["destination"] || domain
set :web_conf, ENV["web_conf"] || ENV["environment"] || 'production'
raise "please set domain=app.domain.name.com" unless domain
raise "please set user=server_username" unless user
set :port, ENV["port"] || 1234
set :repository, "."
# Login as root
ssh root@domain
# Create deploy user
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional
# Add user to sudo group
usermod -g <groupname> <username>
# Add .ssh/authorized_keys for deploy user

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.10 x32)

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

//= require jquery
//= require jquery_ujs
//= require_tree .
// ^ I am assuming that bootstrap3-dialog is in the tree
//GLOBAL JQuery Functaionality
$(function(){
/*** CONFIRM MODAL OVERRIDE ***/
//override the use of js alert on confirms