Moved to a repo at https://github.com/Geczy/coolify-migration
<artifacts_info> | |
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity. | |
# Good artifacts are... | |
- Substantial content (>15 lines) | |
- Content that the user is likely to modify, iterate on, or take ownership of | |
- Self-contained, complex content that can be understood on its own, without context from the conversation | |
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations) | |
- Content likely to be referenced or reused multiple times |
import type { FetcherWithComponents } from "@remix-run/react"; | |
import { useFetcher } from "@remix-run/react"; | |
import { useEffect, useState } from "react"; | |
import type { AppData } from "@remix-run/react/dist/data"; | |
import type { SerializeFrom } from "@remix-run/server-runtime"; | |
/** | |
* A higher-order function that creates a new FetcherWithComponentsReset instance, which extends the FetcherWithComponents interface. | |
* The new instance includes an additional method `reset` that can be used to reset the state of the fetcher. | |
* |
name: Back up database | |
run-name: Task | |
on: | |
schedule: | |
- cron: '0 */6 * * *' | |
# every 6 hours | |
workflow_dispatch: | |
jobs: | |
backup: | |
runs-on: ubuntu-latest |
import { UseBoundStore } from 'zustand/esm'; | |
import { StoreApi } from 'zustand'; | |
import type { ElectronSyncOptions } from './middleware'; | |
export function getSerializableState(excludes: string[], state: unknown) { | |
return JSON.parse( | |
JSON.stringify(state, (key, value) => { | |
if (typeof value === 'function' || excludes.includes(key)) { | |
return undefined; | |
} |
Remix's useFetcher
doesn't return a Promise for any of its methods (like fetcher.submit()
) because Remix doesn't want you to explicitly await
anything so they can handle things like cancellation for you. Instead, they recommend adding a useEffect
and performing whatever logic you need to after the fetcher is in a particular state.
I found using an effect to run some logic after a submission to be too indirect, and there seem to be plenty of cases where you want to submit a form and then perform some other work on the client (sometimes async, like requesting the user's permission for their location), and I'd rather just do that after a submission in the event handler rather than an effect.
So here's a proof of concept hook that wraps Remix's useFetcher
and returns a version of submit
that is a promise, and resolves with the data from the action:
function useFetcherWithPromise() {
let resolveRef = useRef();
let promiseRef = useRef();
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/ | |
create or replace function uuid_generate_v7() | |
returns uuid | |
as $$ | |
begin | |
-- use random v4 uuid as starting point (which has the same variant we need) | |
-- then overlay timestamp | |
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string | |
return encode( |
This Gist represents an event-driven architecture that helps to structure my games in Unity. It uses events to trigger and communicate between decoupled parts of a game.
In the first game scene, create an empty Game Object named EventManager
and attach the EventManager.cs
script to it. This script is set to DontDestroyOnLoad
, i.e., it won't be destroyed when reloading scene.
The Producer.cs
and Consumer.cs
classes show how an event is published and consumed. In this example, when a coin is collected, an addCoins
event is published with the collected amount
. A Consumer receives the amount of coins collected and update its own coins amount.
Free O'Reilly books and convenient script to just download them.
Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post
How to use:
- Take the
download.sh
file and put it into a directory where you want the files to be saved. cd
into the directory and make sure that it has executable permissions (chmod +x download.sh
should do it)- Run
./download.sh
and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.