Add this file to your AI assistant's system prompt or context to help it avoid common AI writing patterns. Source: tropes.fyi by ossama.is
| /** | |
| * Gemini generated object to original schema compatible object converter | |
| * | |
| * Utility to convert Gemini generated objects back to their original schema format. | |
| * Pairs with gemini.schema-converter.ts | |
| */ | |
| import { z } from "zod"; | |
| function findDiscriminatorKey(schema: z.ZodTypeAny): string | null { | |
| if (schema instanceof z.ZodUnion) { |
| /* | |
| Allows you to hijack the new Customer Accounts login flow and redirect to a custom page after login. | |
| 10SQ - 2024 | |
| 10sq.dev | |
| */ | |
| const SHOP_ID = "<YOUR-SHOP-ID>"; | |
| const CLIENT_ID = "<YOUR-CLIENT-ID>"; // Install https://apps.shopify.com/headless |
a thread where we can discuss some crazy routing ideas a bit out in the open branching out from the previous discussion on filesystem routes over at: https://discord.com/channels/815937377888632913/1014946079965454366
so, first of all, it seems there is a close alignment between how vite-plugin-ssr and router5 handles routing:
- vps: (
view === 'overview') @ https://vite-plugin-ssr.com/layouts#nested-layouts - router5 (
route === 'dashboard') @ https://youtu.be/hblXdstrAg0?t=197 maybe with the small exception that router5 has the explicit perspective of routes as app state whereas I didn't get the impression from vps that it's viewed as such (even though it technically is still state).
I recommend watching this router5 talk from 2:45 - 7:50 https://youtu.be/hblXdstrAg0?t=165 since it's really key to how I think about view / state separation, and I think of routing as a state separate from the view. (After all, and especially in a client-rendered app, what page it is showing is certainly a major part
NativeScript is a JavaScript runtime that allows you to write an iOS or Android app entirely in TypeScript or JavaScript with no compromises. That is to say, it provides you with the same level of native access that writing the app in Obj-C/Swift (for iOS) or Java/Kotlin (for Android) does. Not just JSON-serialisable data types like NSString, but all data types are supported. To illustrate what it's all about, here's how you would get the battery level using NativeScript (the below snippet is entirely JS code!):
import { isIOS, isAndroid, Application } from "@nativescript/core";
/**The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'instead ofconst foo = require('foo')to import the package. You also need to put"type": "module"in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)from CommonJS instead ofrequire(…). - Stay on the existing version of the package until you can move to ESM.
| // | |
| // MapRegionUtility.swift | |
| // QuakeData | |
| // | |
| // Created by Adrian Bolinger on 7/9/18. | |
| // Copyright © 2018 Adrian Bolinger. | |
| // | |
| /* | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| import MapKit | |
| extension MKCoordinateRegion { | |
| init?(coordinates: [CLLocationCoordinate2D]) { | |
| // first create a region centered around the prime meridian | |
| let primeRegion = MKCoordinateRegion.region(for: coordinates, transform: { $0 }, inverseTransform: { $0 }) | |
| // next create a region centered around the 180th meridian |
| // 2018.5.11更新: 减少了swap | |
| function qSort(compare) { | |
| var swap = (p1, p2) => { | |
| var tmp = this[p1]; | |
| this[p1] = this[p2]; | |
| this[p2] = tmp; | |
| } | |
| var sortRange = (start, end) => { | |
| var midValue = this[start]; | |
| var p1 = start + 1, p2 = end - 1; |
| // getComponent is a function that returns a promise for a component | |
| // It will not be called until the first mount | |
| function asyncComponent(getComponent) { | |
| return class AsyncComponent extends React.Component { | |
| static Component = null; | |
| state = { Component: AsyncComponent.Component }; | |
| componentWillMount() { | |
| if (!this.state.Component) { | |
| getComponent().then(Component => { |