This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allow domains | |
var allowDomains = ["gmail.com", "hotmail.com", "outlook.com"]; | |
$.validator.addMethod('allowDomain', function(value, elem, param) { | |
var domain = value.split('@')[1]; | |
return allowDomains.indexOf(domain) >= 0; | |
}, 'Định dạng mail chập nhận: @gmail.com, @hotmail.com, @outlook.com'); | |
// validate form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EditorConfig is awesome: https://EditorConfig.org | |
# top-most EditorConfig file | |
root = true | |
# Unix-style newlines with a newline ending every file | |
[*] | |
end_of_line = lf | |
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Email template</title> | |
<style type="text/css"> | |
.wrapper_one { | |
font-size: 14px; | |
color: black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MONGO_DATABASE="your_database_name" | |
MONGO_HOST="127.0.0.1" | |
MONGO_PORT="your_mongo_port(default 27017)" | |
USERNAME="your_admin" | |
PASSWORD="your_password" | |
TIMESTAMP=`date +%F-%H%M%S` | |
BACKUP_NAME="$MONGO_DATABASE-$TIMESTAMP" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sync; echo 3 > /proc/sys/vm/drop_caches | |
## setup crontab */30 * * * * /usr/bin/bash /home/cronjob/cache-clear.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name main_domain.com www.main_domain.com; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl default_server; | |
# access_log off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vowelsAndConsonants(s) { | |
let vowels = ['a', 'e', 'i', 'o', 'u']; | |
let sLen = s.length; | |
for (let i = 0; i < sLen; i++) { | |
if (vowels.includes(s[i])) { | |
console.log(s[i]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timeConversion($s) { | |
return date("H:i:s", strtotime($s)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function birthdayCakeCandles($ar) { | |
$candles = array_count_values($ar); | |
ksort($candles); | |
$candleLast = array_key_last($candles); | |
$tallestCandels = $candles[$candleLast]; | |
return $tallestCandels; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function miniMaxSum($arr) { | |
$minArr = min($arr); | |
$maxArr = max($arr); | |
if ($minArr !== $maxArr) { | |
$miniSum = array_sum(array_diff($arr, [$maxArr])); | |
$maxSum = array_sum(array_diff($arr, [$minArr])); | |
} else { | |
// Case 13: 5 elements are the sames | |
unset($arr[0]); |