Skip to content

Instantly share code, notes, and snippets.

View marklocklear's full-sized avatar

J. Mark Locklear marklocklear

View GitHub Profile
require 'java'
#HTMLUNIT 2.8 jar files
require 'lib/apache-mime4j-0.6.jar'
require 'lib/commons-codec-1.4.jar'
require 'lib/commons-collections-3.2.1.jar'
require 'lib/commons-io-1.4.jar'
require 'lib/commons-lang-2.4.jar'
require 'lib/commons-logging-1.1.1.jar'
require 'lib/cssparser-0.9.5.jar'
require 'htmlunit.rb'
require 'test/unit'
class MyFirstTest < Test::Unit::TestCase
def test_main
webClient = WebClient.new(BrowserVersion::FIREFOX_3)
main_page = webClient.getPage("http://www.asheville-outdoors.com")
#this will simply output all the text on the page...nice for screen scraping
#puts main_page.asText
assert_equal("Asheville-Outdoors.com", main_page.getTitleText)
jlocklear@jlocklear-VirtualBox:~/htmlunit-2.8$ pwd
/home/jlocklear/htmlunit-2.8
jlocklear@jlocklear-VirtualBox:~/htmlunit-2.8$ ls
apidocs htmlunit.rb lib LICENSE.txt test.rb
require 'java'
require 'rubygems'
require 'jdbc/mysql'
module JavaLang
include_package "java.lang"
end
module JavaSql
include_package 'java.sql'
end
@marklocklear
marklocklear / gist:844260
Last active September 25, 2015 01:58
jruby and mysql
require 'java'
require 'rubygems'
require 'jdbc/mysql'
module JavaLang
include_package "java.lang"
end
module JavaSql
include_package 'java.sql'
end
require 'java'
require 'rubygems'
require 'jdbc/mysql'
module JavaLang
include_package "java.lang"
end
module JavaSql
include_package 'java.sql'
end
namespace :db do
desc "populate random data for testing"
task :create_data => :environment do
require 'populator'
require 'faker'
#NOTE These deletions may not work on heroku. You will need to reset/load db for primary key ids to reset
#[Site, Therapist, PatientAuthorization, Patient, Visit].each(&:delete_all)
#user 1
Site.populate 10 do |site|
#controller
def new
@questions = Array.new(3) {Question.new}
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @question }
end
end
def create
@questions = params[:questions].values.collect { |question| Question.new(question) }
<tr>
<td>Choosed the correct software
(Present info professionally)</td>
<input id="results_0_question_id" name="results[0][question_id]" type="hidden" value="3" />
<input id="results_0_student_id" name="results[0][student_id]" type="hidden" value="68" />
<td><input id="results_0_score_0" name="results[0][score]" type="radio" value="0" /></td>
<td><input id="results_0_score_1" name="results[0][score]" type="radio" value="1" /></td>
<td><input id="results_0_score_2" name="results[0][score]" type="radio" value="2" /></td>
<td><input id="results_0_score_3" name="results[0][score]" type="radio" value="3" /></td>
<%= submit_tag 'Submit', :onclick => 'return validate(this)' %><br/>
<script type="text/javascript" charset="utf-8">
function validate() {
var valid = false;
var radio_groups = {}
$(":radio").each(function(){
radio_groups[this.name] = true;
})
for(group in radio_groups){