Skip to content

Instantly share code, notes, and snippets.

View VasylShevchenko's full-sized avatar
🏃‍♂️
Running

Vasyl Shevchenko VasylShevchenko

🏃‍♂️
Running
View GitHub Profile
@VasylShevchenko
VasylShevchenko / readme.md
Created April 1, 2021 07:43 — 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
require "get_process_mem"
def print_usage(description)
mb = GetProcessMem.new.mb
puts "#{ description } - MEMORY USAGE(MB): #{ mb.round }"
end
def print_usage_before_and_after
print_usage("Before")
yield
@VasylShevchenko
VasylShevchenko / rails_setup.md
Created March 13, 2020 21:29 — forked from ryanflach/rails_setup.md
Common setup for a new Rails project
  1. rails new <project_name> -d postgresql --skip-turbolinks --skip-spring -T
  • -d postgresql sets up the project to use PostgreSQL
  • --skip-turbolinks & --skip-spring creates a project that does not use turbolinks or spring
  • -T skips the creation of the test directory and use of Test::Unit
  1. In the Gemfile:
  • Available to all environments:
    • gem 'figaro' - store environment variables securely across your app (docs)
    • Uncomment gem 'bcrypt', '~> 3.1.7' if you will be hosting your own user accounts with passwords (docs)
  • Inside of group :test:
    • gem 'rspec-rails' - user rspec in place of minitest (docs)

Project workflow:

  1. Load/Reload waffle.
  • Get most current list of actions for the project.
  1. Choose a card from the backlog in waffle. If we're working separately, it's best to move that card that you've chosen into ready and perhaps assign it to yourself as well.
  • Make sure multiple team members aren't working on the same issue; ensure everyone knows what each other is working on.
  1. git checkout master
  2. git pull origin master
  • Ensure you're starting on the master branch and have the most recent changes pulled down.
  1. run rspec
  • Make sure there are no outstanding issues with code on master.
class String
def to_boolean
ActiveRecord::Type::Boolean.new.cast(self)
end
end
class NilClass
def to_boolean
false
end
// 1
deployer$ sudo visudo
// add
deployer$ ALL=NOPASSWD: /bin/systemctl restart nginx, /bin/systemctl status nginx
deployer$ ALL=NOPASSWD: /bin/systemctl restart dotnet.service, /bin/systemctl status dotnet.service
// 2
// add dotnet.service
deployer$ sudo vim /etc/systemd/system/dotnet.service
// insert file dotnet.service see below
https://medium.com/launch-school/number-validation-with-regex-ruby-393954e46797
def number?(obj)
obj = obj.to_s unless obj.is_a? String
/\A[+-]?\d+(\.[\d]+)?\z/.match(obj)
end
/\A[+-]?\d+(\.\d+)?\z/
/ start of the regex
module Encryptable
def encrypt(key)
crypt.encrypt_and_sign(key)
end
def decrypt(key)
crypt.decrypt_and_verify(key)
end
private
module Encryptable
def encrypt(key)
crypt.encrypt_and_sign(key)
end
def decrypt(key)
crypt.decrypt_and_verify(key)
end
private
@VasylShevchenko
VasylShevchenko / box-shadow.html
Created August 6, 2019 13:15 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;