Skip to content

Instantly share code, notes, and snippets.

itchyny itchyny

  • Hatena Co., Ltd.
  • Kyoto, Japan
Block or report user

Report or block itchyny

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View re.js
const opt = (s) => `${group(s)}?`;
const chars = (s) => `[${s}]`;
const group = (s) => /^\[[^\]]+\][*+]$/.test(s) ? s : `(?:${s})`;
const or = (...xs) => xs.join('|');
const many = (s) => group(`${s}*`);
const many1 = (s) => group(`${s}+`);
const integer = or('0', `[1-9]${many('[0-9]')}`);
const name = (n, s) => `(?<${n}>${s})`;
@itchyny
itchyny / go114-regression.md
Last active Apr 8, 2020
Go 1.14の主なregression
View go114-regression.md

Go 1.14 の主なregressionです。1.14.1で修正されると思われます。

@itchyny
itchyny / git-ssh-key.sh
Last active Nov 27, 2019
shell alias to use specific identity file on git push
View git-ssh-key.sh
# Example: git-ssh-key ~/path/to/identity-file git push origin master
git-ssh-key() {
ssh_key=${1:?Usage: git-ssh-key identity-file commands...}
shift
GIT_SSH_COMMAND=" \
ssh -F /dev/null \
-o IdentitiesOnly=yes \
-o IdentityFile=\"$ssh_key\" \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
View seekfile.go
package main
import (
"encoding/binary"
"errors"
"fmt"
"io"
"os"
"strconv"
)
View gist:3cb5a09e190fd1c7da4755d3a51e9a1e
SCRIPT /usr/local/Cellar/vim/8.1.1500/share/vim/vim81/scripts.vim
Sourced 1 time
Total time: 0.001107
Self time: 0.001107
count total (s) self (s)
" Vim support file to detect file types in scripts
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2018 Feb 03
View bf.jq
def skip_loop:
.input[.cursor:.cursor+1] as $c |
.cursor += 1 |
if $c == "[" then .depth += 1 | skip_loop
elif $c == "]" then .depth -= 1 | if .saved_depth > .depth then . else skip_loop end
elif $c == "" then error("unmatching loop")
else skip_loop
end;
def backward_loop:
@itchyny
itchyny / json_format.jq
Created May 10, 2019
JSON formatter written in jq
View json_format.jq
{ source: ., depth: 0, indent: false, first_elem: false, output: "" } |
until(
.source == "";
if .source[:1] | inside(" \t\n\r") then
.source |= .[1:]
else
.output +=
(if .first_elem and (.source[:1] | inside("]}")) then ""
else (if .first_elem then "\n" else "" end) +
(if .indent then " " * .depth
@itchyny
itchyny / main.go
Created Feb 24, 2019
Golang tsort implementation
View main.go
package main
import (
"errors"
"fmt"
"os"
)
type edge struct{ from, to int }
@itchyny
itchyny / atomic-test.go
Created Jan 21, 2019
Atomic write testing in Golang (why this fails on Windows?)
View atomic-test.go
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@itchyny
itchyny / .md
Last active Mar 13, 2018
詰将棋 gif生成
View .md
diff --git a/util/image/generate.go b/util/image/generate.go
index 81c69f7..9635b87 100644
--- a/util/image/generate.go
+++ b/util/image/generate.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"image"
 	"image/color"
+	"image/color/palette"
You can’t perform that action at this time.