Skip to content

Instantly share code, notes, and snippets.

View gh640's full-sized avatar
🦔

Goto Hayato gh640

🦔
View GitHub Profile
@gh640
gh640 / Dockerfile
Created August 7, 2022 09:01
サンプル: Docker の `ubuntu:20.04` イメージでタイムゾーンを JST に変更する
FROM ubuntu:20.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata
@gh640
gh640 / Dockerfile
Created August 7, 2022 08:55
サンプル: Docker の `debian:bullseye` イメージでタイムゾーンを JST に変更する
FROM debian:bullseye
# tzdata はすでに入っているので dpkg-reconfigure がそのまま使える
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata
@gh640
gh640 / func_name.sh
Created May 14, 2022 04:12
Zsh / Bash: Getting the current function name invoked
function func_name {
case "${SHELL}" in
*/bash)
# Bash
echo ${FUNCNAME[2]}
;;
*/zsh)
# Zsh
echo ${funcstack[2]}
;;
@gh640
gh640 / pyproject.toml
Last active August 14, 2022 03:45
Poetry setting to make the project private (prevent accidental push)
[tool.poetry]
name = "mypackage"
version = "0.1.0"
description = ""
authors = []
classifiers = [
"Private :: Do not Upload"
]
@gh640
gh640 / Dockerfile
Last active February 5, 2022 13:02
Sample: Convert `.mov` file to `.gif` animation
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y ffmpeg && \
rm -rf /var/lib/apt/lists/*
@gh640
gh640 / html-style-dictionary-ja.html
Created January 22, 2022 10:18
サンプル: HTML で基本的な要素のスタイルのチェックに使用するためのテンプレート
<!DOCTYPE>
<html>
<head>
<title>スタイルディクショナリ</title>
</head>
<body>
<h1>スタイルディクショナリ</h1>
<h2>共通</h2>
@gh640
gh640 / asyncio_streaming_example.py
Created December 12, 2021 02:45
Python: Stream output of `asyncio.create_subprocess_exec()`
"""Stream output of `asyncio.create_subprocess_exec()`"""
import asyncio
import sys
async def run(program: str, args: list[str]):
"""Capture output (stdout and stderr) while running external command."""
proc = await asyncio.create_subprocess_exec(
program, *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
@gh640
gh640 / use_python_poetry_cache_on_github_actions_workflow.yml
Last active April 29, 2024 15:05
Sample: Use Python Poetry cache on GitHub Actions workflow
name: Use Python Poetry cache on GitHub Actions workflow
on:
push:
branches:
- main
env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.4.2"
@gh640
gh640 / delete_directory_children.py
Created August 4, 2021 11:43
Sample: Delete all items in a directory without deleting the directory itself
import shutil
from pathlib import Path
def delete_directory(path: str):
"""Delete a directory."""
for item in Path(path).iterdir():
if item.is_dir():
shutil.rmtree(item)
else:
@gh640
gh640 / cookie_with_puppeteer.js
Created July 22, 2021 01:42
Sample: Use cookie with Puppeteer