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
./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
@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

@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.

{
"customer": {
"id": 59,
"first_name": "North Customer",
"last_name": "TGM STAP2 Completed",
"email": "north_customer_tgm_stap2_completed@tgm.vn",
"gender": "male",
"birthdate": "1991-04-17",
"phone": "06546465",
"address": null
@viphat
viphat / Postgres Functions and View.sql
Created November 15, 2017 02:31
Postgres Function with Parameters
CREATE OR REPLACE FUNCTION vessels_arrival_departure_time(imos text[],
since timestamp without time zone default null,
port_locode text default null)
RETURNS TABLE(port_vessels_id int, imo varchar, mmsi varchar,
vessel_name varchar, voyage_number jsonb,
port_locode varchar, event_name varchar,
event_time timestamp without time zone
) AS $$
SELECT pv.id, v.imo, v.mmsi,
@viphat
viphat / table_partition.sql
Created November 17, 2017 10:26
Table Partitioning with Postgres
EXPLAIN ANALYZE
select count(*) from ais_trackings;
select * from ais_trackings LIMIT 1;
DELETE from ais_trackings WHERE last_ais_updated_at < '2017-11-15'
DROP TABLE ais_trackings_2017_11_16;
CREATE TABLE ais_trackings_2017_11_14 (
@viphat
viphat / x.sublime-settings
Last active May 18, 2018 13:16
Sublime Settings
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"caret_style": "solid",
"color_scheme": "Packages/Predawn/predawn.tmTheme",
"copy_with_empty_selection": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"find_selected_text": true,
"font_face": "Source Code Variable Regular",
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [74057c17-3a4b-4fff-940b-3e49c88d96a0] CartsController::edit_user:#<User::AttributesCollector:0x007fa659869488 @items=[#<CartItem::DomainRegister id: 345954, cart_id: 7788732, product_id: 1036, type: "CartItem::DomainRegister", key: "naturist-paris.com", duration: 1, discount: nil, properties: {"owner"=>"CD365364", "admin"=>"CD365364", "billing"=>"CD365364", "tech"=>"CD365364"}, created_at: "2019-05-18 10:55:00", updated_at: "2019-05-18 10:56:00">, #<CartItem::DomainRegister id: 345956, cart_id: 7788732, product_id: 1036, type: "CartItem::DomainRegister", key: "naturist-plantes.com", duration: 1, discount: nil, properties: {"owner"=>"CD365364", "admin"=>"CD365364", "billing"=>"CD365364", "tech"=>"CD365364"}, created_at: "2019-05-18 10:55:10", updated_at: "2019-05-18 10:56:00">], @users={}, @data_models={}>
...
...
...
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [e437b44d-c2c2-419c-8079-38331f94ad52] Started GET "/checkout/validate" for 90.79.105.133 at
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [891c2732-9701-4270-a96e-8c76715de78e] Processing by CartsController#show as HTML
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [1f1d7564-df12-4c1b-b48a-49a68c5d21c8] CartItem::Factory:find_item:345954
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [1f1d7564-df12-4c1b-b48a-49a68c5d21c8] Rules::DiscountRules:#<Product::DomainRegister id: 1036, type: "Product::DomainRegister", slug: "domain-register-com", name: "com", unit_price: #<BigDecimal:7f210e4023e8,'0.12E2',9(18)>, duration: "1,2,3,4,5,6,7,8,9,10", unit: 2, active: true, cost_price: #<BigDecimal:7f210e402140,'0.653E1',18(27)>, minimum_selling_price: #<BigDecimal:7f210e402050,'0.698E1',18(27)>, properties: {}, created_at: "2012-10-22 16:46:58", updated_at: "2012-10-22 16:46:58">
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [1f1d7564-df12-4c1b-b48a-49a68c5d21c8] CartItem::Factory:find_item:345956
[90.79.105.133] [b835e17645e393d5bc174ca464313608] [1f1d7564-df12-4c1b-b48a-49a68c5d21c8] Rules:
%simplicity_theme {
box-sizing: border-box;
background-color: #fff;
margin-bottom: 30px;
font-size: 16px;
line-height: 170%;
img {
max-width: 100%;
height: auto !important;