Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'mechanize'
agent = Mechanize.new
puts agent.get('http://stackoverflow.com/questions/5023740/mechanize-table-scraping-problem').root().class
@tychobrailleur
tychobrailleur / simple.rb
Created February 26, 2011 15:04
Example of use of JMenuBar
require 'rubygems'
require 'java'
require 'rubeus'
# Rubeus.verbose = true
Rubeus::Swing.irb
JFrame.new('Hello') do
|frame|
frame.layout = BoxLayout.new(:Y_AXIS)
public class MyClass {
public void doStuff() {
System.out.println("hello");
}
}
sebastien@greystones:/tmp$ jruby singleton.rb
hello
world
@tychobrailleur
tychobrailleur / gist:1088835
Created July 18, 2011 08:02
Nokogiri issue
require 'rubygems'
require 'optparse'
require 'nokogiri'
Dir.chdir(ARGV[0])
poms = File.join("**", "pom.xml")
Dir.glob(poms).each do
|p|
puts p
f = File.open(p)
require 'java'
# Update with the name of jar you have downloaded
require 'mysql-connector-java-5.0.8-bin.jar'
Java::com.mysql.jdbc.Driver
# Update the JDBC details as needed
jdbc_url = 'jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8'
login = 'sonar'
@tychobrailleur
tychobrailleur / gitlog.rb
Created December 10, 2011 18:36
Find the first commit of all committers in a git log file
require 'date'
class Commit
attr_accessor :sha_id, :author, :date, :comment
end
commits = Hash.new
commits_number = Hash.new { |k,v| k[v] = 0 }
@tychobrailleur
tychobrailleur / ant output
Created January 4, 2012 16:08
Test Error
install-dev-gems:
[java] Gem.ruby /home/sebastien/dev/jruby/bin/jruby
[java] Gem.bindir /home/sebastien/dev/jruby/bin
[java] INFO: gem "rake" is not installed
[java] INFO: gem "rspec-core" is not installed
[java] INFO: gem "diff-lcs" is not installed
[java] INFO: gem "rspec-expectations" is not installed
[java] INFO: gem "rspec-mocks" is not installed
[java] INFO: gem "rspec" is not installed
[java] Successfully installed rake-0.9.2.2
sebastien@kilkenny:~$ rvm jruby-1.6.5.1
sebastien@kilkenny:~$ ruby strings.rb
user system total real
21 chars 0.448000 0.000000 0.448000 ( 0.401000)
22 chars 0.213000 0.000000 0.213000 ( 0.213000)
23 chars 0.172000 0.000000 0.172000 ( 0.172000)
24 chars 0.201000 0.000000 0.201000 ( 0.201000)
25 chars 0.187000 0.000000 0.187000 ( 0.187000)
26 chars 0.174000 0.000000 0.174000 ( 0.174000)
27 chars 0.170000 0.000000 0.170000 ( 0.171000)
sebastien@kilkenny:~$ rvm jruby-head
sebastien@kilkenny:~$ ruby strings.rb
user system total real
21 chars 0.445000 0.000000 0.445000 ( 0.415000)
22 chars 0.171000 0.000000 0.171000 ( 0.171000)
23 chars 0.160000 0.000000 0.160000 ( 0.160000)
24 chars 0.206000 0.000000 0.206000 ( 0.207000)
25 chars 0.172000 0.000000 0.172000 ( 0.172000)
26 chars 0.174000 0.000000 0.174000 ( 0.174000)
27 chars 0.176000 0.000000 0.176000 ( 0.176000)