This file contains 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
use aes_gcm::{ | |
aead::{generic_array::GenericArray, Aead}, | |
Aes256Gcm, | |
}; | |
async fn decrypt_body( | |
mut response: reqwest::Response, | |
cipher: &Aes256Gcm, | |
) -> anyhow::Result<reqwest::Response> { | |
let mut headers = std::mem::take(response.headers_mut()); |
This file contains 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
if exists("*ToggleBackground") == 0 | |
function ToggleBackground() | |
if &background == "dark" | |
set background=light | |
else | |
set background=dark | |
endif | |
endfunction | |
command BG call ToggleBackground() |
This file contains 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
let lastFocusedId = null; | |
document.addEventListener("turbolinks:request-start", function () { | |
const element = document.querySelector( | |
"[data-turbolinks-preserve-focus]:focus" | |
); | |
if (element) { | |
lastFocusedId = element.id; | |
} |
This file contains 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 function asyncComponent<T>( | |
fn: (props: T) => Promise<JSX.Element> | |
): React.FC<T> { | |
return fn as any; | |
} |
This file contains 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
create schema if not exists my_new_schema; | |
alter default privileges for user supabase_admin in schema my_new_schema grant all | |
on sequences to postgres, anon, authenticated, service_role; | |
alter default privileges for user supabase_admin in schema my_new_schema grant all | |
on tables to postgres, anon, authenticated, service_role; | |
alter default privileges for user supabase_admin in schema my_new_schema grant all | |
on functions to postgres, anon, authenticated, service_role; | |
alter default privileges for user postgres in schema my_new_schema grant all | |
on sequences to postgres, anon, authenticated, service_role; | |
alter default privileges for user postgres in schema my_new_schema grant all |
This file contains 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
.comPlainTextContentEditable { | |
-webkit-user-modify: read-write-plaintext-only; | |
} | |
.comPlainTextContentEditable--has-placeholder::before { | |
content: attr(placeholder); | |
opacity: 0.5; | |
color: inherit; | |
cursor: text; | |
} |
This file contains 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
// @ts-check | |
require('path'); | |
const esbuild = require('esbuild'); | |
async function main() { | |
const {plugin, set} = createDependencyPlugin(); | |
await esbuild.build({ | |
bundle: true, |
This file contains 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
type Thenable<T> = { | |
then<R, L = never>(onFulfill: (t: T) => R, onError?: (err: any) => L): Thenable<R | L>, | |
catch<L>(onError: (err: any) => L): Thenable<T | L>, | |
} | |
type Result<T> = { type: "value", value: T } | { type: "error", error: any }; | |
/** Wrapper around simple functions that allow you to `.catch` and `.then` for synchronous functions */ | |
function thenable<T>(createT: () => T): Thenable<T> { | |
let resultT: Result<T>; |
This file contains 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
type Validator<Input, Error> = (input: Input) => Error[]; | |
type ExtractValidatorError<V extends Validator<any, any>> = V extends Validator<any, infer A> ? A : never; | |
function error<Error>(error: Error): Error[] { | |
return [error]; | |
} | |
function ok(): any[] { | |
return []; | |
} |
This file contains 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
////////////////////////////////////////////////////////////// Array utilities | |
type Length<T extends any[]> = T["length"]; | |
type Head<T extends any[]> = T[0]; | |
type Tail<T extends any[]> = ((...xs: T) => any) extends ((_x: any, ...xs: infer R) => any) ? R : []; | |
type AllTrue<Ts extends any[]> = { | |
0: true, | |
1: false, | |
2: AllTrue<Tail<Ts>> | |
}[Length<Ts> extends 0 ? 0 : Head<Ts> extends false ? 1 : 2] |
NewerOlder