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
server.get('/downloadPdf/:fileData', function (req, res) { | |
// config | |
var fileData = Buffer.from(req.params.fileData, 'base64'); | |
var menuData = JSON.parse(fileData.toString()); | |
var userName = menuData.userName; | |
var menuName = slug(menuData.menuName); | |
var fileName = userName + "-" + menuName + PDF_EXT; | |
var filePath = PDF_PATH + fileName; | |
// process headers |
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 nativeMax = Math.max; | |
const nativeMin = Math.min; | |
function debounce(func, wait, options) { | |
let lastArgs, | |
lastThis, | |
maxWait, | |
result, | |
timerId, | |
lastCallTime, | |
lastInvokeTime = 0, |
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
/** | |
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken | |
* It was requested to be introduced at as part of the jsonwebtoken library, | |
* since we feel it does not add too much value but it will add code to mantain | |
* we won't include it. | |
* | |
* I create this gist just to help those who want to auto-refresh JWTs. | |
*/ | |
const jwt = require('jsonwebtoken'); |
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 axios = require('axios'); | |
const http = require('http'); | |
const https = require('https'); | |
module.exports = axios.create({ | |
//60 sec timeout | |
timeout: 60000, | |
//keepAlive pools and reuses TCP connections, so it's faster | |
httpAgent: new http.Agent({ keepAlive: true }), |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<h2>Hello from outside the Shadow DOM!</h2> | |
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
// Copyright (c) 2017 Riikka Kalliomäki | |
// Licensed under MIT license: https://opensource.org/licenses/MIT | |
window.snake = {}; | |
(function (exports) { | |
"use strict"; | |
var queue; | |
var nearest; |
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 PrivateRoute ({component: Component, authenticated, ...rest}) { | |
return ( | |
<Route | |
{...rest} | |
render={(props) => authenticated === true | |
? <Component {...props} /> | |
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />} | |
/> | |
) | |
} |
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
axios({ | |
url: 'http://localhost:5000/static/example.pdf', | |
method: 'GET', | |
responseType: 'blob', // important | |
}).then((response) => { | |
const url = window.URL.createObjectURL(new Blob([response.data])); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', 'file.pdf'); | |
document.body.appendChild(link); |
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'; | |
import * as fs from 'fs'; | |
import * as restify from 'restify'; | |
import * as helmet from 'helmet'; | |
if (process.env.NODE_ENV === 'development') { | |
require('dotenv').config(); | |
} |
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
{ | |
"afghan": "Afghan", | |
"albanian": "Albanian", | |
"algerian": "Algerian", | |
"american": "American", | |
"andorran": "Andorran", | |
"angolan": "Angolan", | |
"antiguans": "Antiguans", | |
"argentinean": "Argentinean", | |
"armenian": "Armenian", |