extend - додає методи до самого класу.
include - додає методи до екземпляру класу.
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 res params | |
| begin | |
| # do something | |
| Rails.logger.info "debug #{Time.now.to_datetime}" | |
| Rails.logger.info params | |
| rescue Exception => e | |
| Rails.logger.info "debug_Exception #{Time.now.to_datetime}" | |
| Rails.logger.info e.message | |
| 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
| gem 'rack-cors' |
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
| a = true | |
| b = false | |
| # if one of variable false run exception | |
| if !a or !b | |
| p 'ERROR 1' # + | |
| end | |
| unless a or b |
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
| pkill -o chrome && pkill -o chromium |
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
| # E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) | |
| # E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? | |
| sudo lsof /var/lib/dpkg/lock | |
| sudo kill -9 <PID> && sudo dpkg --configure -a |
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
| // Show log | |
| tail -f /var/log/mysqld.log |
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
| # WAY 1 | |
| url = 'https://www.example.com/post/hello-world' | |
| subdomain = 'blog' | |
| index = url.index('://www.') ? url.index('://www.') + 7 : url.index('://') + 3 | |
| url.insert(index, subdomain + '.') | |
| p url | |
| # WAY 2 | |
| url = 'https://www.example.com/post/hello-world' |
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
| 'my_name'.split('_').collect(&:capitalize).join | |
| # => "MyName" |
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
| <?php | |
| $obj = (object) ['a' => 'b']; | |
| echo $obj->a; |
OlderNewer