Skip to content

Instantly share code, notes, and snippets.

Avatar

Felipe Lima felipepastorelima

View GitHub Profile
@felipepastorelima
felipepastorelima / localhostFileStorage.ts
Created Jun 23, 2021
backend/src/services/file/localhostFileStorage.ts
View localhostFileStorage.ts
import path from 'path';
import fs from 'fs';
import os from 'os';
import jwt from 'jsonwebtoken';
import { getConfig } from '../../config';
import mv from 'mv';
import Error403 from '../../errors/Error403';
/**
* The directory where the files should be uploaded.
View NEW_orderRepository.js
const models = require('../models');
const SequelizeRepository = require('./sequelizeRepository');
const AuditLogRepository = require('./auditLogRepository');
const FileRepository = require('./fileRepository');
const lodash = require('lodash');
const SequelizeFilterUtils = require('../utils/sequelizeFilterUtils');
const Sequelize = models.Sequelize;
const Op = Sequelize.Op;
View .vscode_settings.json
{
"javascript.updateImportsOnFileMove.enabled": "always",
"javascript.preferences.importModuleSpecifier": "non-relative"
}
View jsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es2016",
"jsx": "preserve",
"checkJs": true,
"baseUrl": "./src"
},
"exclude": ["node_modules", "**/node_modules/*"]
}
View strategy-c.js
const seniorCandidatesRequirements = [
// ...
];
const candidates = [
// ...
];
function matchesEveryRequirement(candidates, requirements) {
if (!requirements) {
View strategy-b.js
const seniorCandidatesRequirements = [
{
matches(candidate) {
return Number(candidate.yearsOfExperience) >= 5;
}
},
{
matches(candidate) {
return candidate.languages && candidate.languages.includes('Javascript');
}
View strategy-a.js
function selectSeniorCandidates(candidates) {
return candidates.filter(candidate => {
// with at least 5 years of experience that knows Javascript
return (
candidate.yearsOfExperience >= 5 &&
candidate.languages.includes('Javascript')
);
});
}
View extract-method-c.js
function printPrimeNumbersFromZeroToHundred() {
const primeNumbersToPrint = primeNumbersBetween(0, 100);
console.log(primeNumbersToPrint);
}
function primeNumbersBetween(min, max) {
const result = [];
for (let i = min; i <= max; i++) {
if (isPrime(i)) {
View extract-method-b.js
function printPrimeNumbersFromZeroToHundred() {
const primeNumbers = [];
for (let i = 0; i <= 100; i++) {
if (isPrime(i)) {
primeNumbers.push(i);
}
}
console.log(primeNumbers);