This directory contains the pipeline for converting MobileCLIP2-S4 from PyTorch to Core ML for semantic search in Screenshot Manager.
cd embeddings
./setup.sh # Create venv and install deps| #!/bin/zsh | |
| # Instructions: | |
| # 1. Put this file in your user folder (~/git-editor) | |
| # 2. Enable execution by running `chmod +x ~/git-editor` | |
| # 3. Run `git config --global core.editor "~/git-editor" | |
| # 4. Now when you run a git command that launches your interactive editor, it'll use the current IDE | |
| # Function to get the process name by PID | |
| get_process_name() { |
| import React, { Suspense } from "react"; | |
| const componentMap = { | |
| sectionOne: React.lazy(() => import("./SectionOne")), | |
| sectionTwo: React.lazy(() => import("./SectionTwo")), | |
| }; | |
| const Section = ({ _type, ...sectionProps }) => { | |
| const SectionComponent = componentMap[_type]; |
| /** | |
| * This script injects JSDoc comments from the JS source files into the type | |
| * definition files. This is necessary because the type definition files | |
| * generated by TypeScript do not include JSDoc comments. | |
| * | |
| * @see https://github.com/microsoft/TypeScript/issues/14619 | |
| * | |
| * The strategy is a bit hacky, but straightforward: | |
| * | |
| * 1. Recursively walk the output folder looking for .d.ts files |
| const getImageData = async url => { | |
| const response = await global.fetch(url) | |
| const contentType = response.headers.get("Content-Type") | |
| return response.blob().then(imageData => ({ contentType, imageData })) | |
| } | |
| const uploadImage = ({ imageData, contentType }) => | |
| client.assets.upload("image", imageData, { contentType }) | |
| // usage example |
| // import and configure the client | |
| const oldRef = "abc123" | |
| const newRef = "def456" | |
| client | |
| .fetch( | |
| `*[references($oldRef)][0...250] { | |
| _id, | |
| _rev, |
To render the SVG, it's useful to have a wrapper component that allows passing in additional props:
import React from "react"
import { compiler } from "markdown-to-jsx"
const InlineSvg = ({ content, ...props }) =>
compiler(content, {
createElement: (type, elProps, children) =>
React.createElement(type, { ...elProps, ...props }, children),| import { useEffect } from "react" | |
| import config from "config:sanity" | |
| const BUNDLE_CHECK_INTERVAL = 60 * 1000 | |
| const CHANGES_AVAILABLE_MESSAGE = | |
| "There are changes to the Studio. For the best results the page will be refreshed to update to the latest version of the Studio." | |
| async function getCurrentHash() { | |
| const basePath = (config.project && config.project.basePath) || "/" | |
| const html = await window.fetch(basePath).then((res) => res.text()) |
| exports.onPostBuild = ({ graphql }) => | |
| graphql(` | |
| { | |
| redirects: allSanityRedirect { | |
| nodes { | |
| matchPath | |
| target | |
| statusCode | |
| } | |
| } |
| import { useState, useCallback, useEffect } from "react" | |
| /** | |
| * Similar to `useState` but with some lightweight behind-the-scenes | |
| * writing to localStorage; also subscribes to changes in localStorage | |
| * | |
| * @param {string} key The string key name to be written to localStorage | |
| * @param {object} options | |
| * @param {*} options.initialValue Initial value for setState | |
| * @param {boolean} options.bool Treat values as boolean types |