Skip to content

Instantly share code, notes, and snippets.

.svn/prop-base/ZipCodeLookUp.java.svn-base:
K 13
svn:eol-style
V 6
native
END
package com.usps.webservice.msg;
public class ResponseWrapper<E> {
private Object response = null;
public ResponseWrapper(E response) {
this.response = response;
}
class Source < ActiveRecord::Base
belongs_to :owner
def self.create_from_pathname(pathname)
source = Source.new({:path => "", :tracename => ""})
end
private
# call-seq
# get_owner_from_svn_log(Pathname("path/to/source.java")) => owner_name
#
# if 'pathname' doesn't exist or there is no commit history then returns nil
def self.get_owner_from_svn_log(pathname)
log = `svn log #{pathname}`
first_commit_time = nil
commits = []
log.each do |line|
commits << [$1, first_commit_time = Time.parse($2)] if line =~ /^\w+? \| (\w+?) \| (.+?) \(.+?\) \| /
# call-seq
# get_owner_from_svn_log(Pathname("path/to/source.java")) => owner_name
#
# if 'pathname' doesn't exist or there is no commit history then returns nil
def self.get_owner_from_svn_log(pathname)
log = `svn log #{pathname}`
first_commit_time = nil
committers = Hash.new(0)
log.reverse_each do |line|
if line =~ /^\w+? \| (\w+?) \| (.+?) \(.+?\) \| /
#!/usr/bin/env ruby
require 'pathname'
require 'lib/database_utils'
DatabaseUtils.establish_connection
def get_owner_or_init_from_svn
unless self.owner
owner_name = Source.get_owner_from_svn_log(self.path)
if owner_name
self.owner = Owner.find_or_create_by_name(owner_name)
self.save!
end
end
return self.owner
end
class Owner < ActiveRecord::Base
belongs_to :owner
# fields: name, fullname, email, phone, owner_id
def self.find_incomplete_owners
Owner.find(:all, :conditions => "fullname is null or email is null")
end
on_data_proc = lambda do |ch, data|
log.puts "out: #{data}"
channel.send_data("yes\n") if data =~ /continue connecting \(yes\/no\)/i
channel.send_data("#{cmds["password"]}\n") if data =~ /Password/i
if data =~ /Last login:/i
log.puts "logged in"
process_cmds(cmds, nest+1, params)
log.puts "processing nested commands finished"
channel.on_data do |ch, data|
on_data_proc.call(ch, data)
@danlynn
danlynn / gist:809103
Created February 3, 2011 05:54
Grouping a list of strings by similarity using Levenshtein string distance
# The Levenshtein distance between two strings is defined as the minimum number
# of edits needed to transform one string into the other, with the allowable
# edit operations being insertion, deletion, or substitution of a single character.
#
# see:
# http://en.wikipedia.org/wiki/Levenshtein_distance
# http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#Ruby
# https://github.com/threedaymonk/text/blob/master/lib/text/levenshtein.rb