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
<div class="zoom-gallery"> | |
<div data-slide-id="zoom" class="zoom-gallery-slide active"> | |
<a href="https://magictoolbox.sirv.com/images/magiczoomplus/nike-01.jpg" class="MagicZoom" id="zoom-v"> | |
<img src="https://magictoolbox.sirv.com/images/magiczoomplus/nike-01.jpg?scale.width=400"/> | |
</a> | |
</div> | |
<div data-slide-id="video-1" class="zoom-gallery-slide video-slide"> | |
<iframe width="560" height="315" src="https://www.youtube.com/embed/J91IcJE6Clg" frameborder="0" allowfullscreen></iframe> | |
</div> | |
<div data-slide-id="video-2" class="zoom-gallery-slide video-slide"> |
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
// console.log([...permutate(['1', '2', '3'], 2)]) | |
// console.log([...permutate(['1', '2', '3'], 3)]) | |
function* permutate(items, count) { | |
yield* req([]) | |
function* req(array) { | |
if (array.length == count) { | |
yield array.join('') | |
return |
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 chunkString (str, len) { | |
const size = Math.ceil(str.length/len) | |
const r = Array(size) | |
let offset = 0 | |
for (let i = 0; i < size; i++) { | |
r[i] = str.substr(offset, len) | |
offset += len | |
} | |
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 loadjscssfile(filename, filetype){ | |
if (filetype=="js"){ //if filename is a external JavaScript file | |
var fileref=document.createElement('script') | |
fileref.setAttribute("type","text/javascript") | |
fileref.setAttribute("src", filename) | |
} | |
else if (filetype=="css"){ //if filename is an external CSS file | |
var fileref=document.createElement("link") | |
fileref.setAttribute("rel", "stylesheet") | |
fileref.setAttribute("type", "text/css") |
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 sortObj(obj) { | |
// Sort object as list based on values | |
return Object.keys(obj).map(k => ([k, obj[k]])).sort((a, b) => (b[1] - a[1])) | |
} | |
//source | |
//https://stackoverflow.com/questions/25500316/sort-a-dictionary-by-value-in-javascript | |
//https://stackoverflow.com/a/74250133/13861187 |
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 sortObjectByValues = (dict: { [key: string]: number }, direction: 'asc'| 'desc' = 'asc') => { | |
return Object.fromEntries(Object.entries(dict).sort((a, b) => { | |
if (direction === 'asc') { | |
return a[1] - b[1] | |
} | |
return b[1] - a[1] | |
})) | |
} | |
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 k = 5; | |
const dict = { | |
"x" : 1, | |
"y" : 6, | |
"z" : 9, | |
"a" : 5, | |
"b" : 7, | |
"c" : 11, | |
"d" : 17, | |
"t" : 3 |
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
let str = "atul kumar srivastava"; | |
let obj ={}; | |
for(let s of str)if(!obj[s])obj[s] = 1;else obj[s] = obj[s] + 1; | |
console.log(obj) | |
//source | |
// https://stackoverflow.com/questions/19480916/count-number-of-occurrences-for-each-char-in-a-string | |
// https://stackoverflow.com/a/60648545/13861187 |
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 countChar(str) { | |
let myObj= {}; | |
for (let s of str) { | |
if ( myObj[s] ? myObj[s].count ++ : myObj[s] = { count : 1 } ); | |
} | |
return myObj; | |
} | |
var charCount = countChar('abcceddd'); |
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 countChrOccurence ('hello') { | |
let charMap = new Map(); | |
const count = 0; | |
for (const key of str) { | |
charMap.set(key,count); // initialize every character with 0. this would make charMap to be 'h'=> 0, 'e' => 0, 'l' => 0, | |
} | |
for (const key of str) { | |
let count = charMap.get(key); | |
charMap.set(key, count + 1); |
NewerOlder