Skip to content

Instantly share code, notes, and snippets.

View dir's full-sized avatar
making it happen

Luke Davis dir

making it happen
View GitHub Profile
@dir
dir / get-project-root.mjs
Last active October 17, 2024 21:42
Helper function to locate the project root path in a Node.js app, with implementations for both ECMAScript Modules (ESM) and CommonJS (CJS).
// ECMAScript (ESM)
// @ts-check
import { existsSync } from "node:fs";
import { parse, resolve } from "node:path";
import { cwd, env } from "node:process";
/**
* Finds and returns the root directory of the project.
*
@dir
dir / convex.schema.json
Created December 15, 2024 22:44
Unofficial convex.json Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Configuration schema for Convex project settings.\n\nDocumentation: https://docs.convex.dev/production/project-configuration#convexjson",
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"project": {
"type": "string",
@dir
dir / download-video.sh
Created February 3, 2025 02:28
Video Downloader (yt-dlp) Raycast Script Command
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Download Video
# @raycast.mode compact
# @raycast.packageName Media
# @raycast.argument1 { "type": "text", "placeholder": "URL", "percentEncoded": false }
# @raycast.argument2 { "type": "dropdown", "placeholder": "Format", "data": [{ "title": "Auto", "value": "auto" }, { "title": "MP4", "value": "mp4" }, { "title": "WebM", "value": "webm" }, { "title": "MKV", "value": "mkv" }, { "title": "FLV", "value": "flv" }, { "title": "AVI", "value": "avi" }, { "title": "M4A", "value": "m4a" }], "optional": true }
# @raycast.argument3 { "type": "text", "placeholder": "Output Path", "optional": true }
@dir
dir / README.md
Last active February 14, 2025 03:35
Postman Package Library script to convert XML responses to JS/JSON objects

Usage

  1. Add the script to your Postman Package Library, call it whatever you'd like.
  2. Import it in any of your Postman scripts using pm.require("package-name")

Example

const { parse } = pm.require("xml"); // assuming package is named xml

const xmlResponseString = pm.response.text();
@dir
dir / zendesk-web-widget.d.ts
Last active March 11, 2025 18:12
Global TypeScript type definitions for the Zendesk Web Widget embed
/**
* Type definitions for the Zendesk Web Widget
*
* @see {@link https://developer.zendesk.com/api-reference/widget-messaging/introduction/#web-widget}
*/
/**
* Callback function for Zendesk Web Widget events
*/
type ZendeskCallback = () => void;
audio.allow_downgrade=false
audio.normalize_v2=false
audio.sync_bitrate_enumeration=4
audio.play_bitrate_enumeration=4
audio.play_bitrate_non_metered_migrated=true
audio.play_bitrate_non_metered_enumeration=4
@dir
dir / figma-agent-remove
Last active March 7, 2025 22:06
Bash script to remove Figma Agent login item & FigmaAgent.app(s) from your Mac
#!/usr/bin/env bash
#
# figma-agent-remove
# Removes Figma Agent from launchctl & deletes Figma Agent apps
# - This script may require sudo privileges.
# - You will likely have to re-run this script after every Figma update.
# - You will need to restart your system for changes to take effect.
# - After restarting, you may have to manually remove FigmaAgent from Login Items one last time.
FIGMA_AGENT_LAUNCHCTL_IDENTIFIER="application.com.figma.agent"
@dir
dir / spotify-player-app-schema.json
Last active May 27, 2025 17:56
JSON Schemas for spotify-player TOML configuration files
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spotify Player Configuration",
"description": "JSON schema for spotify-player app.toml configuration file",
"type": "object",
"properties": {
"client_id": {
"type": "string",
"description": "The Spotify client's ID",
"default": "65b708073fc0480ea92a077233ca87bd"
@dir
dir / init.sh
Last active June 17, 2025 02:33
NixOS Test
#!/bin/bash
echo "Hello world 12345"
@dir
dir / nanoid-3.3.11.min.cjs
Last active July 24, 2025 23:58
Postman Package Library
let t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",e=t=>crypto.getRandomValues(new Uint8Array(t)),r=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,l=-~(1.6*n*e/t.length);return(o=e)=>{let a="";for(;;){let e=r(l),g=0|l;for(;g--;)if(a+=t[e[g]&n]||"",a.length===o)return a}}},n=(t,n=21)=>r(t,n,e),l=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),"");module.exports={customAlphabet:n,customRandom:r,nanoid:l,random:e,urlAlphabet:t};module.exports.default=null;
//# sourceMappingURL=https://cdn.jsdelivr.net/sm/2bcc6c4870702ad675061bedae7ea2c4af9274577d2bce6e749ab8c564d06b45.map