Skip to content

Instantly share code, notes, and snippets.

View mattkelley's full-sized avatar

Matt mattkelley

  • Austin, TX
  • 19:18 (UTC -05:00)
View GitHub Profile
@mattkelley
mattkelley / response.json
Created June 18, 2019 19:46
Stripe preview invoice response
{
"object": "invoice",
"account_country": "US",
"account_name": "Spanning Cloud Apps, LLC",
"amount_due": 10825,
"amount_paid": 0,
"amount_remaining": 10825,
"application_fee": null,
"attempt_count": 0,
"attempted": false,
// report files failure action
{
payload: {
name: 'ApiError',
status: 404,
statusText: 'Not Found',
response: {},
message: '404 - Not Found'
},
type: 'REPORT_FILES_FAILURE',
@mattkelley
mattkelley / invalid-jwt-example.js
Last active September 19, 2017 19:59
Mock Admin Console API invalid JWT example
// Create a multi-part form
const data = new FormData()
// Set error type
data.append('error', 'expired')
// Fetch the invalid JWT
fetch(`${window.location.origin}/home/jwt`, { method: 'POST', body: data })
.then(body => body.json())
.then(jwt => console.log(jwt))
@mattkelley
mattkelley / valid-jwt-example.js
Last active September 19, 2017 19:59
Mock Admin Console API valid jwt example
// Create a multi-part form
const data = new FormData()
// Set number of seconds till JWT should expire
data.append('exp', '30')
// Fetch the JWT
fetch(`${window.location.origin}/home/jwt`, { method: 'POST', body: data })
.then(body => body.json())
.then(jwt => console.log(jwt))
@mattkelley
mattkelley / readme.md
Last active August 29, 2017 15:10
Frontend talk notes

Extending webpack dev server routes:

Problem: Needed a development ONLY page, hosted on same protocol/host/port for creating auth tokens. If we want to use webstorage, protocol/host/port much match, otherwise the token will not be availible, unlike cookie storage

Why use webStorage?

Simpler API, not need to require a 3rd party cookie parsing library. More importantly, webStorage exposes events for changes made to the store, offering better user experience than storing JWT in cookies

Reference: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#Responding_to_storage_changes_with_the_StorageEvent

class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = {isToggleOn: true};
// This binding is necessary to make `this` work in the callback
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
@mattkelley
mattkelley / example.js
Created February 9, 2017 16:05
overriding the default Event system in favor of a more performant, feature rich event emitter (eventemitter3)
import EventEmitter from 'eventemitter3'
import pdfjs from 'pdfjs-dist'
const el = document.getElementById('my-viewer')
// create instance of EventEmitter 3
const eventBus = new EventEmitter()
// create a document Viewer and pass our event emitter instance
// see: https://github.com/mozilla/pdfjs-dist/blob/master/web/pdf_viewer.js#L2593
@mattkelley
mattkelley / init.coffee
Last active November 16, 2016 20:10
atom settings sync
We couldn’t find that file to show.
@mattkelley
mattkelley / index.js
Last active August 17, 2016 15:52
Sail.js demo
// @NOTE this demo assumes price is a Sail.js instance
// var price = Sail({data});
// find pricing for all sitelock products
var sitelock = price.find.product('sitelock');
// set all sitelock products to be 100 dollars
price.set(100, sitelock.matches);
// or you can operate on the return value stored on sitelock
sitelock.price(100);
@mattkelley
mattkelley / pretty.js
Last active April 27, 2016 15:47
invodo.com affiliate config
var INVODO_AFF_CONFIG = {
"videoPlayerPreference": "HTML5",
"test": "false",
"rtmpBase": "rtmp://aoaef.invodo.com/",
"imageBase": "http://e.invodo.com/media/",
"httpBase": "http://e.invodo.com/media/",
"affiliate": "invodo.com",
"name": "",
"playbuttoncolor": "black",
"backcolor": "000000",