Skip to content

Instantly share code, notes, and snippets.

@hypervillain
hypervillain / LinkifyDraftailEditor.jsx
Last active October 5, 2018 16:27
Linkify DraftTail Editor using decorators
// If you're using https://github.com/lokiuz/redraft,
// reuse these methods in your renderers module.
const urlRegex = (/((?:https?(?::\/\/))(?:www\.)?(?:[a-zA-Z\d-_.]+(?:\.[a-zA-Z\d]{2,})|localhost)(?:(?:[-a-zA-Z\d:%_+.~#!?&//=@]*)(?:[,](?![\s]))*)*)/g);
function findWithRegex(regex, contentBlock, callback) {
const text = contentBlock.getText();
let matchArr;
let start;
matchArr = regex.exec(text);
@hypervillain
hypervillain / batchUploadcareUrls.js
Created June 13, 2018 13:57
Call Uploadcare with cross-fetch, failing on GCF
// line 41: public & private are your Uploadcare API keys
/*
Call is nodeJS script (pass) :
async function main() {
const res = await pushBatchUrlsToUploadCare(['123']);
console.log(res); // { err: { '123': 'Invalid' } }
}
@hypervillain
hypervillain / addSubscriberToRevue.js
Last active October 5, 2018 16:28
Add Subscriber to Revue (https://getrevue.co) using Serverless (AWS Lambda)
'use strict';
/*
Before creating your service,
add your API key to serverless.yml file
For example, a valid conf:
service:
name: revue
provider: