2011/05/20


4chan BBS - Genius sorting algorithm: Sleep sort
http://dis.4chan.org/read/prog/1295544154
常識を覆すソートアルゴリズム!その名も"sleep sort"! - Islands in the byte stream
http://d.hatena.ne.jp/gfx/20110519/1305810786
Sleep sort with AnyEvent - TokuLog 改メ tokuhirom’s blog
http://d.hatena.ne.jp/tokuhirom/20110519/1305814594
こういうのはGoが得意分野だよね。 package main

import (
    "os"
    "strconv"
    "syscall"
)

func main() {
    args := os.Args[1:]

    done := make(chan int64)
    for _, arg := range args {
        i, _ := strconv.Atoi64(arg)
        go func(i int64) {
            syscall.Sleep(i * 1e9)
            done <- i
        }(i)
    }
    for _ = range args {
        println(<-done)
    }
}
Posted at by



2011/05/13


vimキチの皆さんこんばんわ。今日もvimscript書いてますか?

今日はGoogle TasksのAPIが公開されたので、Google Tasksをvimから操作出来るvimscriptを書いてみました。
今回はoauth2で、client認証方式を取りました。Twitterの様な認証方式になります。
いつものごとく、bundleディレクトリに放り込んで
:GoogleTasks と実行するとブラウザが起動して
googletasks1
という画面が出るので、テキストボックスの中身をコピーしてvim上の CODE: という部分に張り付けます。
すると
googletasks2
こんな風に一覧が表示され(初めて使う人は空っぽです)、メニューのキーをタイプします。
後は画面操作に従えば、登録・更新・削除・参照が出来ます。またeをタイプするとvim上で編集でき、":w"で書き込めます。
なお、タスク期限やタスク完了フラグの更新はまだ出来てません。とりあえず動いたよ!って所です。
動作にはwebapi-vimの最新版が必要です。
よかったら遊んでみて下さい。
mattn/webapi-vim - GitHub

Vim Interface to Web API

https://github.com/mattn/webapi-vim
mattn/googletasks-vim - GitHub

This is vimscript for googletasks

https://github.com/mattn/googletasks-vim
Posted at by



2011/05/12


以前、githubにsshポートが通らなくてもpush出来る方法をご紹介しましたが、今日はbitbucketです。
bitbucketは元々https経由でpush出来ますが、sshプロトコルを使わない場合はbasic認証になってしまいパスワードを毎回尋ねられます。またそれを省略しようと思うと、Clone URLを hg clone https://username:password@bitbucket.org/username/example といった感じにしなければならなく、とても危険です。
出来る事ならばsshを使いたいですね。実はgithubと方法はまったく同じ。
bitbucketのアカウントページにid_rsa.pubの値を貼り付け、ssh/configファイルを修正します。

~/.ssh/config Host bitbucket.org
    Port 443

もしプロキシを使っておられるなら、ココにあるconnectを.ssh内に置き Host bitbucket.org
    Port 443
    ProxyCommand /home/mattn/.ssh/connect -h bitbucket.org 443
とすればOK。後はpushしまくれ。
Posted at by