Skip to content

Instantly share code, notes, and snippets.

@yukihir0
yukihir0 / gist:8b58666582edf78b6a8c
Last active January 16, 2022 08:47
GolangでHTTPサーバのモック使ってテストを実行する。
package main
import (
"github.com/jarcoal/httpmock"
"io/ioutil"
"net/http"
"testing"
)
func TestHttpMockSample(t *testing.T) {
@yukihir0
yukihir0 / go_bandit_sample.go
Created January 27, 2015 10:13
Golangでバンディットアルゴリズムを実装した。
package main
import (
"./bandit"
"fmt"
"image/color"
"math/rand"
"time"
"code.google.com/p/plotinum/plot"
@yukihir0
yukihir0 / nested-map.go
Last active August 29, 2015 14:13
GolangでネストしたMapを使う。
package main
import (
"fmt"
)
func main() {
data := map[string]map[string]int{
"first": map[string]int{},
}
@yukihir0
yukihir0 / gec.go
Created January 21, 2015 11:30
本文抽出モジュールExtractContentのGolang版を作った。
package main
import (
"fmt"
"github.com/yukihir0/gec"
"io/ioutil"
)
func main() {
src, err := ioutil.ReadFile("sample1.html")
@yukihir0
yukihir0 / perceptron.go
Last active August 29, 2015 14:13
Golangでパーセプトロンを実装した。
package main
import (
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/plotter"
"code.google.com/p/plotinum/plotutil"
"code.google.com/p/plotinum/vg"
"fmt"
"image/color"
)
@yukihir0
yukihir0 / svm.go
Last active August 29, 2015 14:13
GolangでSVMを実装した。
package main
import (
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/plotter"
"code.google.com/p/plotinum/plotutil"
"code.google.com/p/plotinum/vg"
"fmt"
"image/color"
)
@yukihir0
yukihir0 / mecab.go
Last active August 29, 2015 14:13
GolangでMeCabを使う。
input := "すもももももももものうち"
result, err := mecab.Parse(input)
if err != nil {
panic(err)
}
for _, r := range result {
if r.Pos == "名詞" {
@yukihir0
yukihir0 / rss.go
Last active August 29, 2015 14:13
GolangでRSSをパースする。
package main
import (
"fmt"
rss "github.com/jteeuwen/go-pkg-rss"
"os"
)
func main() {
timeout := 5