Skip to content

Instantly share code, notes, and snippets.

Avatar
🌎
Another beautiful day on our beautiful planet ❤️

Martin Adams heymartinadams

🌎
Another beautiful day on our beautiful planet ❤️
View GitHub Profile
View main.yml
# 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]
View react-spread-operator.js
<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),
View react-input.js
<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'
View prisma-client-2.js
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)
}
}
View prisma-client-1.js
module.exports = async (parent, args, { prisma, ...ctx }, info) => {
try {
return await prisma.user.findMany()
} catch (error) {
throw new Error(error)
}
}
View query.graphql
{
users {
email
nameFirst
nameLast
}
}
@heymartinadams
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: https://medium.com/chrisburgin/rewriting-javascript-replacing-the-switch-statement-cfff707cf045
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
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
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 Oct 21, 2019
Git commit message rules
View git.md

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.

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