Skip to content

Instantly share code, notes, and snippets.

View jricaldi's full-sized avatar
🏠
Working from home

Jorge Ricaldi jricaldi

🏠
Working from home
  • Lima, Peru
View GitHub Profile
// https://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/javascript
function sumIntervals(intervals){
intervals = intervals.sort(function(a, b) { // O(n)
return a[0] - b[0];
});
intervals = intervals.reduce(function(acc, el, index, array) { // O(n)
const anterior = array[index - 1];
if (array.length > 1 && anterior !== undefined) {
if (el[0] < acc[acc.length - 1]) {
const { performance } = require('perf_hooks');
const encontrarFrases = (target, matchings) => {
const hashTarget = target.toLowerCase().split('').reduce((acc, letter) => {
if (letter === ' ') {
return acc;
}
acc[letter] = (acc[letter] || 0) + 1;
return acc;
}, {});
@jricaldi
jricaldi / increase-memory.sh
Created June 21, 2017 16:43
Increases memory for FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p