All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
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
#dwarf.rb | |
class Dwarf | |
include Comparable | |
def initialize(name, age, beard_strength) | |
@name = name | |
@age = age | |
@beard_strength = beard_strength | |
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
module RunStrategies | |
class RunStrategyInterface | |
def self.run(name) | |
raise "Run method has not been implemented!" | |
end | |
end | |
class Jog < RunStrategyInterface | |
def self.run(name) | |
puts "#{name} is now jogging at a comfortable pace." |
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
SELECT DATA_TYPE | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE | |
TABLE_NAME = 'yourTableName' | |
COLUMN_NAME = 'yourColumnName' |
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 DatabaseHelper | |
def self.select name, *args, &blk | |
execute "select", name, *args, &blk | |
end | |
def self.call name, *args, &blk | |
execute "call", name, *args, &blk | |
end | |
def self.execute via, name, *args, &blk |
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
## | |
# This files shows some possible implementations of the Singleton pattern | |
# in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice | |
# in some cases. In this file I'm going to implement a simple logger. | |
# | |
## | |
# The first implementation that can come to our minds is to create a class | |
# that holds an instance as a class variable that can be accessed through |
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
#With the macOS El capitan | |
#check git version | |
git --version | |
#Backup (or remove) Apple git (Optional) | |
sudo mv /usr/bin/git /usr/bin/git-apple | |
#Install Homebrew if you didn’t have | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
#Or update if you already have | |
brew update && brew upgrade | |
#Install Git with Homebrew |
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
EXEC sp_change_users_login 'Auto_Fix', 'user', NULL, 'pass' | |
-- constraints information | |
SELECT * FROM sys.objects | |
WHERE type_desc LIKE '%CONSTRAINT' | |
SELECT * | |
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS | |
where CONSTRAINT_NAME = 'constraint_name' |