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
import asyncio | |
import subprocess | |
import time | |
from asgiref.sync import sync_to_async | |
async def delete_revision(function_name, revision): | |
cmd = f"aws lambda delete-function --function-name {function_name}:{revision}" | |
print(cmd) |
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
import sys | |
from math import ceil, floor | |
from hashids import Hashids | |
target_length = 8 | |
hashids = Hashids(min_length=target_length) | |
print(f"target_length={target_length}") |
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
""" | |
Camelize FastAPI path params and query params. | |
For body params and responses, use pydantic model's alias_generator config. | |
""" | |
from fastapi import FastAPI | |
from fastapi.dependencies.models import Dependant | |
from fastapi.routing import APIRoute | |
from humps import camelize |
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
from copy import copy | |
from typing import Generic, Optional, TypeVar, get_args, get_type_hints | |
from pydantic import BaseModel | |
from pydantic.errors import ConfigError | |
from pydantic.typing import convert_generics | |
T = TypeVar('T', bound=BaseModel) | |
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
const getFileFromURL = async (url: string): Promise<File> => { | |
const result = await fetch(url) | |
const buffer = await result.arrayBuffer() | |
const blob = new Blob([buffer]) | |
const file = new File([blob], url.split('/')[1]) | |
return file | |
} | |
// Usage | |
const someFile: File |
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
- node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js | |
+ ../MyApp/node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js |
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
_getFileData(file) { | |
const relativePath = fastPath.relative(this._rootDir, file); | |
+ if (file.endsWith('node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js')) { | |
+ console.log('rootDir:', this._rootDir); | |
+ console.log('file:', file); | |
+ console.log('relativePath:', relativePath); | |
+ } | |
return this._files.get(relativePath); | |
} | |
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
jest.mock('@wry/equality', () => ({ | |
equal: (lhs: any, rhs: any) => { | |
const equals = require('expect/build/jasmineUtils').equals(lhs, rhs) | |
return equals || jest.requireActual('@wry/equality').equal(lhs, rhs) | |
} | |
})) | |
const mocks = [ | |
{ |
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 Spy<T extends {}, M extends jest.FunctionPropertyNames<Required<T>>> = Required<T>[M] extends (...args: any[]) => any | |
? jest.SpyInstance<ReturnType<Required<T>[M]>, jest.ArgsType<Required<T>[M]>> | |
: never; |
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
class NonNullConnection(graphene.relay.Connection): | |
class Meta: | |
abstract = True | |
@classmethod | |
def __init_subclass_with_meta__(cls, node=None, **options): | |
if node is not None and not isinstance(node, graphene.NonNull): | |
node = graphene.NonNull(node) | |
super(NonNullConnection, cls).__init_subclass_with_meta__( |
NewerOlder