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
Invoice.prototype.getBarcode = function() { | |
const CUIT = this.tenant().cuit; | |
const baseCode = `${CUIT}\ | |
${(this.type + '').padStart(3, '0')}\ | |
${(this.salesPoint + '').padStart(5, '0')}\ | |
${this.cae}${moment(this.caeDueDate).format('YYYYMMDD')}`; | |
let oddSum = 0, | |
evenSum = 0; | |
baseCode.split('').forEach((digit, index) => { |
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
// 2017 version based on phantomjs, probably much easier nowadays with puppeteer | |
'use strict'; | |
const Promise = require('bluebird'); | |
const fs = require('fs'); | |
const readFile = Promise.promisify(fs.readFile); | |
const unlink = Promise.promisify(fs.unlink); | |
const phantom = require('phantom'); | |
const logger = require('logger'); |
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 getCuit(document_number, gender) { | |
/** | |
* Cuil format is: AB - document_number - C | |
* Author: Nahuel Sanchez, Woile | |
* | |
* @param {str} document_number -> string solo digitos | |
* @param {str} gender -> debe contener HOMBRE, MUJER o SOCIEDAD | |
* | |
* @return {str} | |
**/ |
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
FROM marianobe/node-base:latest | |
EXPOSE 3000 3001 3002 | |
RUN npm install -g --unsafe-perm @angular/cli pushstate-server | |
RUN mkdir -p /usr/src/app/client | |
WORKDIR /usr/src/app | |
# Loopback app | |
COPY package.json /usr/src/app |
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
/* Previously defined in customer-user.json: | |
"relations": { | |
"roles": { | |
"type": "hasMany", | |
"model": "Role", | |
"foreignKey": "principalId", | |
"through": "RoleMapping" | |
} | |
}, |
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
# Backups database $DATABASE running in container $CONTAINER | |
docker exec -u postgres $(docker ps | grep $CONTAINER | cut -f 1 -d " ") pg_dump -Fc $DATABASE > "$OUTPUTDIR/$DATABASE-$(date "+%u").pg |
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
/* | |
I usually insert this snippet right at the beginning of server.js | |
*/ | |
const path = require('path'); | |
const staticRoot = path.resolve(__dirname, '..', 'client-dist'); | |
app.all('/*', function(req, res, next) { | |
if (req.url.startsWith('/api')) { | |
return next(); | |
} |
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
import {Inject, Injectable, Optional} from '@angular/core'; | |
import {DateAdapter, MAT_DATE_LOCALE, MatDateFormats} from '@angular/material'; | |
import * as moment from 'moment'; | |
/** Creates an array and fills it with values. */ | |
function range<T>(length: number, valueFunction: (index: number) => T): T[] { | |
const valuesArray = Array(length); | |
for (let i = 0; i < length; i++) { | |
valuesArray[i] = valueFunction(i); | |
} |
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
<VirtualHost *:80> | |
# The ServerName directive sets the request scheme, hostname and port that | |
# the server uses to identify itself. This is used when creating | |
# redirection URLs. In the context of virtual hosts, the ServerName | |
# specifies what hostname must appear in the request's Host: header to | |
# match this virtual host. For the default virtual host (this file) this | |
# value is not decisive as it is used as a last resort host regardless. | |
# However, you must set it for any further virtual host explicitly. | |
#ServerName www.example.com |
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
/* I've chosen Javascript as it has become my main language nowadays. I tried | |
to avoid high level functions () and stick to just the basic stuff. | |
*/ | |
function flatten(object) { | |
return object.reduce((a, b) => { | |
if (Array.isArray(b)) { | |
return a.concat(flatten(b)); | |
} else { | |
return a.concat(b); | |
} |
NewerOlder