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
| #!/usr/bin/python2 | |
| from bs4 import BeautifulSoup | |
| import urllib | |
| path = '/home/tunisia/Projects/rosalind/' | |
| html = BeautifulSoup(urllib.urlopen('http://rosalind.info/problems/list-view/')) | |
| tr_all = html.find_all('tr') |
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
| from contextlib import asynccontextmanager | |
| import asyncio as aio | |
| from playwright.async_api import async_playwright | |
| class BrowserPool: | |
| def __init__(self, n_tabs=10, executable=None) -> None: | |
| self.executable = executable | |
| self.n_tabs = n_tabs | |
| self.tabs_remaining = n_tabs |
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 asyncio as aio | |
| from collections import deque | |
| from typing import Awaitable, Iterable, TypeVar | |
| T = TypeVar("T") | |
| class BaseLimit: | |
| async def limit(self, awa: Awaitable[T]) -> T: |
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 asyncio | |
| import datetime as dt | |
| from functools import wraps | |
| from typing import Union | |
| from httpx import AsyncClient | |
| # unless you keep a strong reference to a running task, it can be dropped during execution | |
| # https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task | |
| _background_tasks = set() |
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
| #!/usr/bin/env python3 | |
| """ | |
| Transform between networkx v1 and v2+ node_link_data format. | |
| """ | |
| def node_link_data_1_2( | |
| data: dict, *, source="source", target="target", name="id", key="key", link="links" | |
| ): | |
| """Update the node_link_data in-place for compatibility with networkx v2+. |
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
| #!/usr/bin/env python3 | |
| """ | |
| Group nodes together in a networkx DiGraph. | |
| Requires networkx. | |
| """ | |
| from typing import Hashable, Any, Callable, Optional | |
| import networkx as nx | |
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
| #!/usr/bin/env python3 | |
| """Load a list of images in dask.""" | |
| from pathlib import Path | |
| import re | |
| from typing import Callable, Iterable, Optional | |
| import dask.array as da | |
| from dask import delayed | |
| import numpy as np |
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
| from functools import lru_cache, wraps | |
| from typing import Optional, Callable | |
| from copy import copy, deepcopy | |
| def copy_cache(deep: bool = True, maxsize: Optional[int] = 128, typed: bool = False): | |
| """Decorator factory wrapping functools.lru_cache, which copies return values. | |
| Use this for functions with mutable return values. |
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
| #!/usr/bin/env python3 | |
| """Module for building pandas DataFrames by row.""" | |
| from collections.abc import Sequence, Collection | |
| import typing as tp | |
| import pandas as pd | |
| class DataFrameBuilder: | |
| def __init__( |
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
| #!/bin/sh | |
| set -e | |
| if [ $# -eq 0 ]; then | |
| >&2 echo "No argument given, using ls" | |
| exec ls | |
| elif [ -d "$1" ]; then | |
| >&2 echo "Directory detected, using ls" | |
| exec ls "$1" | |
| elif [ -f "$1" ]; then | |
| >&2 echo "File detected, using less" |