Skip to content

Instantly share code, notes, and snippets.

@reiki4040
reiki4040 / close_channel_messages.go
Created April 2, 2021 14:59
closed channel is not also send message to receivers only once but send to channel until release all receivers or program finished.
package main
import (
"fmt"
"time"
)
/*
closed channel is not also send message to receivers only once
but send to channel until release all receivers or program finished.
@reiki4040
reiki4040 / main.go
Created July 2, 2017 13:51
post slack with apex-go
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
@reiki4040
reiki4040 / inventory_replcacer.go
Created March 10, 2017 15:09
replace inventory file block for tool.
package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"strings"
)
@reiki4040
reiki4040 / genpr.sh
Created March 8, 2017 12:44
auto generate pull request sample.
#!/bin/bash
function usage() {
cat <<_EOB
Create Pull Request that homebrew-rnzoo for new version.
Usage:
$(basename $0) <version> <sha256hash>
_EOB
}
@reiki4040
reiki4040 / rune_count_in_string_bench_test.go
Created December 17, 2014 14:53
benchmark utf8.RuneCountInString()
package benchrunecount
import (
"testing"
"unicode/utf8"
)
func BenchmarkRunCountInString16ascii(b *testing.B) {
str := "abcdefghijklmnop"
for i := 0; i < b.N; i++ {
@reiki4040
reiki4040 / validator.go
Created December 1, 2014 14:47
validation memo
package main
import (
"errors"
"fmt"
"net/url"
"reflect"
"strconv"
"strings"
)
@reiki4040
reiki4040 / signal.go
Created October 2, 2014 14:38
signal handling example for golang
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@reiki4040
reiki4040 / variable_arguments.py
Created September 15, 2014 11:15
example variable arguments for python.
import sys
def PrintStrings(*strings):
for s in strings:
sys.stdout.write(s)
print
def main():
PrintStrings("a", "b", "c")
@reiki4040
reiki4040 / variable_arguments.go
Created September 15, 2014 10:54
example variable arguments for golang
package main
import (
"fmt"
)
func PrintStrings(strings ...string) {
for _, s := range strings {
fmt.Printf("%s", s)
}
@reiki4040
reiki4040 / memo_bashrc
Created April 6, 2014 10:10
.bashrc memo
# alias
alias ls='ls -G'
alias ll='ls -l'
alias la='ls -lA'
alias ..='cd ..'
alias grep='grep --color'
# git completion
if [ -f /usr/local/etc/bash_completion.d/git-prompt.sh ]; then
. /usr/local/etc/bash_completion.d/git-prompt.sh