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 reversea = (cadena) => { | |
cadena = (cadena) ? cadena : ''; | |
return (cadena).split('').reverse().join(''); | |
}; | |
const countCaracteres = (cadena) => { | |
cadena = (cadena) ? cadena : ''; | |
let total = 0; | |
let char = ''; | |
const arr = cadena.split('').sort(); |
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
/** | |
* High order function | |
*/ | |
{ // using currying | |
const createScream = fn => message => fn(message.toUpperCase() + '!!!'); | |
const scream = createScream(message => console.log(message)); | |
scream('functions can be returned from other functions'); | |
} | |
{ // using currying |
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
// npm i -S dotenv uuid express cors bcryptjs jsonwebtoken body-parser | |
require('dotenv').config(); | |
const fs = require('fs'); | |
const http = require('http'); | |
const cors = require('cors'); | |
const uuidv4 = require('uuid/v4'); | |
const express = require('express'); | |
const bcrypt = require('bcryptjs'); | |
const jwt = require('jsonwebtoken'); | |
const bodyParser = require('body-parser'); |
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
#!/bin/bash | |
target_branch="master" | |
working_tree="/home/deploy/icdt-production" | |
git_tree="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then |
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 getTotalTime = seconds => { | |
let hh = Math.floor(parseInt(seconds) / 3600); | |
let mm = Math.floor((seconds - (hh * 3600)) / 60); | |
let ss = seconds - (hh * 3600) - (mm * 60); | |
if (hh < 10) { hh = `0${hh}`; } | |
if (mm < 10) { mm = `0${mm}`; } | |
if (ss < 10) { ss = `0${ss}`; } | |
return `${hh}:${mm}:${ss}`; |
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 memo = fn => { | |
const cache = {}; | |
return function () { | |
// arguments belongs to our returned anonymous function | |
// fn is the function we wish to apply this arguments | |
const key = JSON.stringify(arguments); | |
if (!!!cache[key]) cache[key] = fn.apply(null, arguments); | |
console.log({ cache }); |
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
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const Sequelize = require('sequelize'); | |
const basename = path.basename(__filename); | |
const env = process.env.NODE_ENV || 'development'; | |
const config = require(__dirname + '/../config/config.json')[env]; | |
let sequelize = new Sequelize( |
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 path = require('path'); | |
const fs = require('fs'); | |
const Jimp = require('jimp'); | |
const { v4: uuidv4 } = require('uuid'); | |
const imagesDirPath = path.join(__dirname, './images/'); | |
const writeFile = (dirPath, fileName, data, options) => { | |
if (!fs.existsSync(dirPath)) fs.mkdirSync(dirPath); | |
const joinedPath = path.join(dirPath, fileName); |