Skip to content

Instantly share code, notes, and snippets.

@m040601
Forked from biangle/README
Created October 14, 2010 10:19
Show Gist options
  • Save m040601/625986 to your computer and use it in GitHub Desktop.
Save m040601/625986 to your computer and use it in GitHub Desktop.
post file - mecha/yam/ENV
= A submission script for AizuOnlineJudge(AOJ; http://rose.u-aizu.ac.jp/onlinejudge/index.jsp ).
== Requirement
- Ruby1.9.x
- Mechanize (execute '$ gem install mechanize' if you don't have it)
== How to use.
1. Edit submit.auth.yaml with your AOJ id and Password.
2. Place your answer program XXXX.c in the same directory (XXXX is the problem id).
3. $ ruby submit.rb XXXX
4. See the Status page (http://rose.u-aizu.ac.jp/onlinejudge/Status.jsp ) with your browser, submission will be listed on it.
== ATTENTION
This script is unofficial. NO WARRANTY. Use it at your own risk.
== License
Author: Biangle <[email protected]>
License: MIT
userID: YourUserid
password: YourPassword
#!/usr/bin/env ruby
#encoding: utf-8
require 'yaml'
require 'logger'
require 'mechanize'
AOJ_SUBMIT_URL='http://rose.u-aizu.ac.jp/onlinejudge/servlet/Submit'.freeze
YAML_PATH = File.join(File.dirname(File.expand_path(__FILE__)),
'submit.auth.yaml').freeze
if 1 != ARGV.size
warn "usage: ruby #{__FILE__} 0001"
exit 1
end
auth = YAML.load_file(YAML_PATH)
Mechanize.new do |agent|
agent.log = Logger.new(STDOUT)
query = auth.clone
query['problemNO'] = ARGV[0]
query['language'] = 'C'
query['sourceCode'] = File.binread("#{ARGV[0]}.c").chomp
agent.post(AOJ_SUBMIT_URL, query)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment