Drafts

Draft and unpublished posts

0 posts simple view

Core Keeper

Steam achievements and progress for Core Keeper - 0.0% complete with 0/51 achievements unlocked.

5 min

Starbound - Unstable

Steam achievements and progress for Starbound - Unstable - 9.8% complete with 5/51 achievements unlocked.

4 min

Colossal Order Game

Steam achievements and progress for Colossal Order Game - 3.94% complete with 5/127 achievements unlocked.

10 min

Poly Bridge 2

Steam achievements and progress for Poly Bridge 2 - 9.09% complete with 2/22 achievements unlocked.

4 min

Mimpi Dreams

Steam achievements and progress for Mimpi Dreams - 17.54% complete with 10/57 achievements unlocked.

6 min

Pycon 2023

Keynote Speaker - James Powell # I don’t want to be an expert python developer. https://www.youtube.com/watch?v=iKzOBWOHGFE usage of keyword only arguments to prevent pain for users of libraries # In an alternate timeline the maintainer of newton could have chose to use keyword only arguments to prevent pain for users of libraries, or poor api design due to fear of changing api on users.
1 min read

Craftopia

Steam achievements and progress for Craftopia - 0.0% complete with 0/50 achievements unlocked.

5 min
global Field
global BaseModel
from pydantic import BaseModel
from pydantic import Field

Pydantic is a Python library for serializing data into models that can be validated with a deep set of built in valitators or your own custom validators, and deserialize back to JSON or dictionary.

Installation #

To install pydantic you will first need python and pip. Once you have pip installed you can install pydantic with pip.

pip install pydantic

Always install in a virtual environment

Creating a Pydantic model #

To get started with pydantic you will first need to create a Pydantic model. This is a python class that inherits from pydantic.BaseModel.

from pydantic import BaseModel
from pydantic import Field
from typing import Optional

class Person(BaseModel):
    name: str = Field(...)
    age: int

parsing an object #

person = Person(name="John Doe", age=30)
print(person)
name='John Doe' age=30

data serialization #

Pydantic has some very robust serialization methods that will automatically coherse your data into the type specified by the type-hint in the model if it can.

person = Person(name=12, age="30")
print(f'name: {person.name}, type: {type(person.name)}')
print(f'age: {person.age}, type: {type(person.age)}')
1 validation error for Person
name
  Input should be a valid string [type=string_type, input_value=12, input_type=int]
    For further information visit https://errors.pydantic.dev/2.3/v/string_type
person = Person(name="John Doe", age='thirty')
print(f'name: {person.name}, type: {type(person.name)}')
print(f'age: {person.age}, type: {type(person.age)}')
1 validation error for Person
age
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='thirty', input_type=str]
    For further information visit https://errors.pydantic.dev/2.3/v/int_parsing

loading from json #

serializing to json #

validation #

Knockout City™

Steam achievements and progress for Knockout City™ - 2.0% complete with 1/50 achievements unlocked.

5 min

Badger

Steam achievements and progress for Badger - 12.5% complete with 5/40 achievements unlocked.

6 min

Frozen Flame

Steam achievements and progress for Frozen Flame - 6.25% complete with 2/32 achievements unlocked.

4 min

MultiVersus

Steam achievements and progress for MultiVersus - 53.57% complete with 15/28 achievements unlocked.

5 min

useful btrfs tools

disk usage # Looking at disk usage on any of these must be done using a tool built for it if you want an accurate measurement. General purpose tools like du will be inaccurate as they do not count things like duplicate copies in snapshots. -T for tabular format mounting the drive # mounting a snapshot # snapper # btdu # btrfs-assistant #
1 min read

Subnautica

Steam achievements and progress for Subnautica - 5.88% complete with 1/17 achievements unlocked.

4 min

Poly Bridge

Steam achievements and progress for Poly Bridge - 9.09% complete with 2/22 achievements unlocked.

4 min

devops philosophy

How to keep a secret - https://changelog.com/shipit/58 Kelsey Heightower Fundamentals - https://changelog.com/shipit/44 What does good devops look like - https://changelog.com/shipit/28 Docs are not optional - https://changelog.com/shipit/17 Dave Farley the foundations of Continuous Delivery - https://changelog.com/shipit/5

Steep

Steam achievements and progress for Steep - 0.0% complete with 0/41 achievements unlocked.

5 min

extending vim with shell commands

Vimconf 2022 The pitch # Extending vim does not need to be complicated and can be done using cli tools that you might already be comfortable with. Examples, setting up codeformatters with autocmds, using lf/ranger as a tui file manager, generating new files using a template framework like cookiecutter/copier/yeoman, using ag to populate your quickfix. run a command # formatters # File Navigation # FloatTerm # vimgrep over hidden files # I know all the files that I care to search for are called build.yml, and they are in a hidden directory. Once opened as a buffer by using args, and a handy fd command I can vimgrep over all the open buffers using Open buffers are represented by ## Now I can just and my way through the list of changes that I have, and know that I hit every one of them when I am at the end of my list. And can double check this in about 10s by scrolling back through the quickfix list.
1 min read
from kedro.pipeline import node

node(
    input="raw",
    output="int",
    func=my_func,
    tags=["one"],
)