Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
partyin

Jason Lengstorf jlengstorf

💭
partyin
View GitHub Profile
@jlengstorf
jlengstorf / claim-swag.sh
Created Oct 27, 2021
If you registered for Jamstack Conf 2021, you can run this command to claim swag
View claim-swag.sh
curl --location --request POST 'https://deploy-preview-1--jamstackconf2021-swag.netlify.app/api/claim-swag' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "YOUREMAIL@example.com"
}'
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'
}
},
}),