2009-10-01から1ヶ月間の記事一覧

Vimのエンコーディングの設定

Vim

fileencodings(複数形)に設定するらしい。 set fileencodings=ucs-bom,utf-8,iso-2022-jp,euc-jp,cp932,utf-16,utf-16leより左にあるエンコーディングがより優先される。ucs-bomは一番先頭にしておくのが吉。

URL短縮サービス j.mp のAPIを呼び出してみた

j.mpのアカウントをとるとAPI KeyがもらえてAPIでURLを短縮できるようになる。 ということで、短縮してみた。 require 'rubygems' require 'net/http' require 'json' require 'uri' class BitLy def initialize(login_id, api_key) @login_id = login_id @a…

はてなブックマークのuser数を取得するRubyスクリプト

書いてみた。 require 'net/http' url = gets.chomp Net::HTTP.start('b.hatena.ne.jp') {|http| /(\d+)\.gif$/ =~ http.head("/entry/image/#{url}")['location'] puts "#{$1.to_i} user(s)" } 使用例: % ruby get_hateb_users.rb http://twitter.com/ 215…

mathTeX

はてなだと数式はmimeTeXで表示できるんだけど、mimeTeXは見た目があんまりきれいじゃないのでmathTeXを使いたい。 If you have trouble installing mathTeX on your own server, a mathTeX web service is currently available. An <img> tag of the form <img src="http://www.forkosh.dreamhost.com/mathtex.cgi?c=\sqrt{a^2+b^2}" alt="" border=0 align=middle>dis…

Minimum Cost Flow

2009-5-19の日記の続きをいつか書こうと思ってたけどいつの間にか10月になってた。とりあえずwikiに要約を書いたのでそこにリンク。http://mono.kmc.gr.jp/~nojima/wiki/index.php?MinimumCostFlow