Skip to content

Instantly share code, notes, and snippets.

View zoontek's full-sized avatar

Mathieu Acthernoene zoontek

View GitHub Profile
@nandorojo
nandorojo / readme.md
Last active February 1, 2024 13:26
URQL Simple Pagination Hook implementation

This hook lets you use pagination from URQL. I needed a better solution for React Native and infinite lists.

It also has a pullToRefresh option. Since URQL's pull to refreshes are so insanely flickery, I decided to fake this completely, and make it pretend to spin for one second (plenty for most calls).

Be sure to use useMemo with your variables!

It comes with typesafety too.

const document = graphql(`
import { Router } from 'next/router';
import { useEffect } from 'react';
import { publicConfig } from '~/shared/config';
import { trpc } from '~/utils/trpc';
let initVersion = publicConfig.GIT_COMMIT;
function useDetectVersionChange() {
const healthQuery = trpc.health.useQuery(undefined, {
refetchInterval: 10_000,
@veekaybee
veekaybee / chatgpt.md
Last active April 12, 2024 20:16
Everything I understand about chatgpt

ChatGPT Resources

Context

ChatGPT appeared like an explosion on all my social media timelines in early December 2022. While I keep up with machine learning as an industry, I wasn't focused so much on this particular corner, and all the screenshots seemed like they came out of nowhere. What was this model? How did the chat prompting work? What was the context of OpenAI doing this work and collecting my prompts for training data?

I decided to do a quick investigation. Here's all the information I've found so far. I'm aggregating and synthesizing it as I go, so it's currently changing pretty frequently.

Model Architecture

@subfuzion
subfuzion / README.md
Last active August 29, 2023 01:41
Node.js 18 Test Runner

Node.js 18 Test Runner

Node.js v18 introduces test runner support. This currently experimental feature gives developers the benefits of a structured test harness for their code without having to install a third party test framework, like Mocha or Jest, as a dependency. Using the test runner produces [TAP] output.

The [online reference] provides the most up-to-date, authoritative reference and have plenty of good testing examples. However, there are a few points that might not be immediately obvious from the reference, so those are highlighted here.

@dsumer
dsumer / TaxRateModel.ts
Last active February 2, 2022 15:07
Apply the correct VAT Rate to your customer in Stripe Checkout
import { Model } from 'objection';
export default class TaxRateModel extends Model {
countryCode!: string;
stripeId!: string;
static tableName = 'tax_rate';
}
#!/bin/sh
set -e
# 查杀/恢复 CleanMyMac 的流氓后台 HealthMonitor
#
# - 执行脚本后,原 HealthMonitor.app 会被备份并被空目录替代,然后杀掉后台进程(你直接杀是杀不净的)。此时 CleanMyMac 主应用也不能运行。
# - 再次执行脚本,则将备份的文件恢复回去,CleanMyMac 则可以正常使用。
#
# NOTE: 如果不是 Setapp 版本,进程名可能不同,需要自行修改下面变量:
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active March 29, 2024 08:00
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@bvaughn
bvaughn / useSubscription-and-useMutableSource.md
Last active December 29, 2021 02:12
`useSubscription` and `useMutableSource` tearing and deopt behavior.

useSubscription and useMutableSource1 tearing and deopt behavior.

Mounting a new tree

The tree below represents a React application mounting. During mount, two components read from an external, mutable source. The first one (List) reads version 1 of that data and the second one (Item) reads version 2.

Deopt

useSubscription (legacy mode)

N/A.

import { ApolloClient, QueryOptions, MutationOptions } from 'apollo-client';
import { DocumentNode } from 'graphql';
import { getSdk, Requester } from '.generated/schema-typedefs';
import { ApolloRequestError } from './ApolloRequestError';
export type ApolloRequesterOptions<V, R> =
| Omit<QueryOptions<V>, 'variables' | 'query'>
| Omit<MutationOptions<R, V>, 'variables' | 'mutation'>;