This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -I -XOPTIONS \ | |
-H "Access-Control-Request-Method: POST" \ | |
-H "Origin: https://frontend.app.com" \ | |
https://api.app.com/messages | grep access-control-allow-origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (string & {}) defers collapsing of type, showing your | |
// suggested values as autocompletable. | |
// https://www.youtube.com/watch?v=lraHlXpuhKs&t=481s | |
const Brand = 'Audi' | 'BMW' | 'Volvo' | (string & {}); | |
const drive = (brand: Brand) => { | |
console.log(`${brand} goes wroom wroom!`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Util type to simplify how types are rendered in editor | |
// https://www.youtube.com/watch?v=lraHlXpuhKs&t=420s | |
type Prettify<T> = { | |
[K in keyof T]: T[K]; | |
}; | |
type ComplexType = { a: boolean } & Omit<{ b: number, c: number}, 'c'>; | |
type FlattenedType = Prettify<ComplexType> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select json_agg(row_to_json(t)) from (select * from "my_table" LIMIT 1) as t; | |
-- This ⬆️ will return a json of the results, which you could use for test data/mock data, you name it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
referencing_schema_name, referencing_entity_name, referencing_id, | |
referencing_class_desc, is_caller_dependent | |
FROM | |
sys.dm_sql_referencing_entities ('REPLACE_WITH_TABLE_NAME', 'OBJECT'); | |
GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useQueryClient } from '@tanstack/react-query'; | |
/* | |
* Demonstration of how to fetch data from API in a promise, | |
* but utilizing already cached data from React Query | |
* or (if not present) populate the cache after fetch. | |
* | |
* Motivation: reduce unnecessary data fetching. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Notification app", | |
"short_name": "Notifs", | |
"start_url": ".", | |
"display": "standalone", | |
"background_color": "#1f2937", | |
"orientation": "portrait", | |
"description": "Notifications made easy.", | |
"icons": [{ | |
"src": "img/logo_144.png", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const authOptions: NextAuthOptions = { | |
// [...other options] | |
providers: [ | |
env.NODE_ENV === "development" | |
? ConsoleOtpProvider() | |
: EmailOtpProvider({ from: env.EMAIL_FROM, server: env.EMAIL_URL }), | |
], | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type NextAuthOptions } from "next-auth"; | |
import EmailProvider from "next-auth/providers/email"; | |
import { ConsoleEmailLink } from "./dev.auth.ts"; | |
/** | |
* ConsoleEmailLink will print a login link to the console. | |
* Enables you to login while developing without internet, | |
* and makes local setup easier. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('matchesPath', () => { | |
const matches = [ | |
['/cake', '/cake'], | |
['/cake', '/cake/'], | |
['/cake', '/cake?frige=warm'], | |
['/cake', '/cake?frige=warm&freezer=cold'], | |
['/[id]', '/cake'], | |
['/[anything-goes]', '/cake'], | |
['/c/[id]/practitioner/[pid]/[anything-goes]', '/c/1/practitioner/2/3'], | |
['/[...rest]', '/cake'], |
NewerOlder