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
heymartinadams / ternary.js
Last active Nov 12, 2019
The following is (in my book) an elegant approach to avoid nested ternary operations. In response to this article:
View ternary.js
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,'
heymartinadams / medium-article-selenium-cron.js
Last active Oct 22, 2019
Cron job that checks if a Webflow site has been published, then exports its CSS code into your app.
View medium-article-selenium-cron.js
;(async () => {
// Secrets
// 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 /
Last active Oct 21, 2019
Git commit message rules

See here.


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


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


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

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()
View Get Webflow HTML, CSS, or

To export JavaScript, HTML, or CSS:

  1. Visit your Webflow site:

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


Keybase proof

I hereby claim:

  • I am heymartinadams on github.
  • I am 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 =
const stripeToken =
// 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) {
You can’t perform that action at this time.