This file contains hidden or 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
<style> | |
#log { | |
position: fixed; | |
z-index: 9999999999999999999999; | |
bottom: 5px; | |
right: 5px; | |
left: 5px; | |
padding: 10px; | |
box-shadow: 0 0 3px rgba(0, 0,0, .2); | |
background: #333; |
This file contains hidden or 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
const randomString = (length) => { | |
const letters = 'abcdefghijklmnopqrstuvwxyz'; | |
const numbers = '1234567890'; | |
const charset = `${letters}${letters.toUpperCase()}${numbers}`; | |
const randomCharacter = (character) => character[Math.floor(Math.random() * character.length)]; | |
let result = ''; | |
for (let i = 0; i < length; i++) { | |
result += randomCharacter(charset); |
This file contains hidden or 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 removeTone(str, isCaseSensitive = false) { | |
let formatted = isCaseSensitive ? str : str.toLowerCase(); | |
formatted = formatted.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a'); | |
formatted = formatted.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e'); | |
formatted = formatted.replace(/ì|í|ị|ỉ|ĩ/g, 'i'); | |
formatted = formatted.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o'); | |
formatted = formatted.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u'); | |
formatted = formatted.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y'); | |
formatted = formatted.replace(/đ/g, 'd'); |
This file contains hidden or 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 downloadFile(url, filename) { | |
fetch(url) | |
.then(resp => resp.blob()) | |
.then(blob => { | |
const url = window.URL.createObjectURL(blob); | |
const a = document.createElement('a'); | |
a.style.display = 'none'; | |
a.href = url; | |
a.download = filename; | |
This file contains hidden or 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
birthYear = formatter.getYear(profile.birthDate); currentYear = formatter.getYear(formatter.now); age = currentYear - birthYear; nextBirthDay = formatter.addYears(profile.birthDate, age); return nextBirthDay; |
This file contains hidden or 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
/** | |
* Generate password regex | |
* @method generatePasswordRegex | |
* @param {Number} min Minimum length of password | |
* @param {Number} max Maximum length of password | |
* @param {String} specialCharacter List of special characters | |
* @param {Number} specialLength Number of required special character in password | |
* @param {Number} uppercaseLength Number of required uppercase character in password | |
* @param {Number} numberLength Number of digit character in password * | |
*/ |
This file contains hidden or 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
$('#query').keydown2(function () { | |
console.log($(this).val()); | |
}); |
This file contains hidden or 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
/** | |
* Bob Math utilities | |
* @author: ducdhm | |
* @created: Tue, Feb 11th, 2014 (GTM+7) | |
*/ | |
(function(Math) { | |
/** | |
* Find the number of decimal places | |
* @method findDec | |
* @param {Float|Number} dec |
This file contains hidden or 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
var redirectTo = function (url) { | |
var anchor = document.createElement('a'); | |
anchor.href = url; | |
document.body.appendChild(anchor); | |
anchor.click(); | |
}; | |
redirectTo('http://coccoc.com'); |