Skip to content

Instantly share code, notes, and snippets.

@Tuan-T-Nguyen
Tuan-T-Nguyen / gist:d2d27767daa14f1cd65f47c2bd14696b
Last active July 10, 2021 13:34
eslint prettier in reactjs
  1. npx eslint --init

Choose your options

  1. Install prettier
  • Install VSCode prettier extension
  • touch .prettierrc
  • Basic .prettierrc setting
@Tuan-T-Nguyen
Tuan-T-Nguyen / error_code_api.md
Last active November 21, 2020 03:23
error code api

Reference: https://www.twilio.com/docs/api/errors

Error Status code

400 Bad Request

Possible Causes

  • The resource to be modified has moved into a state that is no longer valid.
  • Input on the request did not pass validation.
@Tuan-T-Nguyen
Tuan-T-Nguyen / cleanbranch
Created July 23, 2019 01:34
Remove tracking branches no longer on remote
// Source: https://stackoverflow.com/a/33548037
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@Tuan-T-Nguyen
Tuan-T-Nguyen / sumConditions.sql
Created March 7, 2018 06:32
SUM() based on a different condition to the SELECT
SELECT m.member_id, m.teamname,
Sum(Case When r.track_Id = '$chosentrack'
Then total_points Else 0 End) TotalChosenTrackPoints,
Sum(Case When r.track_Id < '$chosentrack'
Then total_points Else 0 End) TotalLessThanChosenTrackPoints,
total_points as last_race_points
FROM members m
Join members_leagues l
On l.member_id = m.member_id
Join member_results r
@Tuan-T-Nguyen
Tuan-T-Nguyen / Rules Validator Yii.md
Last active October 11, 2017 05:26
Rules Validator Yii Examples

Yii 1.1

Validates that the attribute value is either trueValue or falseValue.

  1. trueValue, the value representing true status. Defaults to '1'
  2. falseValue, the value representing false status. Defaults to '0'
  3. strict, when this is true, the attribute value and type must both match those of {trueValue} or {falseValue}. Defaults to false, meaning only the value needs to be matched.
  4. allowEmpty, whether the attribute value can be null or empty. Defaults to true. Example:
array('name', 'boolean', 
@Tuan-T-Nguyen
Tuan-T-Nguyen / Install Composer using MAMP's PHP.md
Created January 14, 2017 15:16 — forked from irazasyed/Install Composer using MAMP's PHP.md
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php