Skip to content

Instantly share code, notes, and snippets.

View LarryKlugerDS's full-sized avatar

Larry Kluger LarryKlugerDS

View GitHub Profile
@LarryKlugerDS
LarryKlugerDS / openFile.js
Last active October 25, 2020 11:12
openFile handler
/**
* The file input element
*/
<input type="file" className="hidden"
multiple={false}
accept=".json,.csv,.txt,.text,application/json,text/csv,text/plain"
onChange={evt => this.openFile(evt)}
/>
/**
@LarryKlugerDS
LarryKlugerDS / file_download.js
Created October 18, 2020 18:40
File download with React.JS
// The React.JS code for the download method:
const blob = new Blob([output]); // Step 3
const fileDownloadUrl = URL.createObjectURL(blob); // Step 4
this.setState ({fileDownloadUrl: fileDownloadUrl}, // Step 5
() => {
this.dofileDownload.click(); // Step 6
URL.revokeObjectURL(fileDownloadUrl); // Step 7
this.setState({fileDownloadUrl: ""})
})
@LarryKlugerDS
LarryKlugerDS / apis.conf
Created May 11, 2016 08:35
Nginx node.js proxy with open cors
#
# The default apis server
# This file is in dirextory conf.d
server {
listen 82 default_server;
server_name _;
access_log /var/log/nginx/apis.log main;
# Load configuration files for the default server block.