Skip to content

Instantly share code, notes, and snippets.

View davidsa's full-sized avatar

David Sttivend davidsa

  • Medellin, Colombia
View GitHub Profile
require('blanket');
var chai = require('chai'),
chaiHttp = require('chai-http');
var should = chai.should();
var server = require('../../server');
chai.use(chaiHttp);
describe('Product UT:', function() {
@davidsa
davidsa / isPrimeRecursive.js
Created June 26, 2018 22:45
first 0..100 Prime numbers recursively
function isPrimeNumberRecursive(n, next) {
if (n <= 1) {
return false
}
if (!next) {
next = n - 1
}
@davidsa
davidsa / recursiveDownload.js
Created September 13, 2018 17:18
Download an array of url images, and if it fail retry recursively
const request = require('request')
const data = require('./urls')
const fs = require('fs')
const urls = data.map(product => ({
url: product['PRODUCTIMAGEURL'],
name: product['PRODUCTSKU']
}))
function processImg(url, name) {
var table = [
[0, 0, 0, 0, 1],
[0, 0, 0, 1, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
]
function findBoat(boat, grid, i, j, direction) {
@davidsa
davidsa / closure.js
Created February 11, 2020 02:23
closure examples
function factory(i) {
return function() {
i++;
console.log(i);
};
}
const contadorDesde5 = factory(5); // 1
contadorDesde5();