Skip to content

Instantly share code, notes, and snippets.

View brianjriddle's full-sized avatar

Brian Riddle brianjriddle

View GitHub Profile
#!/usr/bin/env ruby
require 'java'
module Polopoly
include_package "com.polopoly.cm"
include_package "com.polopoly.pear"
end
if ARGV.empty? or not ARGV.length == 2
puts "usage: #{__FILE__} PATH_TO/polopolyclient.properties contentid "
else
require 'java'
require File.expand_path "lucene-core-1.9.1.jar"
module Lucene
include_package "org.apache.lucene.index"
include_package "org.apache.lucene.store"
include_package "org.apache.lucene.analysis.standard"
end
if ARGV.length == 1
writer = Lucene::IndexWriter.new(Lucene::FSDirectory.getDirectory(ARGV[0], false), Lucene::StandardAnalyzer.new, false)
<target name="compile-jsp" depends="compile" description="precompile jsp">
<java classname="com.caucho.jsp.JspCompiler" fork="true" failonerror="true">
<classpath refid="resin.classpath" />
<arg line="-app-dir ${src.web.dispatcher.dir} ${src.web.dispatcher.dir}" />
</java>
<delete>
<fileset dir="${src.web.dispatcher.dir}/WEB-INF/work"/>
<fileset dir="${src.web.dispatcher.dir}/WEB-INF/tmp"/>
</delete>
</target>
require 'rubygems'
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://www.recept.nu/veckomatsedel'))
week_10 = doc.xpath('//div[@class="box-orange-content related-material"]/div/a')[0]
puts week_10
require 'rubygems'
require 'open-uri'
require 'json'
require 'nokogiri'
days = ['Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag']
week = []
doc = Nokogiri::HTML(open('http://www.recept.nu/veckomatsedel'))
doc.css('div.teaser-list.three-pack')[0..4].each_with_index do |div, i|
#
#monkey patch fix from rack 1.20 to remove escaping of " and '
#from parameters.
#
#following from rack 1.20 is removed i the funciotns in this
#file
#
#if v =~ /^("|')(.*)\1$/
# v = $2.gsub('\\'+$1, $1)
#end
/**
* Finish a response.
*/
public void finishResponse() {
try {
if (writer != null) {
writer.close();
} else if (outputStream != null) {
outputStream.close();
}
@brianjriddle
brianjriddle / polopoly_solr_indexer.rb
Created October 28, 2010 06:37
jruby script to index up our polopoly content. Creates a client and calls a method. Most of the skript is setting up the classpath.
# sets up classpath needed to run the script, notice that commons-httpclient-3.1.jar
# need come before jbossall-client.jar as the jboss jar includes an
# older httpclient and will not work with solr
require 'java'
module Polopoly
polopoly_libs = ["/install/lib/servlet.jar",
"/install/lib/polopoly.jar",
"/install/lib/polopoly-community.jar",
import org.junit.*;
import static org.junit.Assert.*;
public class OneFailsOnePasses {
@Test
public void testItFails() {
fail();
}
python run.py -a 50 -d 300 -x api4-testcases.xml