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

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

<Input
{...{
autocomplete: 'off',
disabled: false,
autofocus: true,
inputRef: null,
name: 'myInput',
onBlur: x => console.log(x),
onChange: x => console.log(x),
onKeyDown: x => console.log(x),
# This is a basic workflow to help you get started with Actions
name: Reflect Regression Tests
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
@heymartinadams
heymartinadams / react-input.js
Last active October 31, 2020 17:59
Medium essay
<Input
autocomplete='off'
disabled={false}
autofocus={true}
inputRef={null}
name='myInput'
onBlur={x => console.log(x)}
onChange={x => console.log(x)}
onKeyDown={x => console.log(x)}
placeholder='Please enter a value'
const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
module.exports = async (parent, args, ctx, info) => {
try {
return await prisma.user.findMany()
} catch (error) {
throw new Error(error)
}
}
module.exports = async (parent, args, { prisma, ...ctx }, info) => {
try {
return await prisma.user.findMany()
} catch (error) {
throw new Error(error)
}
}
{
users {
email
nameFirst
nameLast
}
}
@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,'
@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 / 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.