Skip to content

Instantly share code, notes, and snippets.

Martin Adams heymartinadams

Block or report user

Report or block heymartinadams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View medium-article-selenium.js
(async () => {
const webdriver = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
const chromedriver = require('chromedriver')
// Run Selenium with Chrome on Node
chrome.setDefaultService(new chrome.ServiceBuilder(chromedriver.path).build())
let driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
View Get Webflow HTML, CSS, or JS.md

To export JavaScript, HTML, or CSS:

  1. Visit your Webflow site: https://webflow.com/design/yoursite

  2. Press shift + e to open the export window.

  3. Open the developer console (e.g. command + option + j in Chrome)

  4. Paste the following code into Webflow (yes, Webflow tells you not to paste code in there — the below snippets won’t grant anyone access to your Webflow account):

View keybase.md

Keybase proof

I hereby claim:

  • I am heymartinadams on github.
  • I am heymartinadams (https://keybase.io/heymartinadams) on keybase.
  • I have a public key ASBjZdqMBdjUJrTfeoVWmyy7IvQ2CqTFz8DnOw9jL1CX2go

To claim this, I am signing this object:

View medium-webflow-component.js
import React from 'react'
import Button from './Button'
export default class Signin extends React.Component {
setPage = (page) => {
// Custom nav function here
}
validation = () => {
View medium-webflow-button.js
// Button, stateless functional component
// Pass a special class from parent component (e.g. “capps-button flat”)
// to affect appearance. Otherwise, “capps-button primary” is the default.
import React from 'react'
export default ({ action, className, text }) => (
<div className={className ? className : 'app-button dark'} onTouchTap={action}>{text}</div>
)
View onToken.js
onToken(token) {
// This is where token is received, as described in Logic #1
const userId = this.props.data.user.id
const stripeToken = token.id
// Hide or remove button to prevent duplicate purchases
this.setState({ buttonStyle: 'button hidden' })
// Logic #2
this.props.createCard({ variables: { stripeToken, userId } })
.then(() => {
console.log('Customer created...')
View StripeComponent.js
import React from 'react'
import StripeCheckout from 'react-stripe-checkout'
import { graphql } from 'react-apollo'
import { userQuery, signinUser } from './graphql/user'
import { createCard, receiveStripeId, createPurchase, checkIfPaid, upgradeApp } from './graphql/purchase'
class Stripe extends React.Component {
constructor(props) {
super(props)
View componentDidUpdate-5-6.js
componentDidUpdate(newProps) {
if (this.props.data.user) {
const userId = this.props.data.user.id
if (!this.stripeTokenSubscription && !this.purchaseSubscription) {
// Logic #5: Create subscription to trigger response once user in User model has been successfully assigned a Stripe customer ID
this.stripeTokenSubscription = newProps.data.subscribeToMore({
document: receiveStripeId,
variables: { userId },
updateQuery: (previousState, { subscriptionData }) => {
console.log('Purchasing...')
View componentDidUpdate-9-10.js
componentDidUpdate(newProps) {
if (this.props.data.user) {
const userId = this.props.data.user.id
if (!this.stripeTokenSubscription && !this.purchaseSubscription) {
// Logic #5: Create subscription to trigger response once user in User model has been successfully assigned a Stripe customer ID
this.stripeTokenSubscription = newProps.data.subscribeToMore({
document: receiveStripeId,
variables: { userId },
updateQuery: (previousState, { subscriptionData }) => {
console.log('Purchasing...')
View MutationCallbackPurchase.js
{
createdNode{
id
amount
description
isPaid
purchaseToUser {
id
stripeId
}
You can’t perform that action at this time.