Skip to content

Instantly share code, notes, and snippets.

View viphat's full-sized avatar
🎯
Focusing

Duong Vi Phat viphat

🎯
Focusing
  • Osaka, Japan
View GitHub Profile
@viphat
viphat / pull-requests-template.md
Last active April 10, 2017 06:58
ufuture-pull-requests-template.md

Pull Requests Template

[STATUS (WIP/HOLD/READY)] - [TICKET_ID] - NAME OF PULL REQUEST

Related Issues

Link to JIRA’s User Story

What's this PR do?

Description - It might be same as user story, but sometimes, they might be different. For example: This PR is just a small part of User Story.

@viphat
viphat / the-art-of-readable-code.md
Last active September 7, 2022 05:03
The Art of Readable Code

The goal of this book is help you make your code better. And when we say "code", we literally mean the lines of code you are staring at in your editor. We’re not talking about the overall architecture of your project, or your choice of design patterns. Those are certainly important, but in our experience most of our day-to-day lives as programmers are spent on the “basic” stuff, like naming variables, writing loops, and attacking problems down at the function level. And a big part of this is reading and editing the code that’s already there.

KEY IDEA 1 - Code should be easy to understand.

KEY IDEA 2 - Code should be written to minimize the time it would take for someone else (may be you sixth months later) to understand it.

Is smaller always better?

The less code you write to solve a problem, the better. It probably takes less time to understand a 2000 line class than a 5000 line class

./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --without-http_empty_gif_module --without-http_rewrite_module --without-http_autoindex_module --without-http_ssi_module --without-http_scgi_module --with-http_realip_module --without-http_uwsgi_module --without-http_fastcgi_module --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
@viphat
viphat / cau_hinh_ssh_centos.md
Last active August 29, 2015 14:23
Cấu hình SSH xác thực bằng Public Keys trên CentOS 6

Cấu hình SSH chỉ đăng nhập bằng Public Keys trên CentOS 6

Bởi vì User Root có quyền tối cao trên hệ thống nên sẽ rất nguy hiểm nếu sử dụng thường xuyên tài khoản root, do đó, ta nên add thêm một User khác và đăng nhập SSH vào User này, thay cho root. Để an toàn hơn, chúng ta sẽ bỏ luôn việc đăng nhập SSH bằng mật khẩu mà chỉ cho đăng nhập bằng ssh public key của máy.

Bước 1 - Đăng nhập vào tài khoản root, Thêm một User mới

ssh root@ip_address
useradd viphat
@viphat
viphat / feedback.md
Last active August 29, 2015 14:22
Luồng xử lý của Feedback

Luồng xử lý của Hệ thống Feedback

  1. Feedback mới sẽ có status là Pending. (Trang Dashboard của AdminCP sẽ thể hiện total feedback đang pending, total comments đang pending để Admin truy cập vào Feedbacks ACP xử lý)
  2. Nếu thấy Feedback đó hữu ích (Not Spam, Not Duplicate) thì Admin sẽ Approved Feedback đó.
    1. Nếu Feedback bị Duplicated, Admin có thể Merge Feedback đó với một Feedback khác. (Feedback này sẽ được chuyển thành comment của Feedback kia)
    2. Admin có quyền Edit Feedback để lọc các emoticons, các từ viết tắt, ngôn ngữ teen, sửa lỗi chính tả, câu cú cho đơn giản, dễ hiểu. Vì cái này sẽ dùng làm Title của Feedback, và nó xuất hiện trên mặt tiền nên nếu không chỉnh sửa, biên tập sơ qua thì sẽ trông khá nhếch nhác. (Đang cân nhắc không biết có cần chức năng này không???)
    3. Tương tự, ta có thể approve cho từng comment trong Feedback (Comment không cần Edit)
    4. Những Feedback được approve mới được xuất hiện trên Giao diện Feedbacks để User có thể Vote hoặc comment thêm.
@viphat
viphat / git.sh
Last active August 29, 2015 14:21
Restore a whole directory
git checkout ae72740612bc -- vendor/assets/bower_components/moment/
# Allow some helpful debugging of localization issues.
# You can see translations in the UI by adding the following (or like it) to your CSS.
# .translation_missing { background-color: red; color: white !important; }
# .translation_fallback { background-color: green; color: white !important; }
#
# You will also need to have the following in your development group in your Gemfile:
# gem 'term-ansicolor'
#
# To turn this off, change this to false.
LOG_LOCALIZATION_ERRORS = true unless defined?(LOG_LOCALIZATION_ERRORS)
----- BEGIN LICENSE -----
MinBan
Single User License
EA7E-806395
318133A3 8F202A61 B0DBB8EB 21E17D2E
97D540E6 34079344 54620650 71E47589
9EF87857 345F5042 0D728DD1 8D8C979D
6A4F4DD2 67BB0345 746CA297 515BDA91
6CEAB381 4DB56700 D77DCD14 977BD326
1AC309ED 0EB414B8 4730DA10 99DBD291
@viphat
viphat / books.coffee
Last active February 6, 2017 06:05
Phân trang bằng AngularJS + Coffee
app = angular.module("myBookshelf", ["ngResource", "ui.router", "ui.bootstrap"])
app.config ['$httpProvider', ($httpProvider) ->
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')
$httpProvider.defaults.headers.common.Accept = 'application/json'
]
app.factory "Book", ($resource) ->
$resource("/books/:id", { id: "@id" }, {
update: { method: "PUT" }