Skip to content

Instantly share code, notes, and snippets.

const getVideoId = () => {
const id = window.location.pathname.split('/')[1]
if (isNaN(id)) {
console.warn('cannot find valid video ID')
return undefined
} else {
return parseInt(id)
}
}
@james-prado
james-prado / How to install a bookmarklet.md
Last active January 28, 2026 22:45
A bookmarklet that downloads vimeo thumbnails

Install the bookmarklet

  1. Create a new bookmark in your browser (right-click on the bookmarks bar and click "Add Page")
  2. Enter a name for the bookmark (e.g. "Get Vimeo Thumbnail")
  3. Copy the code block below, and paste it into the bookmark "URL"
javascript:void%20function(){const%20a=()=%3E{const%20a=window.location.pathname.split(%22/%22)[1];return%20isNaN(a)%3Fvoid%20console.warn(%22cannot%20find%20valid%20video%20ID%22):parseInt(a)},b=b=%3E{const%20c=a(),d=c%3F`thumbnail-${c}`:%22thumbnail%22;if(!b)return%20console.warn(%22thumbnail%20url%20is%20null%20or%20undefined%22);const%20e=document.createElement(%22a%22);e.id=d,e.href=b,e.target=%22_blank%22;const%20f=()=%3E{setTimeout(()=%3E{URL.revokeObjectURL(b),removeEventListener(%22click%22,f)},150)};return%20e.addEventListener(%22click%22,f,!1),e},c=(a,c)=%3E{const%20d=b(a);d.download=c,document.body.append(d),document.getElementById(d.id).click()},d=JSON.parse(document.getElementById(%22microdata%22).textContent).find(a=%3E%22VideoObject%22==a[%2
@james-prado
james-prado / hide-preview-bar-refresh.html
Created January 28, 2026 20:08
A bookmarklet that hides shopify preview bars using URL Search Params (this will also cause the page to refresh)
javascript: (() => { const url = new URL(window.location.href); const params = new URLSearchParams(url.search); const preview_bar = document.querySelector('#PBarNextFrameWrapper'); if (preview_bar) { params.set('pb', 0); } else { params.set('pb', 1); } window.location.href = %60${location.pathname}?${params}%60;})()
@james-prado
james-prado / hide-preview-bar.html
Created January 28, 2026 20:05
A bookmarklet that hides shopify preview bars
javascript: (() => { let style = document.querySelector("%23hide_preview_bar"); if (style) return style.remove(); style = document.createElement("style"); style.setAttribute("id", "hide_preview_bar"); document.head.appendChild(style); style.sheet.insertRule(%60%23PBarNextFrameWrapper{display:none;}%60);})()
@james-prado
james-prado / github-relative-time.html
Created January 28, 2026 20:04
A bookmarklet that converts github timestamps between relative and absolute values
javascript: (() => { let style = document.querySelector("#custom_github_time"); if (style) return style.remove(); style = document.createElement("style"); style.setAttribute("id", "custom_github_time"); document.head.appendChild(style); style.sheet.insertRule(%60:not([role=gridcell]) > relative-time {display: inline-flex; flex-direction: row;visibility: hidden;text-indent: -1000px;}%60); style.sheet.insertRule(%60:not([role=gridcell]) time-ago:after, :not([role=gridcell]) > relative-time:after {content: attr(title);display: block;visibility: visible;text-indent: 0;}%60);})()

Shopify CLI Alias

Here's how to turn long Shopify CLI commands like

shopify theme dev --nodelete --ignore 'templates/*.json' 'config/settings_data.json' 'locales/en.default.json' 'sections/*.json' --store "$STORE" --theme "$THEME_ID"

into a simple alias like serve that's scoped to your project.

@james-prado
james-prado / .envrc
Created May 24, 2025 01:08
Example .envrc file
#!/usr/bin/bash
# ——— Test Theme
export THEME_ID=123456789101
export STORE=store.myshopify.com
.gitignore_local
.envrc
.scripts/*
.zshrc
@james-prado
james-prado / pull.sh
Created May 24, 2025 00:11
Example Shopify CLI scripts
#!/usr/bin/bash
shopify theme pull --store "$STORE" --theme "$THEME_ID"
@james-prado
james-prado / deep_flatten.js
Last active September 5, 2018 14:07
Deep flatten an array
const input = [[1, 2, [3]], 4];
// ––––– Option 1 –––––
function baseFlatten(array, depth, result) {
result || (result = []);
if (array == null) {
return result;
}