Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Lengstorf jlengstorf

View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jlengstorf
jlengstorf / serverless-function-send-sms.js
Created Feb 19, 2021
An example of a serverless function that sends an SMS message using Twilio (deployable to Netlify Functions).
View serverless-function-send-sms.js
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
exports.handler = async () => {
const response = await client.messages.create({
// RIP Mitch Hedberg
body: 'Is a hippopotamus a hippopotamus... or a really cool opotamus?',
from: '+15552888588',
to: '+15558675309',
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
const formatCommand = msg => {
const { name, duration, message, audio, image } = msg.handler;
return {
command: name,
message,
audio,
image,
duration: duration * 1000, // convert seconds to milliseconds
View machine.js
const effectsMachine = Machine({
id: 'effects',
initial: 'idle',
context: {
transitionSpeed: 600,
duration: 4000,
},
states: {
idle: {
on: {
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
const checkAuth = () => false;
const getTwitchAuth = async () => ({id: 123, displayName: 'jlengstorf'});
const getNetlifyAuth = async () => 'auth';
const getCurrentConfig = () => 'config';
const getNetlifySites = () => ['site'];
const machine = Machine({
id: 'dashboard',
initial: 'checkingAuth',
context: {
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View bit.js
schema.buildInterfaceType({
name: "MyInterface",
fields: {
name: {
type: "String!",
resolve: () => 'data'
}
},
}),
@jlengstorf
jlengstorf / airtable-accessibility.diff
Created Jul 9, 2019
Markup changes to make Airtable form fields more accessible.
View airtable-accessibility.diff
<div class="sharedFormField required">
- <div class="title">Organizer's First Name</div>
+ <label for="input1" class="title">Organizer's First Name</div>
<div class="cellContainer">
<div class="cell formCell" data-columntype="text">
<div class="flex-auto flex baymax">
<input
+ id="input1"
type="text"
value=""