Navigation Menu

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 / 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);
@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 / 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 / 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
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
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
Created October 30, 2020 11:04
Generated by XState Viz: https://xstate.js.org/viz
const trafficLightMachine = Machine({
id: "trafficLight",
initial: "red",
on: {
NEXT: "green"
}
})
@dorelljames
dorelljames / webtask-io-scrollable.md
Created September 10, 2019 08:03
Make webtask.io "Explorer" sidebar scrollable

Objective

Fix the annoying Explorer sidebar of webtask.io and make it scrollable. 😊

How?

I use Google Chrome browser so I installed User CSS extension which basically allows one to add custom CSS to add a website.

Here's the custom css to add:

@dorelljames
dorelljames / README.md
Created August 22, 2019 08:58 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@dorelljames
dorelljames / App.js
Last active August 3, 2019 08:48
App.js
import React from "react";
import axios from "axios";
class App extends React.Component {
constructor() {
super();
this.state = {
todos: [],
isFetching: true
};