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
\usepackage{nicematrix} % https://ctan.org/pkg/nicematrix?lang=en | |
\begin{NiceMatrixBlock}[auto-columns-width] | |
\[ | |
\begin{array}{cccc} | |
& n\text{ source code items} & & m\text{ tests} \\ | |
C = & | |
\begin{bNiceMatrix} | |
c_{1,1} & c_{1,2} & \cdots & c_{1,n} \\ | |
c_{2,1} & c_{2,2} & \cdots & c_{2,n} \\ |
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 httpx as httpx | |
from fastapi import FastAPI | |
app = FastAPI() | |
async def _get_security_score(): | |
url = "https://google.com" | |
async with httpx.AsyncClient() as client: | |
response = await client.get(url) | |
return response.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
import logging | |
import os | |
from subprocess import CompletedProcess | |
import subprocess | |
def uvicorn_logger(): | |
return logging.getLogger('uvicorn') |
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 _get_similar_ones(data: pandas.DataFrame, x_name, y_name, index): | |
return data[(data[x_name] == data.iloc[index][x_name]) & (data[y_name] == data.iloc[index][y_name])] | |
def circular_layout(data: pandas.DataFrame, x_name, y_name, x_offset, y_offset, radius): | |
data[x_offset] = None | |
data[y_offset] = None | |
for index, row in data.iterrows(): | |
if not pandas.isnull(data.iloc[index][x_offset]) and not pandas.isnull(data.iloc[index][y_offset]): | |
continue |
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 textwrap import TextWrapper | |
class LineSafeTextWrapper(TextWrapper): | |
def fill(self, text: str) -> str: | |
return '\n'.join(['\n'.join(self.wrap(line)) for line in text.splitlines() if line.strip() != '']) |
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 logging | |
from typing import Callable | |
class LambdaFormatter(logging.Formatter): | |
def __init__( | |
self, | |
fmt, | |
pre_format_func: Callable[[logging.LogRecord], logging.LogRecord] = lambda text: text, | |
post_format_func: Callable[[str, logging.LogRecord], str] = lambda text, _: 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
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script> | |
<script src="https://momentjs.com/downloads/moment-timezone-with-data-10-year-range.js"></script> | |
<script type="text/javascript"> | |
let my_zone = moment.tz.guess(true); | |
function my(date, duration_text) { | |
let conf_date = moment.tz(date, "CET"); | |
let my_date = moment(conf_date).tz(my_zone); | |
let duration = moment.duration(duration_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
import pytest | |
class ClassA(object): | |
def apply(self, *args): | |
return 42 | |
class ClassB(object): | |
def apply(self, *args): |
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 pytest | |
import typing | |
# add more hint properties as you wish... | |
def hint(id: str, name: typing.Optional[str] = None): | |
def _hint(fn: typing.Callable): | |
fn.hint_id = id | |
fn.hint_name = name if name is not None else id | |
return fn |
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 argparse | |
import sys | |
def main(): | |
""" | |
python wtf-abbr.py --abbr WTF --long "would you like to find the perfect abbreviation" | |
WTF abbreviation found! | |
Would you like To Find the perfect abbreviation | |
^ ^ ^ |
NewerOlder