Skip to content

Instantly share code, notes, and snippets.

Avatar

Atsushi Odagiri aodag

View GitHub Profile
@aodag
aodag / mpdplaylist.sh
Created Dec 26, 2021
select playlist and play mpd
View mpdplaylist.sh
#!/bin/sh
playlist=$(mpc lsplaylist | wofi -d)
if [ -n "$playlist" ] ; then
mpc clear
mpc load "$playlist"
mpc play
fi
@aodag
aodag / env
Last active Feb 20, 2021
PEP600 の確認 Linux debian-desktop 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
View env
aodag@debian-desktop:~$ uname -a
Linux debian-desktop 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
aodag@debian-desktop:~$ python3 -V
Python 3.7.3
View init.el
(leaf *preferences
:config
(setq custom-file "~/.emacs-custom.el")
(setq visible-bell t)
(load custom-file)
(menu-bar-mode -1)
(tool-bar-mode -1)
(set-face-attribute 'default nil :family "Noto Sans Mono" :height 140)
(load-theme 'tango-dark t))
View settings.json
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true
}
@aodag
aodag / pytest.md
Last active Mar 2, 2020 — forked from shiumachi/pytest.md
Pytestの書き方入門
View pytest.md

インストール

pip install pytest pytest-cov pytest-randomly pytest-mock
  • pytest-cov: カバレッジ計測プラグイン
  • pytest-randomly: 実行順のランダム化
  • pytest-mock: mock利用プラグイン
@aodag
aodag / dataclass_converter.py
Created Feb 11, 2020
extension to convert dataclasses with cattrs.
View dataclass_converter.py
import dataclasses
from .converters import Converter
def _is_dataclasses_class(obj):
return dataclasses.is_dataclass(obj)
class DataclassesConverter(Converter):
def __init__(self, *args, **kwargs):
View app.py
from pyramid.config import Configurator
def hello(request):
return dict(message="Hello, world!")
def main(global_conf, **settings):
config = Configurator(settings=settings)
config.include("pyramid_jinja2")
@aodag
aodag / app.py
Created Jun 16, 2019
request引数のgenericsで指定したTypeからmarshmallowスキーマを生成して設定するwsgi wrapper
View app.py
import json
import inspect
from datetime import datetime
from dataclasses import dataclass, asdict
from typing import TypeVar, Generic, Optional, Callable, Dict, Any, Type, Iterable, Sequence
from typing_extensions import Protocol
import webob
import webtest
import marshmallow_dataclass
from marshmallow import Schema
View settings.json
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.jediEnabled": false,
"python.formatting.provider": "black",
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"editor.formatOnSave": true
}
@aodag
aodag / minimal_publication.py
Created Apr 21, 2019
zope.publisher に最低限のpublicationを使って Hello, world
View minimal_publication.py
from zope.publisher.paste import Application
from zope.publisher.interfaces import IPublication
from zope.interface import implementer
from zope.component import getGlobalSiteManager
@implementer(IPublication)
class MyWorkPublication:
def __init__(self, global_conf, **app_conf):
pass