Skip to content

Instantly share code, notes, and snippets.

View mrtonyhuynh's full-sized avatar
😎
Harness Engineering

Tony Huỳnh mrtonyhuynh

😎
Harness Engineering
View GitHub Profile

Callback là gì

Hiểu đơn giản thì callback là một function (A) được truyền vào 1 function khác (B) thông qua các tham số của B. Lúc này function B sẽ gọi đến function A để thực hiện 1 chức năng gì đó hoặc là khi function B hoàn thành chức năng của mình.

Ví dụ đơn giản:

function dihoc(callback){
// Làm các công việc cần thiết khi đi học. Và cuối cùng kết quả nhận được là thu lại kiến thức.
callback('Kiến thức');
}
@mrtonyhuynh
mrtonyhuynh / lemp16.4.sh
Created January 7, 2019 14:05 — forked from Saleh7/lemp16.4.sh
Auto Install and Setup LEMP for Ubuntu 16.04 (PHP7, Nginx, MySql, PhpMyAdmin)
#!/bin/sh
# Auto Install and Setup LEMP #
#Example:sudo bash lemp16.4.sh -p MyPassword
# By Saleh7 - https://github.com/Saleh7
E=`tput setaf 1`
G=`tput setaf 2`
A=`tput setaf 3`
C=`tput setaf 6`
B=`tput bold`
@mrtonyhuynh
mrtonyhuynh / osx_install.sh
Created December 13, 2018 17:11 — forked from t-io/osx_install.sh
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@mrtonyhuynh
mrtonyhuynh / .htaccess
Created December 3, 2018 08:25
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@mrtonyhuynh
mrtonyhuynh / CountryCodes.json
Created September 19, 2018 08:54 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@mrtonyhuynh
mrtonyhuynh / gist:73e64ba8a5da690a66bdc759ef6b60e8
Created September 13, 2018 16:33
PHP: 'Time Ago' helper function. Useful for Twitter feeds
//helper function for 'x hours/minutes/seconds ago' - should be passed a time in php time format
function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
@mrtonyhuynh
mrtonyhuynh / utils.js
Created September 13, 2018 15:53 — forked from tborychowski/utils.js
JS :: Utils - helper library
/**
* https://gist.github.com/tborychowski/3799025
*/
var UTILS = {
/*jshint maxlen: 500, onevar: false */
isTouch : (/iPhone|iPod|iPad/ig).test(navigator.userAgent),
/**
* Modified & lintified version of https://gist.github.com/527683
@mrtonyhuynh
mrtonyhuynh / regex.txt
Created August 19, 2018 15:11 — forked from nerdsrescueme/regex.txt
Common Regex
Perl and PHP Regular Expressions
PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters.
All Major Credit Cards
This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa.
//All major credit cards regex
'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/'
@mrtonyhuynh
mrtonyhuynh / README.md
Created August 2, 2018 02:01 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.