type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| ``` | |
| #!/bin/sh | |
| echo "\nRunning rubocop 🚓 💨 💨 💨\n" | |
| declare -a ERRORS=() | |
| for file in $(git diff --cached --name-only | grep -E '.rb') | |
| do | |
| ERRORS+=("$(rubocop $file | grep -e 'C:' -e 'E:')") | |
| done |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
| tables = [] # or ActiveRecord::Base.connection.tables | |
| collation = "utf8_unicode_ci" | |
| char_set = "utf8" | |
| db = "your_database_name" | |
| # write out | |
| puts "USE #{db};" | |
| puts "ALTER DATABASE #{db} CHARACTER SET #{char_set} COLLATE #{collation};" | |
| tables.each do |t| | |
| puts "ALTER TABLE #{t} CHARACTER SET #{char_set} COLLATE #{collation};" # changes for new records | |
| puts "ALTER TABLE #{t} CONVERT TO CHARACTER SET #{char_set} COLLATE #{collation};" # migrates old records |
| # 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 |
| #!/bin/sh | |
| # | |
| # nginx - this script starts and stops the nginx daemin | |
| # | |
| # chkconfig: - 85 15 | |
| # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ | |
| # proxy and IMAP/POP3 proxy server | |
| # processname: nginx | |
| # config: /usr/local/nginx/conf/nginx.conf | |
| # pidfile: /usr/local/nginx/logs/nginx.pid |
| # I have an array of dates (both past and present) and a single date ('needle' below), | |
| # for which I want to find the closest date in either direction. Here's my solution; | |
| # can you think of a better one? | |
| dates.sort_by { |date| (date.to_time - needle.to_time).abs }.first |
| class Hash | |
| def dig(*path) | |
| path.inject(self) do |location, key| | |
| location.is_a?(Hash) ? location[key] : nil | |
| end | |
| end | |
| end |
| # Ways to execute a shell script in Ruby | |
| # Example Script - Joseph Pecoraro | |
| cmd = "echo 'hi'" # Sample string that can be used | |
| # 1. Kernel#` - commonly called backticks - `cmd` | |
| # This is like many other languages, including bash, PHP, and Perl | |
| # Synchronous (blocking) | |
| # Returns the output of the shell command | |
| # Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |