Skip to content

Instantly share code, notes, and snippets.

@sobolevn
sobolevn / hkt_in_python.py
Last active Oct 29, 2020
Higher Kinded Types in Python
View hkt_in_python.py
import abc
import dataclasses
from typing import Callable, Generic, TypeVar
# TODO: pip install returns
# TODO: add `returns.contrib.mypy.returns_plugin` to mypy plugins
# TODO: read the docs at https://github.com/dry-python/returns
from returns.primitives.hkt import Kind1, SupportsKind1, kinded
_ValueType = TypeVar('_ValueType')
View maybe.py
from typing import Any, TypeVar, Callable, Generic, Optional, TYPE_CHECKING
from returns.functions import compose
if not TYPE_CHECKING:
reveal_type = print
T = TypeVar('T')
N = TypeVar('N')
View hypothesis.build
ex.py::test_draw_law:
- during reuse phase (0.13 seconds):
- Typical runtimes: 16-105 ms, ~ 52% in data generation
- 2 passing examples, 0 failing examples, 0 invalid examples
- during generate phase (30.93 seconds):
- Typical runtimes: 15-33 ms, ~ 89% in data generation
- 998 passing examples, 0 failing examples, 13 invalid examples
- Events:
View .eslintrc.json
{
"env": {
"node": true,
"browser": true,
"es6": true
},
"globals": {
"document": false,
"navigator": false,
"window": false
View manim.log
A002: "dict" is used as an argument and thus shadows a python builtin, consider renaming the argument
1 manimlib/utils/config_ops.py
Total: 1
B001: Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer `except Exception:`. If you're sure what you're doing, be explicit and write `except BaseException:`.
1 manimlib/mobject/svg/drawings.py
4 manimlib/mobject/svg/svg_mobject.py
1 manimlib/utils/color.py
1 manimlib/utils/sounds.py
Total: 7
View pipfile-to-poetry.py
# -*- coding: utf-8 -*-
import json
import toml
def read_pipenv_lock():
with open('Pipfile.lock') as lock:
return json.loads(lock.read())
View create_merge_conflict.sh
#!/usr/bin/env bash
# Running: `bash create_merge_conflict.sh`
set -e
PROJECT_NAME="pipenv-merge-conflicts"
# Creating project structure:
rm -rf "$PROJECT_NAME"
View pipenv.txt
(pipenv-tests) ~/Desktop/pipenv master ✗
» pipenv run pytest -n 8 tests
Loading .env environment variables…
============================= test session starts ==============================
platform darwin -- Python 3.6.4, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /Users/sobolev/Desktop/pipenv, inifile:
plugins: xdist-1.22.0, forked-0.2
gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 ok / gw5 ok / gw6 ok / gw7 ogw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 ok / gw6 ok / gwgw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 [111] / gw7 [111]
scheduling tests via LoadScheduling
FFFFFF..s........s..s......F..................F......................... [ 64%]
@sobolevn
sobolevn / Pipfile
Created Nov 11, 2017
mimesis-factory
View Pipfile
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
mimesis = "*"
View medium-ecto-slugs-article-build-slug.ex
defmodule EctoSlugs.Blog.Article.TitleSlug do
use EctoAutoslugField.Slug, from: :title, to: :slug
def build_slug(sources, _changeset) do
sources
|> super()
|> String.replace("-", "+")
end
end