Skip to content

Instantly share code, notes, and snippets.

View dorelljames's full-sized avatar
🚲
Drifting away...

Dorell James dorelljames

🚲
Drifting away...
View GitHub Profile
@dorelljames
dorelljames / machine.js
Created October 30, 2020 17:46
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: "electricFan",
type: "parallel",
states: {
power: {
id: "power",
initial: "turnedOff",
states: {
turnedOff: {
on: {
@dorelljames
dorelljames / machine.js
Last active September 29, 2021 16:49
Generated by XState Viz: https://xstate.js.org/viz
const allProducts = ["Auction! Desktop", "Auction! Cloud", "Auction! Online", "Auction! Mobile", "Auction! Reservations"];
const orderMachine = Machine({
id: 'order',
initial: 'idle',
context: {
cart: [],
loggedInuser: {
organizations: null,
profile: null
@dorelljames
dorelljames / machine.js
Last active August 26, 2022 05:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dorelljames
dorelljames / machine.js
Created August 26, 2022 10:23
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dorelljames
dorelljames / recover-schema.md
Created March 14, 2023 13:09 — forked from bjoerge/recover-schema.md
How to recover lost schema from *.sanity.studio.md

First, go to https://<yourname>.sanity.studio (or to the url of your studio if it's hosted elsewhere). Then open the developer console (usually by one of the keyboard shortcuts Command+Option+I, F12 or Control+Shift+I depending on what browser/platform you are using)

Steps

  1. Open the Sources tab
  2. Find the app.bundle.js file in the sidebar tree view.
  3. Hit the pretty print source button
  4. Locate your schema types by searching (e.g. try searching for one of your custom types) it in the source view.
@dorelljames
dorelljames / encryptForGitHub
Created February 28, 2024 05:45
Encrypt values for storing on GitHub Secrets
import sodium from "libsodium-wrappers";
// publicKey is from GET /repos/{owner}/{repo}/actions/secrets/public-key
// secretValue is the value you want to get encrypted
export async function encryptForGitHub(secretValue: string, publicKey: string) {
await sodium.ready;
// Convert the secret and key to a Uint8Array.
const binkey = sodium.from_base64(publicKey, sodium.base64_variants.ORIGINAL);
const binsec = sodium.from_string(secretValue);