Skip to content

Instantly share code, notes, and snippets.

View 00.output
n = 1
name = f
n = 2
name = fo
n = 3
name = foo
n = 4
View Dockerfile
FROM python:3.9-slim
RUN python3 -m pip install boto3 pandas
CMD ["python3"]
View 02calc.py
from typing import Any, Optional
from sympy import parse_expr, pi, Symbol, E
def calc(expr_str: str, *, vars: Optional[dict[str, Any]] = None) -> Any:
if vars is None:
vars = {}
# evaluate=Trueだとeval()を使ってしまうっぽい
# ただし、 When evaluate=False, some automatic simplifications will not occur:
View 00clustered-web-services.py
from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import ElastiCache, RDS
from diagrams.aws.network import ELB
from diagrams.aws.network import Route53
# https://diagrams.mingrammer.com/docs/getting-started/examples
with Diagram("Clustered Web Services", show=False):
dns = Route53("dns")
View 05use.py
import logging
from strangeeval import evaluate, DEBUG
class Point:
x: int
y: int
def use(*, x: int) -> None:
View main.tf
data "terraform_remote_state" "root" {
backend = "local"
config = {
path = "../terraform.tfstate"
}
}
output "message" {
value = "hello ${data.terraform_remote_state.root.outputs.config.person.name}!!"
View Makefile
default:
terraform init
terraform validate
terraform apply -auto-approve
View 04use.py
from dataclasses import dataclass
import configlang
@dataclass
class Point:
x: int
y: int
@dataclass
View main.go
package main
import (
"encoding/json"
"errors"
"fmt"
"os"
"time"
)
View design.md

go structopt

goのCLIの定義をstructの設定だけに限定してみればべんりなのではないか? 難しく考えすぎない。

concept

  • 既存のライブラリは覚える事が多すぎる
  • ほとんどstructとタグで定義する。実はCLI用の特別な型毎の対応って不要なんじゃないか?