Skip to content

Instantly share code, notes, and snippets.

@3200pro
3200pro / wait.js
Created July 26, 2022 21:11
Wait before executing
const wait = async (time) => new Promise((resolve) => setTimeout(resolve, milliseconds));
@3200pro
3200pro / check-object-empty.js
Created July 26, 2022 21:10
Check if the object is empty
const isEmpty = obj => Reflect.ownKeys(obj).length === 0 && obj.constructor === Object
@3200pro
3200pro / characters-in-string.js
Last active July 26, 2022 21:09
Get the number of characters in a string
const characterCount = (str, char) => str.split(char).length - 1
@3200pro
3200pro / mutate-data.sh
Created July 25, 2022 15:37
Mutate Data Sanity.io (Add Post)
// Test process of adding a post to the dataset
curl 'https://<PROJECT>.api.sanity.io/v2021-06-07/data/mutate/<DATASET>' \
-H "Authorization: Bearer <TOKEN>" \
-H 'Content-Type: application/json' \
--data-binary '{"mutations":[{ "create": {"_id": "postTestID","title": "Test Title","_type": "site.post"} }]}'
@3200pro
3200pro / deploy_wrangler.sh
Last active July 14, 2022 13:58
Deploy your project with Wrangler:
CF_ACCOUNT_ID=<YOUR_CLOUDFLARE_ACCT_ID> wrangler publish
"startString"(\n|.)*?"finishString"
@3200pro
3200pro / cURL.txt
Created May 17, 2022 12:58
Get All Megaphone.fm Podcast Episodes
curl -H "Authorization: Token {API_TOKEN}" https://cms.megaphone.fm/api/networks/{networkID}/podcasts/{podcastID}/episodes?
@3200pro
3200pro / style.css
Created March 21, 2022 12:07
Vimeo Video Styling
.embed-container {
--video--width: 1296;
--video--height: 540;
position: relative;
padding-bottom: calc(var(--video--height) / var(--video--width) * 100%); /* 41.66666667% */
overflow: hidden;
max-width: 100%;
background: black;
}
@3200pro
3200pro / deskBlog.js
Last active March 13, 2022 20:32
Sanity.io - Desk Structure Section (menu) Example
import React from 'react';
import S from '@sanity/desk-tool/structure-builder';
import sanityClient from 'part:@sanity/base/client';
import { IntentLink, Link } from 'part:@sanity/base/router';
import { Card, Stack, Text, Table } from '@sanity/ui';
import { Article, Browser } from 'phosphor-react';
import { standardViews } from '../previews/standard';
const i1 = Article;
@3200pro
3200pro / action.yml
Last active August 1, 2021 21:33
Refresh Gatsby CMS Preview For Sanity (Runs every 8 Hours)
name: 3200.PRO Refresh Gatsby Preview
on:
schedule:
- cron: "0 */8 * * *" # Visit https://crontab.guru/examples.html for cron scheduling examples
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: muinmomin/webhook-action@v1.0.0