Skip to content

Instantly share code, notes, and snippets.

View atotto's full-sized avatar
🌏
Working from home

Ato Araki atotto

🌏
Working from home
View GitHub Profile
// $ go tool vet *.go
package main
import (
"fmt"
)
func main() {
//fmt.Printf("hello %s", "世界")
@atotto
atotto / chan_test.go
Created March 4, 2014 09:13
golang channel benchmark
package chan_test
import (
"testing"
)
func BenchmarkStructChan(b *testing.B) {
ch := make(chan struct{})
go func() {
for {
package append_test
import "fmt"
func ExampleArrayToSlice() {
arr := []string{"a", "b", "c"}
//arr = append(arr, arr) // Compile error : cannot use arr (type []string) as type string in append
arr = append(arr, arr...)
package example_test
import (
"fmt"
"log"
"os"
"testing"
"text/scanner"
)
@atotto
atotto / README.md
Last active August 29, 2015 14:04
Set-User-ID Programs

Set-User-ID Programs

Advanced Programming in the UNIX® Environment Third Edition

SS 8.13

$ go build tsys.go
$ sudo chmod u+s tsys
@atotto
atotto / testmain_example_test.go
Created December 19, 2014 12:38
go1.4 TestMain example
package example_test
import (
"os"
"testing"
)
func TestA(t *testing.T) {
}
@atotto
atotto / main.go
Created February 19, 2015 14:15
parallel
// http://play.golang.org/p/cwMSE2imEN
package main
import (
"errors"
"fmt"
"sync"
)
func main() {
@atotto
atotto / Dockerfile.godoc
Created July 14, 2015 03:23
godoc docker container
FROM golang:1.5
MAINTAINER gophers
ENV GOPATH=/workspace
ENV PATH=$GOPATH/bin:$PATH
RUN mkdir /workspace
RUN ["go", "version"]
EXPOSE 6060
@atotto
atotto / goversion.bash
Created October 8, 2015 02:59
print go version from built binary
#!/bin/bash -e
# usage
# $0 path/to/go/built/binary
usage() {
echo "Usage"
echo " $0 path/to/go/built/binary"
exit 2
}
@atotto
atotto / fan-ctrl.sh
Last active May 26, 2017 00:24
fan control using hub-ctrl
#!/bin/sh
# $ wget http://www.gniibe.org/oitoite/ac-power-control-by-USB-hub/hub-ctrl.c
# $ gcc -O2 -o hub-ctrl hub-ctrl.c -lusb
# $ sudo chown root:$USER hub-ctrl
# $ sudo chmod +s hub-ctrl
# $ mv hub-ctrl ~/bin
usage() {
echo "Usage: $0 (on|off)"