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
| # chef.rb | |
| class Chef | |
| attr_reader :name, :restaurant | |
| def initialize(name, restaurant) | |
| @name = name # String instance | |
| @restaurant = restaurant # Restaurant instance | |
| end | |
| 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
| # car.rb | |
| # filename - lower_snake_case | |
| # class name - UpperCamelCase | |
| # sports_car.rb => SportsCar | |
| class Car | |
| attr_reader :brand | |
| # attr_writer :color |
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
| paris = { | |
| "country" => "France", | |
| "population" => 2211000 | |
| } | |
| students = { | |
| 2882 => { | |
| 'name' => 'Ricardo', | |
| 'age' => 27 | |
| } |
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
| def beautify_name(first_name, last_name) | |
| full_name = "#{first_name.capitalize} #{last_name.upcase}" | |
| yield(full_name) | |
| end | |
| message = beautify_name("john", "lennon") do |name| | |
| "Greetings #{name}, you look quite fine today!" | |
| end | |
| message = beautify_name("john", "lennon") do |name| |
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
| # Everything's ok | |
| 200 - OK | |
| # Redirects or cache | |
| 301 - Permanent redirect | |
| 302 - Temp redirect | |
| 304 - Not modified | |
| # Client error (you screw up) | |
| 401 - Unauthorized |
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
| # chef.rb | |
| class Chef | |
| attr_reader :name, :restaurant | |
| def initialize(name, restaurant) | |
| @name = name # String | |
| @restaurant = restaurant # Restaurant | |
| end | |
| 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
| # car.rb | |
| # filename - lower_snake_case | |
| # class name - UpperCamelCase | |
| class Car | |
| attr_reader :brand | |
| # attr_reader :brand | |
| # attr_writer :color | |
| # same as attr_writer + attr_reader | |
| attr_accessor :color |
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
| #!/usr/bin/env ruby | |
| ## | |
| # This file must be renamed to pre-commit without extension and | |
| # added to your .git/hooks directory | |
| # After that, run `chmod 755 pre-commit` to make it executable | |
| $user = ENV['USER'] | |
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
| upstream app { | |
| # Path to Unicorn SOCK file, as defined previously | |
| server unix:/servers/sites/backend-saas/shared/tmp/sockets/.unicorn.sock fail_timeout=0; | |
| } | |
| server { | |
| listen 80; | |
| server_name passworks.io; | |
| return 301 $scheme://www.passworks.io$request_uri; | |
| } |
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
| #!/bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Manage unicorn server | |
| # Description: Start, stop, restart unicorn server for a specific application. | |
| ### END INIT INFO |