Skip to content

Instantly share code, notes, and snippets.

View yoichi's full-sized avatar

Yoichi NAKAYAMA yoichi

View GitHub Profile
@yoichi
yoichi / init.el
Created February 26, 2023 02:50
EDITOR='emacsclient -t' とか EDITOR='emacsclient -c' で git commit -a した時に意図しない差分が表示されるのを回避
;; EDITOR='emacsclient -t' とか EDITOR='emacsclient -c' で
;; git commit -a した時に意図しない差分が表示されるのを回避
(defun magit-commit-diff-with-frame-environment ()
(let ((process-environment
(append process-environment
(frame-parameter nil 'environment))))
(magit-commit-diff)))
(with-eval-after-load 'magit-commit
(remove-hook 'server-switch-hook #'magit-commit-diff)
(add-hook 'server-switch-hook #'magit-commit-diff-with-frame-environment))
@yoichi
yoichi / understanding-git-stash.ipynb
Created August 28, 2021 01:54
Understanding git stash
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
import argparse
import base64
import hashlib
import hmac
import os
def match(line, hostname):
host_str = line.split(' ')[0]
@yoichi
yoichi / split_characters.ipynb
Created July 8, 2021 02:50
split_characters.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
' Create Zoom Meeting shortcut
Option Explicit
Dim meetingId
meetingId = InputBox("Enter Meeting ID")
If IsEmpty(meetingId) Or meetingId = "" Then
WScript.Quit
End If
Dim passCode
:: Create Zoom Meeting shortcut
:: If you have your organization's domain name, rename this file as follows:
:: create_zoom_shortcut_{domain}.bat
echo off
:: file name without extension
set SCRIPT_NAME=%~n0
:: remove "create_zoom_shortcut_"
set DOMAIN=%SCRIPT_NAME:~21%
"""Convert truecolor escape sequence to 256 color escape sequence
* \x1b[38;2;{red};{green};{blue}m -> \x1b[38;5;{color}m (foreground)
* \x1b[48;2;{red};{green};{blue}m -> \x1b[48;5;{color}m (background)
where 0 <= red, green, blue <= 255 represents 24-bit color
and 16 <= color <= 231
The logic is based on the colour_find_rgb() in tmux/colour.c
Original copyright notice is:
# Gitのデータ構造についての入門演習
# 履歴管理について
# 三種類のGitオブジェクト commit, tree, blobが現れます。
mkdir git-test-repository
cd $_
git init
ls .git
find .git/objects -type f
#!/usr/bin/env bash
# usage:
# git-list-conflicts.sh
# git-list-conflicts.sh branch-name
# git-list-conflicts.sh revison-begin..revision-end
git log --merges --pretty=tformat:%H $@ | while read COMMIT ; do
PARENTS=$(git log -1 --pretty=tformat:%P ${COMMIT})
git checkout ${COMMIT}~1 2>/dev/null
git merge --no-commit $(echo ${PARENTS} | cut -f 2- -d" ") >/dev/null 2>&1
if [ $? -ne 0 ]; then
@yoichi
yoichi / lifegame.py
Created November 17, 2018 14:04
グライダー銃
import time
import curses
def count(data, x, y):
c = 0
if x > 0:
c += data[x-1][y]
if y > 0:
c += data[x-1][y-1]
if y < len(data[x]) - 1: