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
-- show tables | |
\dt | |
-- create a new database | |
# CREATE DATABASE mydb; | |
-- create user | |
# CREATE USER abhinay with password 'secret'; |
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
#source ~/.bashrc | |
# please manually run source ~/.bashrc to load environmnet variables and path | |
#type rbenv | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
rbenv install 2.3.0 | |
rbenv global 2.3.0 | |
ruby -v |
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
#!/usr/bin/env bash | |
# usage: curl -L https://gist.githubusercontent.com/dangjlin/2dd09f80d114e54b54be89ce8b9c6336/raw/b5eb841f9989609c1c6d19c1b47cdca416435509/init_install.sh | sh | |
# Pre-requisites | |
sudo apt-get -y update | |
sudo timedatectl set-timezone Asia/Taipei | |
sudo apt-get --no-install-recommends -y install git-core zlib1g zlib1g-dev libxml2-dev libxslt-dev libc6-dev ncurses-dev automake libtool subversion pkg-config | |
#from digital ocean suggestion | |
sudo apt-get --no-install-recommends -y install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev |
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 ActiveModel | |
module Validations | |
extend ActiveSupport::Concern | |
# ... | |
module ClassMethods | |
def validate(*args, &block) | |
# ... |
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 M2 | |
extend ActiveSupport::Concern | |
included do | |
my_attr_reader :age | |
end | |
end | |
module M1 | |
extend ActiveSupport::Concern |
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 ActiveSupport | |
module Concern | |
def append_features(base) | |
if base.instance_variable_defined?(:@_dependencies) | |
base.instance_variable_get(:@_dependencies) << self | |
return false | |
else | |
return false if base < self | |
@_dependencies.each { |dep| base.send(:include, dep) } | |
super |
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 ActiveSupport | |
module Concern | |
def append_features(base) | |
# ... |
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 M | |
def self.append_features(base); end | |
end | |
class C | |
include M | |
end | |
C.ancestors | |
# => [C, Object, Kernel, BasicObject] |
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 ActiveSupport | |
module Concern | |
class MultipleIncludedBlocks < StandardError #:nodoc: | |
def initialize | |
super "Cannot define multiple 'included' blocks for a Concern" | |
end | |
end | |
def self.extended(base) base.instance_variable_set(:@_dependencies, []) | |
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
require 'active_support' | |
module MyConcern | |
extend ActiveSupport::Concern | |
def an_instance_method; "an instance method"; end | |
module ClassMethods | |
def a_class_method; "a class method"; end | |
end | |
end |
NewerOlder