집중력 향상

2025-08-11 09:45

나의 근래의 화두

집중력 향상

일단 건강해야 한다, 심신

아니, 그게 전부일 듯 하다.

거기에 쾌적한 환경이 더해져야 한다.

쾌적한 카페와 찜통인 카페

체중 감소, 복부 지방 감소

# Creating DOCX and PDF files with ASCII filenames to avoid encoding/download issues.
from docx import Document
import os

docx_path = '/mnt/data/home_workout_routine.docx'
pdf_path = '/mnt/data/home_workout_routine.pdf'

routine_title = "20-minute Home Workout Routine (4-week template)"
intro = [
    "Location: Home (living room/bedroom). Space needed: ~2m x 2m.",
    "Equipment: Yoga mat or towel (optional). Frequency: 4-5 days/week. Duration: ~20 minutes/day."
]

routine_rows = [
    ("Part", "Exercise", "Time/Reps", "Notes"),
    ("Warm-up", "Ankle & knee circles", "30 sec each", "Joint mobility"),
    ("Warm-up", "Arm circles & shoulder stretch", "30 sec each", "Loosen upper body"),
    ("Warm-up", "Jog in place", "1 min", "Raise heart rate gently"),
    ("Circuit (repeat 3x)", "Jumping Jacks", "30-40 sec", "Cardio, full body"),
    ("", "Squats", "15 reps", "Keep chest up, knees behind toes"),
    ("", "Push-ups (knee or full)", "10-15 reps", "Chest, shoulders, triceps"),
    ("", "Mountain Climbers", "30-40 sec", "Core + cardio"),
    ("", "Plank", "30-40 sec", "Core stability"),
    ("Core focus", "Crunches", "15-20 reps", "Upper abs"),
    ("", "Leg Raises", "10-12 reps", "Lower abs"),
    ("", "Side Plank", "20-30 sec each side", "Obliques"),
    ("Cool-down", "Cobra stretch", "30 sec", "Lower back and abdomen"),
    ("Cool-down", "Hamstring/calf stretch", "30 sec", "Lower body relaxation")
]

# Create DOCX
doc = Document()
doc.add_heading(routine_title, level=1)
for p in intro:
    doc.add_paragraph(p)

table = doc.add_table(rows=1, cols=4)
hdr_cells = table.rows[0].cells
for i, h in enumerate(routine_rows[0]):
    hdr_cells[i].text = h

for row in routine_rows[1:]:
    cells = table.add_row().cells
    for i, val in enumerate(row):
        cells[i].text = val

doc.add_paragraph("\nNotes: Aim for a steady pace during the circuit. Rest 45-60 seconds between sets. Combine with daily walking (7,000-10,000 steps) and balanced diet for best results.")
doc.save(docx_path)

# Try to create PDF using reportlab; fall back to simple text-based PDF if needed
pdf_created = False
try:
    from reportlab.lib.pagesizes import A4
    from reportlab.pdfgen import canvas
    from reportlab.lib.units import mm

    c = canvas.Canvas(pdf_path, pagesize=A4)
    width, height = A4
    x_margin = 20 * mm
    y = height - 30 * mm
    c.setFont("Helvetica-Bold", 14)
    c.drawString(x_margin, y, routine_title)
    c.setFont("Helvetica", 10)
    y -= 10 * mm
    for p in intro:
        c.drawString(x_margin, y, p)
        y -= 6 * mm

    y -= 4 * mm
    # table-like rendering
    col_x = [x_margin, x_margin+60*mm, x_margin+120*mm, x_margin+165*mm]
    # header
    c.setFont("Helvetica-Bold", 10)
    for i, h in enumerate(routine_rows[0]):
        c.drawString(col_x[i], y, h)
    y -= 6 * mm
    c.setFont("Helvetica", 10)
    for row in routine_rows[1:]:
        if y < 30 * mm:
            c.showPage()
            y = height - 30 * mm
            c.setFont("Helvetica", 10)
        for i, cell in enumerate(row):
            # wrap long text minimally
            text = str(cell)
            c.drawString(col_x[i], y, text)
        y -= 6 * mm

    c.showPage()
    c.save()
    pdf_created = True
except Exception as e:
    pdf_created = False
    fallback_error = str(e)

# List files in /mnt/data to confirm
files = os.listdir('/mnt/data')
result = {
    "docx_path": docx_path,
    "pdf_path": pdf_path if pdf_created else None,
    "pdf_created": pdf_created,
    "files_in_mnt_data": files,
}
result

from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm

# 파일 경로
pdf_path_fixed = '/mnt/data/home_workout_routine_fixed.pdf'

# 데이터
routine_title = "20-minute Home Workout Routine (4-week template)"
intro = [
    "Location: Home (living room/bedroom). Space needed: ~2m x 2m.",
    "Equipment: Yoga mat or towel (optional). Frequency: 4-5 days/week. Duration: ~20 minutes/day."
]

routine_rows = [
    ("Part", "Exercise", "Time/Reps", "Notes"),
    ("Warm-up", "Ankle & knee circles", "30 sec each", "Joint mobility"),
    ("Warm-up", "Arm circles & shoulder stretch", "30 sec each", "Loosen upper body"),
    ("Warm-up", "Jog in place", "1 min", "Raise heart rate gently"),
    ("Circuit (repeat 3x)", "Jumping Jacks", "30-40 sec", "Cardio, full body"),
    ("", "Squats", "15 reps", "Keep chest up, knees behind toes"),
    ("", "Push-ups (knee or full)", "10-15 reps", "Chest, shoulders, triceps"),
    ("", "Mountain Climbers", "30-40 sec", "Core + cardio"),
    ("", "Plank", "30-40 sec", "Core stability"),
    ("Core focus", "Crunches", "15-20 reps", "Upper abs"),
    ("", "Leg Raises", "10-12 reps", "Lower abs"),
    ("", "Side Plank", "20-30 sec each side", "Obliques"),
    ("Cool-down", "Cobra stretch", "30 sec", "Lower back and abdomen"),
    ("Cool-down", "Hamstring/calf stretch", "30 sec", "Lower body relaxation")
]

# PDF 생성
c = canvas.Canvas(pdf_path_fixed, pagesize=A4)
width, height = A4
x_margin = 15 * mm
y = height - 20 * mm

# 제목
c.setFont("Helvetica-Bold", 14)
c.drawString(x_margin, y, routine_title)
y -= 10 * mm

# 소개
c.setFont("Helvetica", 10)
for p in intro:
    c.drawString(x_margin, y, p)
    y -= 6 * mm

y -= 4 * mm

# 컬럼 위치
col_x = [x_margin, x_margin + 50*mm, x_margin + 110*mm, x_margin + 155*mm]

# 헤더
c.setFont("Helvetica-Bold", 10)
for i, h in enumerate(routine_rows[0]):
    c.drawString(col_x[i], y, h)
y -= 6 * mm

# 데이터 행
c.setFont("Helvetica", 10)
for row in routine_rows[1:]:
    if y < 20 * mm:
        c.showPage()
        y = height - 20 * mm
        c.setFont("Helvetica-Bold", 10)
        for i, h in enumerate(routine_rows[0]):
            c.drawString(col_x[i], y, h)
        y -= 6 * mm
        c.setFont("Helvetica", 10)
    for i, cell in enumerate(row):
        c.drawString(col_x[i], y, str(cell))
    y -= 6 * mm

c.showPage()
c.save()

pdf_path_fixed

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *