Skip to content

Instantly share code, notes, and snippets.

View ekafyi's full-sized avatar

Eka ekafyi

View GitHub Profile

collection of mermaid.live charts

@ekafyi
ekafyi / Button.tsx
Last active May 30, 2023 18:56
Sample test assets Cypress + Vitest
// Button.tsx
"use client";
export interface ButtonProps {
/** Fooooo */
primary?: boolean;
/** Barrrr */
size?: "small" | "large";
/** Bazzzz */
@ekafyi
ekafyi / pwa-ws-01.md
Last active December 10, 2021 16:30
PWA workshop exercises solution

Exercise 1 — Solution

manifest.json

{
  "name": "Cat of the Day",
  "short_name": "CatOfTheDay",
  "description": "Sample web app for the PWA workshop",
 "icons": [
@ekafyi
ekafyi / machine.js
Last active June 25, 2021 18:03
Generated by XState Viz: https://xstate.js.org/viz
const fetchLocations = async () => {
// fake response
return new Promise(resolve => setTimeout(() => resolve(["foo", "bar", "baz"]), 1000));
// return fetch(`/api/notion/locations`).then((response) => response.json());
}
const updateLocations = (_c, evt) => {
const { query } = evt;
console.log(query); // { AGES: "18_TO_49" }
@ekafyi
ekafyi / machine.js
Last active June 24, 2021 17:43
Generated by XState Viz: https://xstate.js.org/viz
const fooMachine = Machine({
id: 'foo',
initial: 'loading',
// Local context for entire machine
context: {
retries: 0,
activeFilter: {},
},
@ekafyi
ekafyi / netlify-functions-spotify-api.js
Last active July 31, 2020 06:19
my attempt to adapt glitch.com/~spotify-web-api-node into Netlify functions
// truncated version of my attempt to adapt https://glitch.com/~spotify-web-api-node into Netlify functions
const SpotifyWebApi = require("spotify-web-api-node");
const TEST_ARTIST_ID = "1lYT0A0LV5DUfxr6doRP3d";
let accessToken;
const spotifyApi = new SpotifyWebApi({
clientId: process.env.SPOTIFY_CLIENT_ID,
@ekafyi
ekafyi / machine.js
Created July 21, 2020 18:56
Generated by XState Viz: https://xstate.js.org/viz
const tapStates = {
initial: 'tapOff',
states: {
tapOff: {
on: {
TAP_ON: 'tapOn'
}
},
tapOn: {
on: {
@ekafyi
ekafyi / machine.js
Created July 21, 2020 18:40
Generated by XState Viz: https://xstate.js.org/viz
const tapStates = {
initial: 'tapOff',
states: {
tapOff: {
on: {
TURN_ON: 'tapOn'
}
},
tapOn: {
on: {
@ekafyi
ekafyi / machine.js
Last active July 21, 2020 18:27
Generated by XState Viz: https://xstate.js.org/viz
const handWashMachine2b = Machine({
id: 'handwash',
initial: 'unwashed',
states: {
unwashed: {
on: {
START_WASH: 'washing'
}
},
@ekafyi
ekafyi / machine.js
Created July 21, 2020 17:22
Generated by XState Viz: https://xstate.js.org/viz
const handWashMachine2 = Machine({
id: 'handwash',
initial: 'unwashed',
states: {
unwashed: {
on: {
START_WASH: 'washing'
}
},
washing: {