Skip to content

Instantly share code, notes, and snippets.

View heymartinadams's full-sized avatar
🌎
Another beautiful day on our beautiful planet ❤️

Martin Adams heymartinadams

🌎
Another beautiful day on our beautiful planet ❤️
View GitHub Profile
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)
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...')
// 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>
)
import React from 'react'
import Button from './Button'
export default class Signin extends React.Component {
setPage = (page) => {
// Custom nav function here
}
validation = () => {

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:

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):

(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())
@heymartinadams
heymartinadams / git.md
Last active October 21, 2019 19:47
Git commit message rules

See here.

Add

Create a capability e.g. feature, test, dependency.

Cut

Remove a capability e.g. feature, test, dependency.

Fix

Fix an issue e.g. bug, typo, accident, misstatement.

@heymartinadams
heymartinadams / medium-article-selenium-cron.js
Last active October 22, 2019 22:56
Cron job that checks if a Webflow site has been published, then exports its CSS code into your app.
;(async () => {
// Secrets
require('dotenv').config()
// Webflow
const Webflow = require('webflow-api')
// Chron job
const cron = require('node-cron')
// Selenium
const webdriver = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
@heymartinadams
heymartinadams / ternary.js
Last active November 12, 2019 22:43
The following is (in my book) an elegant approach to avoid nested ternary operations. In response to this article: https://medium.com/chrisburgin/rewriting-javascript-replacing-the-switch-statement-cfff707cf045
const name = 'Martin'
const customer = false
const human = true
// The object’s keys are irrelevant, since `Object.values` just spits out the object properties into an array.
const ternaryOps = Object.values({
1: name === 'Joe' ? 'Hi Joe!' : null,
2: customer ? 'Dear customer,' : null,
3: human ? `Hey ${name}!` : null,
default: 'To Whom It May Concern,'