Skip to content

Instantly share code, notes, and snippets.

View hymkor's full-sized avatar

HAYAMA_Kaoru hymkor

View GitHub Profile
@hymkor
hymkor / main.go
Created April 8, 2024 10:38
background worker while key-in
func until(cond func(), work func() bool) {
endSig := make(chan struct{})
go func() {
for {
select {
case <-endSig:
return
default:
if !work() {
<-endSig
function getUsage(command)
print("$ " .. command)
local subcommand = {}
local fd = assert(io.popen(command))
for line in fd:lines() do
local m = string.match(line,"^ ([a-z][-a-z]+)")
if m then
subcommand[m] = {}
end
end
@hymkor
hymkor / xfer.txt
Created June 6, 2022 02:16
My configuration for AutoHotKey
#If WinActive("ahk_exe chrome.exe")
|| WinActive("ahk_exe msedge.exe")
|| WinActive("ahk_exe thunderbird.exe")
|| WinActive("ahk_exe firefox.exe")
|| WinActive("ahk_exe ONENOTE.EXE")
|| WinActive("ahk_class Framework::CFrame")
|| WinActive("ahk_exe onenoteim.exe")
|| WinActive("ahk_exe skype.exe")
|| WinActive("ahk_exe excel.exe")
|| WinActive("ahk_exe MSACCESS.EXE")
nyagos.complete_for["make"] = function(args)
local target = {}
local fd=io.open("Makefile","r")
if fd then
for line in fd:lines() do
local m =string.match(line,'^([^:\t%s]+)%s*:')
if m then
target[1+#target] = m
end
end
@hymkor
hymkor / scrapbox.go
Created March 25, 2020 05:35
scrapbox.ioのエクスポートJSONをプレーンテキスト(UTF8)に展開するやつ (1ページ1ファイルにする時は-dオプションでディレクトリを指定する)
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@hymkor
hymkor / go4nyagos.lua
Created January 13, 2020 10:58
go sub-command completion for nyagos
nyagos.complete_for.go = function(args)
if #args == 2 then
return {
"build", "clean", "doc", "env", "fix", "fmt", "generate",
"get", "install", "list", "mod", "run", "test", "tool", "version",
"vet"
}
end
return nil
end
@hymkor
hymkor / git4nyagos.lua
Last active January 13, 2020 10:56
git sub-command completion for NYAGOS
nyagos.complete_for.git = function(args)
while #args > 2 and args[2]:sub(1,1) == "-" do
table.remove(args,2)
end
if #args == 2 then
return nyagos.fields([[
add fsck-objects rebase
add--interactive gc receive-pack
am get-tar-commit-id reflog
annotate grep relink
@hymkor
hymkor / hangup.txt
Created October 1, 2019 01:30
キーボード入力待機中、急に落ちた。なんでじゃろ
Exception 0xc0000005 0x1 0xc0004b0008 0x7721c080
PC=0x7721c080
syscall.Syscall6(0x772651f0, 0x4, 0x1f, 0xc0004831a0, 0x1, 0xc0004b0008, 0x0, 0x0, 0x0, 0x0, ...)
C:/go/src/runtime/syscall_windows.go:197 +0xfa
syscall.(*Proc).Call(0xc000362100, 0xc0004831c0, 0x4, 0x4, 0x20, 0x6ee280, 0x9dc501, 0xc0004831c0)
C:/go/src/syscall/dll_windows.go:177 +0x375
syscall.(*LazyProc).Call(0xc00007b350, 0xc0004831c0, 0x4, 0x4, 0x40c5df, 0x20, 0x720c80, 0x9f7201)
C:/go/src/syscall/dll_windows.go:328 +0x66
github.com/mattn/go-tty.readConsoleInput(0x1f, 0xc0004831a0, 0x0, 0x0)
@hymkor
hymkor / make.cmd
Created September 29, 2019 07:10
Goの amd64/386 , windows/linux のバイナリパッケージを全部作るバッチファイル
@setlocal
@set "PROMPT=%0> "
@call :"%1"
@endlocal
@exit /b
:""
:"package"
for %%I in (386 amd64) do call :package1 windows %%I .exe
for %%I in (386 amd64) do call :package1 linux %%I
@hymkor
hymkor / sqldbtest.go
Created September 27, 2019 05:39
SQL Server へ接続してみるテスト(業務ワードは「...」に書き換えたので、修正が必要です)
package main
import (
"context"
"database/sql"
"fmt"
_ "github.com/denisenkom/go-mssqldb"
)