Skip to content

Instantly share code, notes, and snippets.

View bondgeek's full-sized avatar

Bart Mosley bondgeek

  • Stockbridge, MA
View GitHub Profile
# from
# https://quickchart.io/documentation/send-charts-in-email/#render-the-chart-image
# https://stackoverflow.com/questions/13137817/how-to-download-image-using-requests
#
# see also
# https://www.chartjs.org/docs/2.9.4/charts/doughnut.html
import shutil
import requests
const braintreeClientCreate = require('braintree-web/client').create;
const braintreeDataCollectorCreate = require('braintree-web/data-collector').create;
import {isEmpty, isNil} from 'ramda';
import application from "../common";
// REDUX action types______________________________________________
export const SET_PAYMENT_CLIENT = 'SET_PAYMENT_CLIENT';
@bondgeek
bondgeek / pdfPrint.js
Last active July 7, 2021 13:04
Alternate ways to print from blob or canvas
/*
starting reference: https://developer.mozilla.org/en-US/docs/Web/Guide/Printing
*/
function closePrint () {
document.body.removeChild(this.__container__);
}
function setPrint () {
setTimeout ( () => {
this.contentWindow.__container__ = this;
@bondgeek
bondgeek / showFile.js
Last active July 26, 2023 13:38
open pdf in pop-up from a blob
/* Use case: returning pdf as blob from XHR request,
for example when the endpoint is secure and needs an Authorization header
NB: responseType on fetch for blobData has to be "blob".
PDF files are not UTF-8, they are binary, so otherwise fonts won't appear properly
*/
const showFile = (blobData, reportName) => {
// Adapted from: https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/
const fileName = reportName && `${ reportName }.pdf` || 'myreport.pdf';