Skip to content

Instantly share code, notes, and snippets.

View joshdavenport's full-sized avatar
🦉
Hooting and Howling

Josh Davenport-Smith joshdavenport

🦉
Hooting and Howling
View GitHub Profile
@joshdavenport
joshdavenport / oembed-zod.ts
Last active April 2, 2024 18:53
oEmbed format zod schema
const oembedSchema = z.discriminatedUnion('type', [
z.object({
type: z.literal('photo'),
url: z.string(),
width: z.number(),
height: z.number(),
}),
z.object({
type: z.literal('video'),
html: z.string(),
@joshdavenport
joshdavenport / tailwind-srcset-sizes.ts
Last active July 5, 2024 04:09
Generate srcset sizes attribute from tailwind screens
/*
The main method here is processTailwindSrcsetSizes. You can generate a sizes attribute using it based on
tailwind style breakpointed sizes referencing your screens, such as:
"100vw md:500px"
"200px lg:100vw"
"200px md:300px xl:600px"
"100vw lg:50vw"
"100vw"
"400px"
// Name: Tailwind Check
// Author: Josh Davenport-Smith
// Twitter: @joshdprts
import "@johnlindquist/kit";
const b = await npm("beautify");
const input = await arg({
name: "Enter Tailwind classes",
// Name: Pause Any Music
// Description: Pause music playing from music apps
// Author: Josh Davenport-Smith
// Twitter: @joshdprts
import "@johnlindquist/kit";
const pauseScript = `
tell application "Spotify"
pause
// Name: Preview CSS Color
// Description: Preview any CSS color accepted by background-color
// Author: Josh Davenport-Smith
// Twitter: @joshdprts
import "@johnlindquist/kit";
const color = await arg("Color");
await div(`
@joshdavenport
joshdavenport / package.json
Created October 19, 2022 17:12
ScriptKit package?
{
"name": "@joshdavenport/my-awesome-scriptkit-widget",
"version": "1.0.0",
"author": "Josh Davenport-Smith <josh@joshdavenport.co.uk>",
"dependencies": {
"some-package-my-widget-needs": "^1.0.0"
}
"scriptkit": {
"name": "My Awesome Widget",
"description": "This is my awesome widget! Check it out.",
// Name: Bandcamp Album Player
// Description: Stream a bandcamp album
// Author: Josh Davenport-Smith
// Twitter: @jdprts
import "@johnlindquist/kit";
import { WidgetAPI } from "@johnlindquist/kit/types/pro";
const jsdom = await npm('jsdom');
const INITIAL_PLAYER_WIDTH = 500;
<?php // -------- FOR METABOX FIELD TYPE `single_image` -------- ?>
<?php if($image = TGHPSite()->metabox->getSingleMetafieldValue('image')): ?>
<div class="intro__image">
<img src="<?= wp_get_attachment_image_url($image['ID'], 'original') ?>"
srcset="<?=
TGHPSite()->asset->getAttachmentSizesSrcset(
$image['ID'],
['xxs-uncropped','xs-uncropped','s-uncropped','m-uncropped','l-uncropped','xl-uncropped','xxl-uncropped','xxxl-uncropped','xxxxl-uncropped']
)
// Name: BBC Sounds Player
// Description: Stream a radio station from BBC Sounds
// Author: Josh Davenport-Smith
// Twitter: @jdprts
import "@johnlindquist/kit";
import { WidgetAPI } from "@johnlindquist/kit/types/pro";
const PLAYER_WIDTH = 180;
const PLAYER_HEIGHT = 195;
// Name: NTS Live
// Description: Stream NTS Live Channel 1 or 2
// Author: Vogelino, extended by Josh Davenport-Smith
// Twitter: @soyvogelino, @jdprts
import "@johnlindquist/kit";
const PLAYER_HEIGHT = 76;
const PLAYER_WIDTH = 205;