This file contains 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
#!/bin/sh | |
# ngix + required packages | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install curl git-core nginx build-essential tcl8.5 -y | |
# mysql | |
# sudo apt-get install libmysqlclient-dev mysql-server |
This file contains 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
# Rotate logs | |
1) vim or nano /etc/logrotate.conf | |
2) Add these lines to the bottom of the file | |
/home/deploy/APPNAME/current/log/*.log { | |
daily | |
missingok | |
rotate 7 | |
compress | |
delaycompress | |
notifempty |
This file contains 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
# config/initializers/string.rb | |
class String | |
##---------------bg Color-----------------## | |
def black; "\e[30m#{self}\e[0m" end | |
def red; "\e[31m#{self}\e[0m" end | |
def green; "\e[32m#{self}\e[0m" end | |
def brown; "\e[33m#{self}\e[0m" end | |
def blue; "\e[34m#{self}\e[0m" end |
This file contains 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
def csv(data) | |
arr = Array.wrap(data) | |
CSV.open(csv_filename, 'wb') do |csv| | |
keys = arr.first.keys | |
# header_row | |
csv << keys | |
arr.each do |hash| | |
csv << hash.values_at(*keys) | |
end | |
end |
This file contains 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
# app/views/shared/_alerts.html.erb | |
<% flash.each do |key, value| %> | |
<div class="alert alert-<%= alert_style(key) %>"><%= value %></div> | |
<% end %> |
This file contains 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
# Encrypts and Decrypts block of data given an encryption key and an | |
# initialization vector (iv). Keys, iv's, and the data returned | |
# are all binary strings. Cipher algorithm should be array [256, CBC], | |
# or any of the cipher types supported by OpenSSL otherwise default will be used. | |
# Pass nil if the encryption type doesn't use iv's (like ECB) or ignore it if you using. | |
# USAGE: | |
# encrypt_to_hex_format( | |
# 'ThisPasswordIsReallyHardToGuess', 'initializervector', 'Hey! please encrypt me' | |
# ) |
This file contains 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 Attachable | |
extend ActiveSupport::Concern | |
included do | |
## -------------------- Associations -------------------- ## | |
if const_defined?('STORAGE_TYPES') | |
self::STORAGE_TYPES.each do |k, v| | |
v == :one ? has_one_attached(k.to_sym) : has_many_attached(k.to_sym) | |
end | |
end |
This file contains 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) cd ~ | |
2) mv .zsh_history .zsh_history_bad | |
3) strings .zsh_history_bad > .zsh_history | |
4) fc -R .zsh_history # reload history |
This file contains 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
# This document will help you setting up a Ruby on Rails development environment on Ubuntu and macOS. | |
# ---------------------------------------- Ubuntu ------------------------------------------------------ # | |
# To make sure we have everything necessary for Webpacker support in Rails, | |
# we're first going to start by adding the Node.js and Yarn repositories to our system before installing them. | |
- sudo apt-get update | |
- sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn | |
# Next we're going to be installing Ruby using one of RVM. |
This file contains 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
# Create a proxy server that forwards requests to thirdparty | |
# 1) Create a file in `/etc/nginx/sites-available` and name it any name | |
# 2) Copy the script replace `server_name` with your server domain and `proxy_pass` with third party domain. | |
server { | |
listen 80; | |
server_name YourDomain.com; | |
location / { | |
proxy_pass https://ThirdPartyDomain.com; | |
#proxy_ssl_certificate /etc/nginx/ssl; |
OlderNewer