Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 11, 2009 03:33
Show Gist options
  • Save mattn/77290 to your computer and use it in GitHub Desktop.
Save mattn/77290 to your computer and use it in GitHub Desktop.
dan the shell
require "readline"
require 'json'
require 'cgi'
require 'open-uri'
while buf = Readline.readline("dan> ", true)
res = open("http://api.dan.co.jp/perleval.cgi?c=callback&s=#{CGI.escape(buf)}")
if /^callback\((.*)\)/ =~ res.read
puts JSON.parse($1)['result']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment