Skip to content

Instantly share code, notes, and snippets.

View sgryjp's full-sized avatar

Suguru Yamamoto sgryjp

View GitHub Profile
@sgryjp
sgryjp / vim-keymaps-i-tend-to-forget.md
Last active August 15, 2023 03:42
Vim keymaps which I tend to forget

Vim keymaps which I tend to forget

This memo is organized according to help files of Vim.

[scroll.txt][scroll.txt]

  • zz (Normal) … Redraw, line [count] at center of window (default cursor line).
  • zl (Normal) … Move the view on the text [count] characters to the right.
  • zL (Normal) … Move the view on the text half a screenwidth to the right.
@sgryjp
sgryjp / julia_redirect_stdout_to_IOBuffer.jl
Last active May 12, 2019 06:07
Redirecting stdout into an `IOBuffer`
"""
redirect_stdout(f::Function, stream::IOBuffer)
```julia
julia> buf = IOBuffer();
julia> redirect_stdout(buf) do
print("Hello, World!")
end
julia> String(take!(buf))
"Hello, World!"
@sgryjp
sgryjp / stopwatch.py
Created December 5, 2018 14:41
Stopwatch to measure code execution time inside a `with` statement.
import time
import statistics
class Stopwatch(object):
"""Stopwatch to measure code execution time.
A Stopwatch object measures execution time of code inside one or more
`with` statements. Using a single object multiple times let it store
timing data every time.
@sgryjp
sgryjp / argparse.bat
Last active February 21, 2023 11:19
Command line option (argument) parsing example for Windows batch file.
:: Command line option (argument) parsing example
::
:: Written by Suguru Yamamoto
:: <https://gist.github.com/sgryjp/045989b0f6f0089a24f257d74b8a60bd>
:: LICENSE: Public Domain
@echo off
setlocal enableextensions
:: Parse arguments
set _LEVEL=0
@sgryjp
sgryjp / windows10.mintty
Created September 26, 2017 15:51
New Windows console color scheme for MinTTY
ForegroundColour = 204, 204, 204
BackgroundColour = 12, 12, 12
CursorColour = 204, 204, 204
Black = 12, 12, 12
BoldBlack = 118, 118, 118
Red = 197, 15, 31
BoldRed = 231, 72, 86
Green = 19, 161, 14
BoldGreen = 22, 198, 12
Yellow = 193, 156, 0
@sgryjp
sgryjp / strcopy_test.go
Last active September 1, 2017 00:41
Golang: Performance test of string variable copy
package main
import "testing"
import "strings"
import "fmt"
type StructWithString struct {
Str string
}