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 / tailwind-srcset-sizes.ts
Last active February 22, 2024 23:55
Generate srcset sizes attribute from tailwind screens
View tailwind-srcset-sizes.ts
/*
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"
View tailwind-check.ts
// 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",
View pause-any-music.ts
// 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
View preview-css-color.ts
// 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?
View package.json
{
"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.",
View bandcamp-album-player.ts
// 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;
View TGHPSrcsetExamples.php
<?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']
)
View bbc-sounds.ts
// 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;
View nts-live.js
// 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;
View bbc-sounds.ts
// 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;