What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-27 18:05:27
array chunk javascript
function splitArrayIntoChunksOfLen(arr, len) { var chunks = [], i = 0, n = arr.length; while (i < n) { chunks.push(arr.slice(i, i += len)); } return chunks; } var alphabet=['a','b','c','d','e','f']; var alphabetPairs=splitArrayIntoC... Add solution -
Other 2022-03-27 15:20:36
mongodb populate in same collection
async function lookup() { const times = []; for (let i = 0; i < 10; ++i) { let startTime = Date.now(); const orders = await Order.aggregate([ {$match: {completed: true}}, { $lookup: { from: 'users', localField: 'user', foreignField:... Add solution -
Javascript 2022-03-27 07:35:02
compress string javascript
function en(c){var x='charCodeAt',b,e={},f=c.split(""),d=[],a=f[0],g=256;for(b=1;b<f.length;b++)c=f[b],null!=e[a+c]?a+=c:(d.push(1<a.length?e[a]:a[x](0)),e[a+c]=g,g++,a=c);d.push(1<a.length?e[a]:a[x](0));for(b=0;b<d.length;b++)d[b]=S... Add solution -
Shell/Bash 2022-03-20 04:25:13
git push to all remotes
#To push all branches to all remotes: git remote | xargs -L1 git push --all #Or if you want to push a specific branch to all remotes: #Replace master with the branch you want to push. git remote | xargs -L1 -I R git push R master #(Bonus) To make a git ... Add solution -
Javascript 2022-03-19 17:25:26
sorting of categories and subcategories in js
function iterative(categories, parentCategory, level = 0) { return categories .filter((category) => parentCategory ? category.parent === parentCategory : !category.parent) .map(category => { category.level = level; return cat... Add solution
Best helpers
+10
+5
+5
+5
+5
+5
+5
+5
+5
+5