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
| openFile(name: string) { | |
| if (this.formData[name]) { | |
| const file = this.formData[name] as File | |
| if (file) { | |
| const { name: filename } = file | |
| saveAs(file, filename) | |
| } | |
| } | |
| } |
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
| openFile(name: string) { | |
| if (this.formData[name]) { | |
| const file = this.formData[name] as File | |
| const { name: filename } = file | |
| saveAs(file, filename); | |
| } | |
| } |
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 { saveAs } from 'file-saver' | |
| interface FileDownloadResponse<T> { | |
| body: T | null; | |
| contentDisposition: string; | |
| contentType: string; | |
| } | |
| private getFileNameFromContentDisposition(res: FileDownloadResponse<Blob>) { | |
| const { contentDisposition } = res; |
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
| // private getFileNameFromContentDisposition(res: FileDownloadResponse<Blob>) { | |
| // const { contentDisposition } = res; | |
| // const matches = /filename=([^;]+)/gi.exec(contentDisposition); | |
| // const tempFilename = ((matches && matches[1]) || 'untitled').trim(); | |
| // const filename = tempFilename.replace(/["]/g, ''); | |
| // return filename; | |
| // } | |
| // static openFile(response: FileDownloadResponse<Blob>) { | |
| // if (response && response.body) { |
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
| // private getFileNameFromContentDisposition(res: FileDownloadResponse<Blob>) { | |
| // const { contentDisposition } = res; | |
| // const matches = /filename=([^;]+)/gi.exec(contentDisposition); | |
| // const tempFilename = ((matches && matches[1]) || 'untitled').trim(); | |
| // const filename = tempFilename.replace(/["]/g, ''); | |
| // return filename; | |
| // } | |
| // static openFile(response: FileDownloadResponse<Blob>) { | |
| // if (response && response.body) { |
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
| // https://medium.com/@p3rf/solving-issue-with-entities-loading-for-a-nx-dev-monorepo-setup-with-nest-js-and-typeorm-282d4491f0bc | |
| // npm install --save-dev fast-glob | |
| // ... | |
| // "scripts": { | |
| // ... | |
| // "create-entities-index": "ts-node --pretty --project=tools/tsconfig.tools.json tools/create-entities-index.ts", | |
| // ... | |
| // } |
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
| // https://github.com/SheetJS/sheetjs/tree/6551dd0e051acac5031ffb728a16932bbf34c80a | |
| // npm install xlsx | |
| import * as XLSX from 'xlsx'; | |
| const { writeFile, utils } = XLSX; | |
| console.log('Create workbook'); | |
| const wb = utils.book_new(); |
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
| version: '3' | |
| services: | |
| postgres: | |
| image: postgres:alpine | |
| ports: ['5432:5432'] | |
| environment: | |
| POSTGRES_PASSWORD: postgres | |
| mailhog: | |
| image: mailhog/mailhog |
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 {CanDeactivate, Router} from '@angular/router'; | |
| import {Injectable} from '@angular/core'; | |
| import {Observable} from 'rxjs/Observable'; | |
| import {Observer} from 'rxjs/Observer'; | |
| import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; | |
| export interface CanComponentDeactivate { | |
| canDeactivate: () => Observable<boolean> | Promise<boolean> | boolean; | |
| } |
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
| crypto = require('crypto'); | |
| function buildMerkleRoot(targetHash, proof) { | |
| const bigEndianMerkleRoot = proof.reduce((merkleHash, p) => { | |
| if ('append' in p) { | |
| return Buffer.concat([merkleHash, Buffer.from(p.append, 'hex')]); | |
| } else if ('prepend' in p) { | |
| return Buffer.concat([Buffer.from(p.prepend, 'hex'), merkleHash]); | |
| } else if ('sha256' in p) { | |
| return crypto.createHash('sha256').update(merkleHash).digest(); |