Skip to content

Instantly share code, notes, and snippets.

View dangjlin's full-sized avatar

Daniel (Guo-Jheng) Lin dangjlin

View GitHub Profile
@dangjlin
dangjlin / postgresl_hints.sql
Created September 5, 2017 03:47 — forked from abhiomkar/postgresl_hints.sql
Postgresql snippets
-- show tables
\dt
-- create a new database
# CREATE DATABASE mydb;
-- create user
# CREATE USER abhinay with password 'secret';
#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
#!/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
module ActiveModel
module Validations
extend ActiveSupport::Concern
# ...
module ClassMethods
def validate(*args, &block)
# ...
module M2
extend ActiveSupport::Concern
included do
my_attr_reader :age
end
end
module M1
extend ActiveSupport::Concern
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
module ActiveSupport
module Concern
def append_features(base)
# ...
module M
def self.append_features(base); end
end
class C
include M
end
C.ancestors
# => [C, Object, Kernel, BasicObject]
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
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