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 { useEffect, useState } from 'react'; | |
/** | |
* Load data from an async function and update a state. | |
*/ | |
export default function useAsyncState<TValue>(loader: Promise<TValue> | (() => Promise<TValue>)) { | |
const [value, setValue] = useState<TValue>(); | |
useEffect(() => { | |
const promise = typeof loader === 'function' ? loader() : loader; | |
promise.then(setValue); |
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 { | |
chakra, | |
keyframes, | |
CSSObject, | |
ChakraProps, | |
useToken, | |
} from '@chakra-ui/react'; | |
export type FlashingDotsProps = Pick<ChakraProps, 'width' | 'height'> & { | |
/** |
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 pkgutil | |
from aiohttp import web | |
ALLOWED_METHODS = ["GET", "POST"] | |
def load_route_handlers(path, mod): | |
routes = [] | |
for method in ALLOWED_METHODS: | |
if hasattr(mod, method): |
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 os | |
from .app import start_cli_service | |
env = (os.environ.get("env") or "prod").lower() | |
is_dev = env == "dev" or env == "local" | |
port, autoreload_observer = start_cli_service(autoreload=is_dev) | |
if autoreload_observer: | |
# move autoreload observer to the foreground so process won't exit |
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 sqlalchemy as sa | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
class Model(Base): | |
__tablename__ = "model" | |
id = sa.Column("id", primary_key=True) | |
bbb = sa.Column("bbb") |
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 type FlashingDotsProps = { | |
/** | |
* Size of each dot | |
*/ | |
dotSize?: number; | |
/** | |
* Animation duration. | |
*/ | |
duration?: number; | |
/** |
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
def remove_duplicates( | |
items: Iterable[InputType], key: Optional[Callable[[InputType], Any]] = None | |
) -> List[InputType]: | |
"""Remove duplicate items in an iterable.""" | |
if not key: | |
return list(dict.fromkeys(items).keys()) | |
seen = set() | |
result = [] | |
for item in items: | |
item_key = key(item) |
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
#!/usr/bin/env python3 | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
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 { | |
ReactNode, | |
HTMLAttributes, | |
CSSProperties, | |
HTMLProps, | |
MutableRefObject, | |
FunctionComponent, | |
} from 'react'; | |
declare module 'react-syntax-highlighter' { |
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 enum import Enum, IntEnum | |
from typing import Any, Dict, Optional | |
from flask import jsonify | |
from flask_babel import gettext as _, ngettext | |
from superset.typing import FlaskResponse | |
class SupersetErrorCode(IntEnum): | |
# Generic Superset errors |
NewerOlder