Skip to content

Instantly share code, notes, and snippets.

View yowcow's full-sized avatar
💮
Job well done

Yoko OYAMA yowcow

💮
Job well done
View GitHub Profile
@yowcow
yowcow / gpg-examples.mk
Last active February 2, 2021 07:16
GPG encrypt/decrypt/sign/verify
RECIPIENT := [email protected]
all:
encrypt: _output/encrypted.txt.gpg.asc
decrypt: _output/decrypted.txt
sign: _output/message.txt.sig.asc
@yowcow
yowcow / debugging-erlang.erl
Created January 19, 2021 02:29
Debugging Erlang application
%% more information available at:
%% * https://erlang.org/doc/man/dbg.html
%% * https://stackoverflow.com/questions/1954894/using-trace-and-dbg-in-erlang
%% start tracer
dbg:tracer().
%% specify what to trace
dbg:p(all, c). %% calls to any of specified functions
dbg:p(all, [c, m]). %% calls and messages
@yowcow
yowcow / memo-on-keyboard-layout.md
Last active June 2, 2020 01:09
キーレイアウトに関するメモ
  • 右手でマウスを操作するので、 ctrl, gui キーは左に置きたい
    • gui キーが押しやすい必要性は高くない
    • gui キーが左に来るなら、 alt は右に置きたい
      • i3wm の modkey を alt にするため
  • 左親指で space を押したい
    • IME 切り替えは ctrl+space だが、 alt+space, gui+space に変えるなどしても良い
  • 右親指で enter を押したい
  • 矢印キー操作は hjkl でやりたいので、このレイヤ切り替えキーは左に置きたい
    • ctrl+矢印 (macOS のワークスペース切り替え) は押しやすくしたい
  • []{} は、レイヤ切り替えが必要なら右側にあるのが良い
@yowcow
yowcow / suckless-terminal-failure.pl
Created May 30, 2020 04:37
suckless terminal rendering failure
use strict;
use utf8;
binmode(STDOUT, ":utf8");
print "\x{1f96b}\n"; # OK
print "\x{1f96c}\n"; # NG
#...
print "\x{1f97b}\n"; # NG
#...
@yowcow
yowcow / capture-matched.sh
Last active December 10, 2019 04:17
AWK regex: capture and print matched pattern that I always forget
cat /path/to/file | awk '$10 ~ /foo/ && match($10, /id=([0-9]+)/, matched) { print matched[1] }
@yowcow
yowcow / find-key.erl
Created November 21, 2019 07:10
finding key existence in erlang
-module(bench).
-export([
run/0
]).
is_valid1(V) ->
V >= 1 andalso V =< 7.
-define(VALID_SET, sets:from_list([1, 2, 3, 4, 5, 6, 7])).
@yowcow
yowcow / list-structs.go
Created October 3, 2019 10:21
Struct scanner
package main
import (
"flag"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io"
"os"
@yowcow
yowcow / scheduler.erl
Created April 25, 2019 10:56
First come first served job scheduler with max concurrency
-module(scheduler).
-export([
run/0
]).
-define(MAX_CONCURRENCY, 3).
run() ->
Msgs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@yowcow
yowcow / build.mk
Created September 6, 2018 09:51
Statically/dynamically cross-compile with CGO enabled/disabled
STATIC := static-app
DYNAMIC := dynamic-app
all: $(STATIC) $(DYNAMIC)
$(MAKE) -f build.mk check FILE=$(STATIC)
$(MAKE) -f build.mk check FILE=$(DYNAMIC)
$(STATIC):
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --ldflags '-extldflags "-static"' -o $@
@yowcow
yowcow / timezone-conv.go
Created July 13, 2018 09:44
Broken timezone on Ubuntu 18.04, Golang 1.10.3
package main
import (
"fmt"
"os"
"time"
)
var format = "2006/01/02 15:04:05"