Skip to content

Instantly share code, notes, and snippets.

View nakagami's full-sized avatar

Hajime Nakagami nakagami

View GitHub Profile
@nakagami
nakagami / gitgraph.md
Last active October 20, 2025 02:32
devブランチで確認して mainブランチを本番に反映するコミットグラフの例

dev で開発環境で確認して mainブランチを本番に反映する。dev ブランチには本番に反映してはいけない雑多なブランチが含まれる。

  • dev: 開発用ブランチ
  • main: 本番用ブランチ
graph TD
    A[main] --> B[dev]
    A[main] --> C[topic]
    C --> D[topic: Commit]
    A --> E[main]
 D --> |①| B
@nakagami
nakagami / gio-glfw.go
Created August 25, 2025 10:54
gio-glfw sample
// SPDX-License-Identifier: Unlicense OR MIT
// GLFW doesn't build on OpenBSD and FreeBSD.
//go:build !openbsd && !freebsd && !android && !ios && !js
// +build !openbsd,!freebsd,!android,!ios,!js
// The glfw example demonstrates integration of Gio into a foreign
// windowing and rendering library, in this case GLFW
// (https://www.glfw.org).
//
@nakagami
nakagami / paintimage.go
Created May 31, 2025 01:08
go-sdl2 example. Paint RGBA image
package main
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
"image"
"image/color"
"math/rand"
"unsafe"
)
@nakagami
nakagami / scp_upload_donwload_recursive.py
Last active April 7, 2025 02:54
Upload files recursive via scp
# Copy directory recursive to remote SFTP server by scp
# scp use SFTP protocol
# need to install `parammiko` and `scp`
# https://pypi.org/project/paramiko/
# https://pypi.org/project/scp/
import paramiko
import scp
# Change these to their actual values
# Related to https://gist.github.com/nakagami/b822ad3fcb72645f003e639060586be9
# Retain the first element, delete the rest.
# modify attribute
# modify element
import xml.etree.ElementTree as ET
xml_data = '''<?xml version="1.0" encoding="utf-8"?>
<root>
<person id="1">
@nakagami
nakagami / openpyxl_example.py
Last active January 14, 2025 09:43
openpyxl を使うサンプル
# openpyxl のサンプル
# Excel の 1シート目の先頭行の内容を読み取る
# 先頭行の値を 2行目に設定
# B セルを削除
# 出来上がった Excel を bytes データに変換
import io
from openpyxl import load_workbook
author date
Hajime Nakagami<[email protected]>
Sep 27, 2024

Introduction to pyvim

Do you use vim?

I have been using vi clone for over 30 years.

# sudo apt install imagemagick
# pip install matplotlib-backend-sixel matplotlib
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.use('module://matplotlib-backend-sixel')
def plot():
x = np.linspace(0, 1)
@nakagami
nakagami / sixeldraw.py
Last active September 21, 2024 15:10
matplotlib and libsixel draw fig to terminal
# https://qiita.com/bjam_ha_nai/items/609924c91343a12d6769
# sudo apt install libsixel-bin libsixel-dev
# pip install libsixel-python matplotlib
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from libsixel.encoder import Encoder as SixelEncoder
from libsixel import SIXEL_OPTFLAG_WIDTH, SIXEL_OPTFLAG_HEIGHT
from tempfile import NamedTemporaryFile
@nakagami
nakagami / etree_example.py
Last active March 13, 2024 06:26
XML manipuration example
import xml.etree.ElementTree as ET
xml_data = '''<?xml version="1.0" encoding="utf-8"?>
<root>
<person id="1">
<name>John Doe</name>
<age>30</age>
<city>Tokyo</city>
</person>
<person id="2">