../big-file-download
├── package.json
├── src
│ └── server.js
└── static
├── index.html
├── not-found.html
This file contains hidden or 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
| #ANDROID | |
| export ANDROID_HOME=$HOME/Library/Android/sdk | |
| export PATH=$PATH:$ANDROID_HOME/emulator | |
| export PATH=$PATH:$ANDROID_HOME/tools | |
| export PATH=$PATH:$ANDROID_HOME/tools/bin | |
| export PATH=$PATH:$ANDROID_HOME/platform-tools | |
| alias avd='$ANDROID_HOME/emulator/emulator' | |
| #FLUTTER | |
| export FLUTTER_PATH=$HOME/flutter/bin |
This file contains hidden or 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 { promisify } from 'util' | |
| import { pipeline } from 'stream' | |
| import { createGzip } from 'zlib' | |
| import { createReadStream, createWriteStream } from 'fs' | |
| console.time('processing time') | |
| promisify(pipeline)( | |
| createReadStream('./big-file.iso'), | |
| createGzip(), |
This file contains hidden or 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 "reflect-metadata"; | |
| import { createConnection } from "typeorm"; | |
| import * as express from "express"; | |
| import * as bodyParser from "body-parser"; | |
| import * as helmet from "helmet"; | |
| import * as cors from "cors"; | |
| //Connects to the Database -> then starts the express | |
| createConnection() | |
| .then(async connection => { |
This file contains hidden or 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 createTimer = () => { | |
| let paused = true | |
| let counter = 0 | |
| let interval | |
| return { | |
| play() { | |
| paused = false | |
| interval = setInterval(() => counter += 1, 1000) | |
| }, |
This file contains hidden or 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 get = (obj, prop, ...props) => { | |
| const val = obj[prop] | |
| if (!props.length || !val) return val | |
| return get(val, ...props) | |
| } | |
| const propertyPathToArray = (path = '') => | |
| path.replace(/\[/g, '.').replace(/\]/g, '').split('.') | |
| const prop = (path, obj) => |
This file contains hidden or 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 Joi = require('joi') | |
| // @see https://github.com/hapijs/joi/blob/v13.0.2/API.md#extendextension | |
| const customJoi = Joi.extend((joi) => ({ | |
| base: joi.number(), | |
| name: 'number', | |
| language: { stringify: 'parse number to string' }, | |
| pre(value, state, options) { | |
| if (this._flags.stringify) return value.toString() | |
| return value |
This file contains hidden or 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 { MongoClient } = require('mongodb') | |
| const Bluebird = require('bluebird') | |
| const DBURL = 'mongodb://localhost/demo' | |
| const COLNAME = 'demo' | |
| MongoClient.connect(DBURL, { promiseLibrary: Bluebird }) | |
| .tap(() => console.log('Connected!')) | |
| .then(async db => { | |
| const result = await db.collection(COLNAME).insert({ value: Math.random() }) |
This file contains hidden or 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' | |
| export class CustomError extends Error { | |
| constructor(message) { | |
| super(message) | |
| this.type = this.name = this.constructor.name | |
| Object.defineProperties(this, { | |
| type: { enumerable: true, writable: false }, |
This file contains hidden or 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 Joi = require('joi') | |
| class ValidationError extends Error { | |
| constructor(joiError) { | |
| super('Request validation error') | |
| this.details = joiError.details | |
| this.type = this.name = this.constructor.name | |
| Object.defineProperties(this, { | |
| type: { enumerable: true, writable: false }, | |
| name: { enumerable: false, writable: false }, |