Skip to content

Instantly share code, notes, and snippets.

@duyetpt
duyetpt / application_record.rb
Created August 3, 2020 07:50
Only validate state if state change value or will save change to db
def self.validates_if_change properity_name, options = {}
options = options.merge if: "will_save_change_to_#{properity_name.to_s}?".to_sym
validates properity_name, options
end
@duyetpt
duyetpt / gist:6997eab4bf225b43e4d756cb8d38fe5d
Created December 6, 2017 10:06 — forked from tommydunn/gist:6f885cc3efbd505e327a
Setting up Atom for Rails development
brew install caskroom/cask/brew-cask
brew cask install atom
apm install linter # Base linter
apm install linter-ruby
apm install linter-scss-lint
apm install linter-coffeelint
apm install linter-rubocop
apm install linter-haml
@duyetpt
duyetpt / Enhanced NGINX logstash parser
Created November 15, 2017 10:57 — forked from csamsel/Enhanced NGINX logstash parser
Enhanced NGINX logstash parser to include upstream response time and request length fields
Enhanced NGINX logstash parser:
NGINX log format:
log_format enhanced '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_length "$http_referer" "$http_user_agent" $request_time $upstream_response_time';
access_log /var/log/nginx/access.log enhanced;
error_log /var/log/nginx/error.log;
logstash pattern (/opt/logstash/pattern/nginx):
@duyetpt
duyetpt / multiple_ssh_setting.md
Created August 1, 2017 09:14 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@duyetpt
duyetpt / gist:a5a1b5adc93b086bac302eceeddf7d2e
Created February 17, 2017 22:44
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after