Skip to content

Instantly share code, notes, and snippets.

View kieetnvt's full-sized avatar
👋

Kiet Nguyen kieetnvt

👋
View GitHub Profile
@kieetnvt
kieetnvt / nginx_on_mac.md
Last active June 7, 2019 06:44
NGINX on MAC and The WebP Support

NGINX on MAC

Location default HTML file

cd /usr/local/Cellar/nginx/1.15.11/html/

Location configure of NGINX

cd /usr/local/etc/nginx

@kieetnvt
kieetnvt / Crying with NGINX Regex, IF statement, and module http rewrite.md
Last active October 6, 2020 09:15
Crying with NGINX Regex matching, IF statement and module http rewrite $1 $2 meaning

If Statement and common condition

Syntax:	if (condition) { ... }
Default:	—
Context:	server, location

A condition may be any of the following:

@kieetnvt
kieetnvt / Crying with Rails Associations.md
Last active April 19, 2019 04:37
Crying with Rails Associations

Crying with Rails Associations

Belongs To:

class Post < ApplicationRecord
  belongs_to :user
end

create_table :photos do |t|
@kieetnvt
kieetnvt / install_ssl_namecheap.markdown
Created September 11, 2018 01:44
Install SSL Namecheap for NGINX server

Install SSL Namecheap for NGINX server

In case of Comodo certificates

  1. receive the zip archive with *.crt and *.ca-bundle files then extract it
  2. you will receive files:
    • youdomainname.crt
    • youdomainname.ca-bundle
  3. NGINX need all the certificates. You should combine theses 2 files. The *.crt should be list first, followed by (theo sau) the chain of CA certificates *.ca-bundle
  4. CMD combine: $ cat yourdomainname.crt yourdomainname.ca-bundle >> cert_chain.crt
@kieetnvt
kieetnvt / logrotate_on_linux.markdown
Last active March 5, 2021 07:35
Logrotate on Linux

My best practice configure logrotate.conf for Staging ENV: It will keep logs around 7 days

/home/deploy/apps/app_name/shared/log/*.log {
  daily
  rotate 7
  missingok
  compress
 delaycompress
@kieetnvt
kieetnvt / rails_admin_tricky.md
Created March 22, 2018 15:09
RailsAdmin Tricky

RailsAdmin Want to customize only one field and All fields are keep default for Model:

# in model.rb, customize one field is array postgres data type
# pg_int_array is a custom type
  rails_admin do
    edit do
      include_all_fields
      field :name_of_field_is_array_custom_type, :pg_int_array
    end
@kieetnvt
kieetnvt / ruby_magic_comment.md
Last active April 10, 2019 07:40
Ruby optimization with Magic Comment

Trong việc phát triển phần mềm, muốn optimization đơn giản là làm được việc này: Find the way to do less!

Ruby thì chậm có tiếng rồi, thủ phạm chính đó là garbage collector của ruby.

Chúng ta có thể optimization ruby bằng cách tạo ít rác rưởi khi chúng ta code ruby.

String trong ruby thì mutable (thay đổi), sinh ra nhiều object rác.

Ví dụ: string = ""; string << "test" nó đã tạo 2 object string là "", và "test". (rác)

.. sublime: wordWrap false
Keyboard Shortcuts - OSX
==================================
.. warning::
This topic is a draft and may contain wrong information.
Editing
-------
@kieetnvt
kieetnvt / linux_user_group.md
Created March 12, 2018 14:35
Linux user & group

Bài toán đặt ra.

Phía dịch vụ B cần gửi đến A một (hoặc nhiều) files thông qua sftp. Folder chứa các file này đã được xác định.

Cụ thể là Adyen (B) muốn send đến server (P) một số file, được chứa trong một folder có tên là "IN". Tại server này có set up 1 account của người chủ (will) có thể access và download file về.

  1. Create guest user for Adyen to cennect the server, create user without root home folder:

sudo adduser --no-create-home adyen_guest_user

@kieetnvt
kieetnvt / rubyist.md
Last active September 11, 2018 01:51
Lượm lặt từ Well grounded Rubyist

I. OJBECTS - METHOD CALL.

  1. dot operator and send method đều được dùng để gửi message đến 1 objec (yêu cầu object đó thực hiện message)
  2. 1 object cần quan tâm đến object_id, respond_to? và send
  3. nên kiểm tra respond_to?
if ticket.respond_to?(request)
  puts ticket.send(request) || ticket.request
else
  puts "no method request for ticket"
end