Skip to content

Instantly share code, notes, and snippets.

View ota42y's full-sized avatar

ota42y ota42y

View GitHub Profile
package main
import (
"fmt"
"net/http"
)
// localhost:8080/ retrun exec folder
// localhost:8088/.... return same name file
// localhost:8080/handler return url path(from handler function)
@ota42y
ota42y / levenshtein_distance.rb
Created July 19, 2015 13:08
Levenshtein distance
# coding: utf-8
def get_cost(d, c1, x, c2, y)
costs = []
if c1 == c2
# 同じ場合
costs << d[y-1][x-1]
end
if c1 != c2
@ota42y
ota42y / least_squares_method.go
Created February 2, 2015 22:59
Golang least squares method
package main
import "fmt"
type Point struct {
x float64
y float64
}
func LeastSquaresMethod(points *[]Point) (a float64, b float64){
@ota42y
ota42y / test.go
Created January 26, 2015 01:54
goの継承テスト
package main
import "fmt"
type If interface{ // PrintDataメソッドを持つインターフェースを定義
PrintData()
}
type MyBase struct {
Count int
type Name = String
colorName :: NamedColor -> Name
colorName c = case c of
Red -> "赤"
Green -> "緑"
Blue -> "青"
main =
print 1
@ota42y
ota42y / go_cron.go
Created September 8, 2014 22:43
github.com/robfig/cronの動作テスト
package main
import (
"fmt"
"github.com/robfig/cron"
"time"
)
func main() {
c := cron.New()
@ota42y
ota42y / go_mongodb.go
Created September 1, 2014 22:51
mongodbにツイートを保存する
package main
import (
"fmt"
"github.com/ChimeraCoder/anaconda"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"net/url"
)
@ota42y
ota42y / go_twitter.go
Created August 31, 2014 02:00
Anacondaを使ってtwitterからツイートを取ってくる
package main
import (
"fmt"
"github.com/ChimeraCoder/anaconda"
"net/url"
)
func showTimeLine(api *anaconda.TwitterApi, v url.Values) {
tweets, err := api.GetUserTimeline(v)
@ota42y
ota42y / http_post_server.coffee
Created August 28, 2014 22:46
When post /hubot/send_message, hubot send message to chat
module.exports = (robot) ->
robot.router.post "/hubot/send_message", (req, res) ->
if not req.body
res.end ""
return
room_name = req.body.room
message = req.body.message
#!/bin/bash
if [ $# -ne 1 ]; then
echo "plese set folder" 1>&2
exit 1
fi
dir=$1
main=${dir%/}
today=`date "+%d.txt"`