Skip to content

Instantly share code, notes, and snippets.

shin Tuan-T-Nguyen

Block or report user

Report or block Tuan-T-Nguyen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Tuan-T-Nguyen / box-shadow.html
Created Apr 21, 2018 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
View box-shadow.html
<!DOCTYPE html>
<title>Box Shadow</title>
.box {
height: 150px;
width: 300px;
margin: 20px;
View search-escape.js
function escapeRegExp(str) {
return str.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
regExSearch = '^' + escapeRegExp(filter) + '$';
table.column(2).search(regExSearch, true, false).draw();
Tuan-T-Nguyen / sumConditions.sql
Created Mar 7, 2018
SUM() based on a different condition to the SELECT
View sumConditions.sql
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 / FontAwesomeAsset.php
Created Mar 5, 2018
FontAwesomeAsset yii2 installed by bower install Font-Awesome
View FontAwesomeAsset.php
namespace app\assets;
use yii\web\AssetBundle;
class FontAwesomeAsset extends AssetBundle
public $sourcePath = '@bower/font-awesome/web-fonts-with-css';
public $css = [
Tuan-T-Nguyen / example.php
Created Jan 30, 2018
Fill zero, round up to specific digit decimal
View example.php
$number = '5.2';
$re = bcadd($number, 0, 2);
echo $re;
// 5.20
Tuan-T-Nguyen /
Created Nov 17, 2017
Add Sass to Reactjs
Tuan-T-Nguyen / example.php
Created Oct 19, 2017
Convert models to array in Yii 1.1
View example.php
public function convertModelsToArray(){
$criteria = new CDbCriteria();
$criteria->order = 't.display_order';
$companies = Company::model()->findAll($criteria);
/** Or using list data
$users = User::model()->findAll();
$usersArr = CHtml::listData( $users, 'id' , 'city');
$return array_map(create_function('$m', 'return $m->getAttributes();'), $companies);
Tuan-T-Nguyen / example.js
Created Oct 17, 2017
Get URL Parameters with JavaScript
View example.js
// From:
// Url example:
// Using:
// getAllUrlParams().product; // 'shirt'
// getAllUrlParams().color; // 'blue'
// getAllUrlParams().newuser; // true
// getAllUrlParams().nonexistent; // undefined
// getAllUrlParams('').a; // 'abc'
function getAllUrlParams(url) {
Tuan-T-Nguyen / User.php
Last active Oct 16, 2017
Sort click header of custom data column in Yii 1.1
View User.php
public function search()
$criteria=new CDbCriteria;
$criteria -> select = ("t.*, c.display_order AS companyOrder");
$criteria->join="LEFT JOIN company c ON t.companyId = ";
$sort = new CSort();
$sort->attributes = array(
Tuan-T-Nguyen / Rules Validator
Last active Oct 11, 2017
Rules Validator Yii Examples
View Rules Validator

Yii 1.1

boolean: CBooleanValidator

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', 
You can’t perform that action at this time.