- Setup
- Swapfile
- NGINX
- ElasticSearch
- RVM
- Rails
- Postgres
- Capistrano
🏃♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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 ofTest::Unit
- In the Gemfile:
- Load/Reload waffle.
- Get most current list of actions for the project.
- 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.
- git checkout master
- git pull origin master
- Ensure you're starting on the master branch and have the most recent changes pulled down.
- run rspec
- Make sure there are no outstanding issues with code on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def to_boolean | |
ActiveRecord::Type::Boolean.new.cast(self) | |
end | |
end | |
class NilClass | |
def to_boolean | |
false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Encryptable | |
def encrypt(key) | |
crypt.encrypt_and_sign(key) | |
end | |
def decrypt(key) | |
crypt.decrypt_and_verify(key) | |
end | |
private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Encryptable | |
def encrypt(key) | |
crypt.encrypt_and_sign(key) | |
end | |
def decrypt(key) | |
crypt.decrypt_and_verify(key) | |
end | |
private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Box Shadow</title> | |
<style> | |
.box { | |
height: 150px; | |
width: 300px; | |
margin: 20px; |
NewerOlder