Skip to content

Instantly share code, notes, and snippets.

View rainabba's full-sized avatar
🎧
Working from home

Michael Richardson rainabba

🎧
Working from home
  • Asurion
  • Manassas, VA
View GitHub Profile
@rainabba
rainabba / pdfToImageTest.js
Created February 8, 2019 16:58
Testing common solutions to PDF -> image conversion
// SPOILER: Only 1 of these tests passes at this point and it bypasses
// all the fluff and complication so it's the one I will end up using
const { expect } = require('code'),
Lab = require('lab'),
lab = exports.lab = Lab.script(),
fs = require("fs"),
path = require("path"),
mkdirp = require('mkdirp'),
rimraf = require('rimraf'),
@rainabba
rainabba / saveToDrive.js
Created December 30, 2015 21:37
VERY basic example of how to save content to Google Drive using node.js using googleapis
// This requires a google developers console project. That UI changes regularly and I found it hard to learn, but at the time I'm creating this, the steps are:
// - At the top-right, select or create a new project (can't give step-by-step details here)
// - Visit https://console.developers.google.com/apis/api/drive/overview
// - Enable API with your options (not sure they matter much, but API must be enabled)
// - Visit https://console.developers.google.com/permissions/serviceaccounts
// - Create a new service account if you don't already have one or don't have one you want to use for these API calls. Select the "Furnish new private key" option and the JSON format along with "Enable Google Apps Domain-wide Delegation".
// - Save provided JSON in a SECURE location (don't include in your source code and ensure it's ignored by GIT)
// You can generate new keys and/or revoke this one at https://console.developers.google.com/apis/credentials
@rainabba
rainabba / Promise-all.js
Created June 30, 2017 19:12
Promise.all() demonstration with iterations for refactoring
// Wait for ALL promises to return OR any to crash and then return the array of values to the caller of .all()
// // //Itteration 1
// // function runParallelPromisesSum() {
// // //Our function returns its own promise with our value that needed both the promises to return first
// // return new Promise( ( resolveAll, rejectAll ) => {
// // let promise1 = new Promise( ( resolvePromise1, rejectPromise1 ) => {
// // console.log("resolving 1");
// // resolvePromise1( 1 );
@rainabba
rainabba / drive-api-test
Last active May 9, 2018 19:34
google-api-nodejs-client examples using JWT and service account
const README = '\n\nThis script is intended to help you use a google API \
client_secret.json file to obtain an OAUTH token (json data) and \
store it next to the source .json for future use. \n\n\
To acomplish this, you will be given an URL that you can follow to \
get a "code" which can then be used to get a token. As an I/O solution \
I run this script with `node --inspect-brk` and then I catch the debugger \
after the URL is logged to the console. Once I have the code, I can run \
`code="{codeFromUrl}"` and resume the script. \n\n\n';
console.log( README );
@rainabba
rainabba / gist:ba2a56dbfc64498c8c033a2615a2afe8
Created April 18, 2017 07:47
Windows Explorer search for GSHEET and GDOC remnants
name:~"*.docx.URL" OR name:~"*.doc.URL" OR name:~"*.gdoc" OR name:~"*.gsheet" OR name:~"*xlsx.URL" OR name:~"*.xls.URL"
@rainabba
rainabba / testdeferredpromise.html
Last active September 23, 2015 19:18
Example and differences for A+ Promise using Resolve/Reject and a Bluebird promisify wrapper
<html>
<head>
<script src="https://www.promisejs.org/polyfills/promise-7.0.1.min.js"></script>
<script src="http://requirejs.org/docs/release/2.1.2/minified/require.js"></script>
</head>
<body>
<h1>Open the console</h1>
<script>
@rainabba
rainabba / gist:3f4fe16cc40bf98b2272
Created May 29, 2014 01:37
G+ Comments on any page
// Simplified version of what I found at http://dashburst.com/how-to-add-google-comments-to-any-webpage-or-blog-unofficially/
// This assumes jQuery support as $
<script src="https://apis.google.com/js/plusone.js"></script>
<div id="commentscounter"></div>
<div id="gpcomments"></div>
<script>
$(function() {
gapi.comments.render('gpcomments', { href: window.location, first_party_property: 'BLOGGER', view_type: 'FILTERED_POSTMOD' });
gapi.commentcount.render('commentscounter', { href: window.location });
@rainabba
rainabba / gist:9996443
Created April 5, 2014 19:06
WKHTMLTOPDF 1.12 using Google-Hosted .woff (Roboto)
<html>
<head>
<title>WKHTMLTOPDF Font Test</title>
<style>
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 100;
src: local('Roboto Thin'), local('Roboto-Thin'), url(http://themes.googleusercontent.com/static/fonts/roboto/v10/vzIUHo9z-oJ4WgkpPOtg1_esZW2xOQ-xsNqO47m55DA.woff) format('woff');
}