Skip to content

Instantly share code, notes, and snippets.

View haya14busa's full-sized avatar
🐶

haya14busa haya14busa

🐶
View GitHub Profile
@haya14busa
haya14busa / ioreader_contain.go
Last active June 19, 2017 15:07
Contains for io.Reader
// https://play.golang.org/p/0CnyWvQ8rY
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"strings"
)
(function() {
function getGoogleCalendarEventID() {
var elm = document.querySelector('div.ep[data-eid]');
if (!elm) {
return;
}
var eid = elm.getAttribute('data-eid');
if (!eid) {
return;
}
command! -nargs=1 BikaBika call s:make_bikabika(<q-args>)
command! -nargs=0 BikaBikaStop call s:stop_bikabika()
highlight! BikaBika ctermbg=green guibg=green
let s:_bika = {}
function! s:make_bikabika(pattern) abort
if !empty(s:_bika)
call s:_bika.stop()
@haya14busa
haya14busa / benchcmp.txt
Created March 28, 2017 03:56
cap and append (old) vs len and assign by index
benchmark old ns/op new ns/op delta
BenchmarkCompileOnepass/^(?:(?:(?:.(?:$))?))$-4 5782 5759 -0.40%
BenchmarkCompileOnepass/^abcd$-4 4831 4974 +2.96%
BenchmarkCompileOnepass/^(?:(?:a{0,})*?)$-4 5616 5636 +0.36%
BenchmarkCompileOnepass/^(?:(?:a+)*)$-4 5239 5201 -0.73%
BenchmarkCompileOnepass/^(?:(?:a|(?:aa)))$-4 6576 6967 +5.95%
BenchmarkCompileOnepass/^(?:[^\s\S])$-4 4090 4100 +0.24%
BenchmarkCompileOnepass/^(?:(?:(?:a*)+))$-4 5520 5652 +2.39%
BenchmarkCompileOnepass/^[a-c]+$-4 4207 4214 +0.17%
BenchmarkCompileOnepass/^[a-c]*$-4 4606 4625 +0.41%
@haya14busa
haya14busa / bench_result.txt
Last active March 12, 2017 12:52
[nit] reduce alloc on commonHeader initialization
# go test -v -bench=. | prettybench
PASS
benchmark iter time/iter bytes alloc allocs
--------- ---- --------- ----------- ------
BenchmarkBefore-4 200000 7609.00 ns/op 4427 B/op 4 allocs/op
BenchmarkAfter-4 500000 3633.00 ns/op 2414 B/op 1 allocs/op
@haya14busa
haya14busa / .git_commit_msg.txt
Created March 1, 2017 15:56
Commit emoji convention
## Commit emoji convention
#
# | emoji | description |
# |--------------------|-----------------------------------------|
# | :memo: | Add comment or doc |
# | :gift: | New feature. |
# | :bug: | Bug fix |
# | :bomb: | Breaking compatibility. |
package main
import (
"testing"
"github.com/kylelemons/godebug/pretty"
)
type ShipManifest struct {
Name string
@haya14busa
haya14busa / patch.diff
Created February 4, 2017 13:55
ignore missing ','
diff --git a/imports/imports.go b/imports/imports.go
index 67573f4..32db0ca 100644
--- a/imports/imports.go
+++ b/imports/imports.go
@@ -124,6 +124,11 @@ func parse(fset *token.FileSet, filename string, src []byte, opt *Options) (*ast
if err == nil {
return file, nil, nil
}
+
+ if err != nil && strings.Contains(err.Error(), "missing ',' before newline in composite literal") {
@haya14busa
haya14busa / 2017-01-28-193616.go
Last active January 30, 2017 00:04
gerrit CommentInput test
package main
import (
"context"
"fmt"
"log"
"golang.org/x/build/gerrit"
)
@haya14busa
haya14busa / lint-throw.go
Last active January 14, 2017 16:06
linter for throw usage in vital.vim
package main
import (
"bytes"
"flag"
"fmt"
"io"
"os"
"strings"