Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇦

Goto Hayato gh640

🇺🇦
View GitHub Profile
@gh640
gh640 / func_name.sh
Created May 14, 2022
Zsh / Bash: Getting the current function name invoked
View func_name.sh
function func_name {
case "${SHELL}" in
*/bash)
# Bash
echo ${FUNCNAME[2]}
;;
*/zsh)
# Zsh
echo ${funcstack[2]}
;;
@gh640
gh640 / pyproject.toml
Created Mar 16, 2022
How to make project private with Python Poetry
View pyproject.toml
[tool.poetry]
name = "mypackage"
version = "0.1.0"
description = ""
authors = []
classifiers = [
"Private :: Do not Upload"
]
@gh640
gh640 / Dockerfile
Last active Feb 5, 2022
Sample: Convert `.mov` file to `.gif` animation
View Dockerfile
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 Jan 22, 2022
サンプル: HTML で基本的な要素のスタイルのチェックに使用するためのテンプレート
View html-style-dictionary-ja.html
<!DOCTYPE>
<html>
<head>
<title>スタイルディクショナリ</title>
</head>
<body>
<h1>スタイルディクショナリ</h1>
<h2>共通</h2>
@gh640
gh640 / asyncio_streaming_example.py
Created Dec 12, 2021
Python: Stream output of `asyncio.create_subprocess_exec()`
View asyncio_streaming_example.py
"""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 May 22, 2022
Sample: Use Python Poetry cache on GitHub Actions workflow
View use_python_poetry_cache_on_github_actions_workflow.yml
name: Use Python Poetry cache on GitHub Actions workflow
on:
push:
branches:
- main
env:
PYTHON_VERSION: 3.9
POETRY_VERSION: 1.1.7
@gh640
gh640 / delete_directory_children.py
Created Aug 4, 2021
Sample: Delete all items in a directory without deleting the directory itself
View delete_directory_children.py
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 / gist:2490ab98144bc52b5938dcd7f7026d3a
Created Jul 22, 2021
Sample: Use cookie with Puppeteer
View cookie_with_puppeteer.js
@gh640
gh640 / Dockerfile
Created Jun 20, 2021
サンプル: Debian 10 (buster) で言語設定を UTF-8 で日本語にする
View Dockerfile
FROM debian:buster
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
locales && \
rm -rf /var/lib/apt/lists/*
RUN localedef -f UTF-8 -i ja_JP ja_JP.UTF-8
@gh640
gh640 / use_different_debugger_with_python3.sh
Last active Jun 20, 2021
Running IPython or bpython with `breakpoint()` on Python 3
View use_different_debugger_with_python3.sh
#!/usr/local/bin/bash
# Use IPython.
PYTHONBREAKPOINT=IPython.terminal.debugger.set_trace python myscript.py
# Use bpython.
PYTHONBREAKPOINT=bpdb.set_trace python myscrippt.py