Skip to content

Instantly share code, notes, and snippets.

View jtgrenz's full-sized avatar

Jon G jtgrenz

  • Gusto
  • Canada
  • 16:31 (UTC -04:00)
View GitHub Profile
@fabianeichinger
fabianeichinger / _htmx-ext-shopify.md
Last active April 14, 2024 13:17
htmx extension for Shopify Ajax API

htmx-ext-shopify gives you access to the Shopify Ajax API from HTML to progressively enhance your Liquid templates. It's an unofficial, experimental extension for htmx.

The extension manipulates API requests and responses in order to replace / update Liquid sections on the current page. The new HTML for sections comes from Bundled section rendering and inserted using htmx swapping and out of band swaps.

This behavior is controlled using existing and new (see below) hx-* attributes on the form triggering the request.

Current features

Update the customer's cart through the Shopify Ajax API and update the current page in response.

Installation

@searls
searls / searches_stuff.rb
Last active September 1, 2021 14:24
Whereable Query Pattern. A design pattern for combining numerous types of queries only if the query is relevant into a single query using ARel
# I heard Whereables were having a moment.
#
# More on the real version of this feature here:
# https://community.wanikani.com/t/kamesame-a-fast-feature-rich-japanese-memorization-webapp/31319/1575?u=searls
#
# Below is simplified but basic usage:
#
# SearchesStuff.new.call("arigatou") # finds ありがとう
# SearchesStuff.new.call("にほんご") # finds 日本語
# SearchesStuff.new.call("探して") # finds 探す
// This code is to be used with https://turbo.hotwire.dev. By default Turbo keeps visited pages in its cache
// so that when you visit one of those pages again, Turbo will fetch the copy from cache first and present that to the user, then
// it will fetch the updated page from the server and replace the preview. This makes for a much more responsive navigation
// between pages. We can improve this further with the code in this file. It enables automatic prefetching of a page when you
// hover with the mouse on a link or touch it on a mobile device. There is a delay between the mouseover event and the click
// event, so with this trick the page is already being fetched before the click happens, speeding up also the first
// view of a page not yet in cache. When the page has been prefetched it is then added to Turbo's cache so it's available for
// the next visit during the same session. Turbo's default behavior plus this trick make for much more responsive UIs (non SPA).
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 27, 2024 06:09
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@Rich-Harris
Rich-Harris / README.md
Last active September 24, 2023 20:08
first-class binding syntax

A modest proposal for a first-class destiny operator equivalent in Svelte components that's also valid JS.

Svelte 2 has a concept of computed properties, which are updated whenever their inputs change. They're powerful, if a little boilerplatey, but there's currently no place for them in Svelte 3.

This means that we have to use functions. Instead of this...

<!-- Svelte 2 -->
<h1>HELLO {NAME}!</h1>
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active May 17, 2024 09:06 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@natcl
natcl / ImportPhoto.scpt
Last active November 11, 2020 18:56
OSX Folder Action to automatically import files added to a folder in Photos.app
property imageFiles : {"jpg", "pef", "dng", "jpeg"}
on adding folder items to theWatchedFolder after receiving theDetectedItems
repeat with theItem in theDetectedItems
set theItemPath to POSIX path of theItem
set ImageFile to POSIX file theItemPath
tell application "System Events"
if name extension of theItem is in imageFiles then
tell application "Photos"
set DestinationAlbumName to "Inbox"
@exupero
exupero / README.md
Last active March 29, 2024 21:10
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. pfctl seems to work.)

@pmarreck
pmarreck / fake_time_machine.sh
Created September 23, 2011 16:29
Fake Time Machine, a way to duplicate the functionality of Apple's Time Machine using rsync, which also might make it cross-platform, but also lets you run it to any remote server
#!/usr/bin/env sh
# fake_time_machine.sh
# Fake Time Machine
# by Peter Marreck
# Based on ideas in http://blog.interlinked.org/tutorials/rsync_time_machine.html
# 9/2011
# E_BADARGS=85
# if [ -z "$1" ]