Skip to content

Instantly share code, notes, and snippets.

View javilobo8's full-sized avatar

Javier Bermúdez Lobo javilobo8

View GitHub Profile
export default function createReducer(INITIAL_STATE, handlers) {
return function reducer(state = INITIAL_STATE, action) {
if (handlers[action.type]) {
return handlers[action.type](state, action);
}
return state;
};
}
FROM node:6
WORKDIR /tmp
COPY . .
# RUN npm install -g execSync
RUN mkdir -p /opt/care/app \
&& npm install --production
// npm i -S request request-promise cheerio lodash
const request = require('request-promise');
const cheerio = require('cheerio');
const fs = require('fs');
const _ = require('lodash');
const projectName = 'enaqx/awesome-react';
// const projectName = 'vuejs/awesome-vue';
const url = `https://raw.githubusercontent.com/${projectName}/master/README.md`;
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
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);
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
h2 {
text-align: center;