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
const iso2FlagEmoji = iso => String.fromCodePoint(...[...iso.toUpperCase()].map(char => char.charCodeAt(0) + 127397)); | |
iso2FlagEmoji("US"); // "🇺🇸" |
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
/** | |
* @desc function to convert ms to time format hh:ii:ss.ms | |
* @param {Number} duration, time ini miliseconds | |
* @return {String} sample 00:01:01:99 | |
*/ | |
export function msToTime(duration = 0) { | |
let milliseconds = parseInt((duration % 1000) / 100), | |
seconds = Math.floor((duration / 1000) % 60), | |
minutes = Math.floor((duration / (1000 * 60)) % 60), | |
hours = Math.floor((duration / (1000 * 60 * 60)) % 24); |
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
.block-ellipsis { | |
display: block; | |
display: -webkit-box; | |
max-width: 100%; | |
height: 43px; | |
margin: 0 auto; | |
font-size: 14px; | |
line-height: 1; | |
-webkit-line-clamp: 3; | |
-webkit-box-orient: vertical; |
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
const now = new Date(now.getTime() - now.getTimezoneOffset() * 60000) |
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
<?php | |
//place this before any script you want to calculate time | |
$time_start = microtime(true); | |
// your script code goes here | |
// do something | |
Put this at the end of your php file: |
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
async function start() { | |
let x1 = await exe(1); | |
console.log("x1", x1); | |
let x2 = await exe(2); | |
console.log("x2", x2); | |
} | |
function exe(n) { | |
return new Promise((resolve, reject) => { | |
let response; |
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
export default function loadCSS(href: string, cb: Function | null) { | |
if(!isStyleLoaded(href)) { | |
const l: HTMLElement | null = document.createElement('link') | |
l.setAttribute('rel', 'stylesheet') | |
l.setAttribute('href', href) | |
if(cb) | |
l.onload = cb() | |
document.body.appendChild(l) | |
} | |
} |
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
export default function loadJS(src: string, args: any) { | |
if(!isScriptLoaded(src)) { | |
const s: HTMLElement | null = document.createElement('script') | |
s.setAttribute('src', src) | |
if(args.id) s.setAttribute('id', args.id) | |
if(args.cb) | |
s.onload = args.cb() | |
document.body.appendChild(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
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(N) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const bin = Math.abs(N).toString(2) | |
let maxGap = 0, currentGap = 0 | |
for(let n=0;n<bin.length;n++) { | |
if(bin[n]=="0"){ |
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
// Reload (or initialize) addThis social share buttons. | |
// IMPORTANT: make sure you put in a correct pubid on line 7. | |
window.addthis_reload = function () { | |
if (!window.addthis) { | |
// Load addThis, if it hasn't already been loaded. | |
window['addthis_config'] = { 'data_track_addressbar' : false }; | |
$('body').append('<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={YOUR PUBID HERE}"></script>'); | |
} else { | |
// Already loaded? Then re-attach it to the newly rendered set of social icons. | |
// And reset share url/title, so they don't carry-over from the previous page. |