Is there a way to take text like below (if it was already in an array or a file) and have it strip the lines with a specified date range?
For instance if i wanted every line from 2009-09-04 until 2009-09-09 to be pulled out (maybe this can be done with grep?) how would I go about doing so?
date,test,time,avail
2009-09-01,JS,0.119,99....
Looking for something similar to xerces for parsing an xml file in ruby. I saw the native processor REXML and another called hpricot (though I can't find any documentation on hpricot, the links all appear to be dead). I'm looking for something that would parse an xml document via SAX2 in ruby.
TIA.
...
I know of the ||= operator, but don't think it'll help me here...trying to create an array that counts the number of "types" among an array of objects.
array.each do |c|
newarray[c.type] = newarray[c.type] ? newarray[c.type]+1 ? 0
end
Is there a more graceful way to do this?
...
I've written some Ruby code to inspect ZIP-files as part of an internal company process. The way we usually launch this code is from a web browser. When you click to download the file, you select "open with" and specify the full path to a small batch file. This one-line batch file looks like this:
\\mathworks\public\Matthew_Simoneau\...
I have backed up a bunch of markdown formatted comments into an XML document. This of course meant I needed to HTMLescape them. When I try to use CGI.unescapeHTML it adds a bunch of strange characters into the markup that do not render well in all browsers.
Specifically, it replaces two spaces with "\302\240 ", but not consistently. ...
In Datamapper, how would one specify the the combination of two fields must be unique. For example categories must have unique names within a domain:
class Category
include DataMapper.resource
property :name, String, :index=>true #must be unique for a given domain
belongs_to :domain
end
...
I want to display different types of objects in the same ajax called controller function. I want to render out when I send back an ajax call. The problem is I want the "title" attribute of one object and the "name" attribute of another object. I can't render 2 partials and can seem to figure out how to check the type of object an object ...
In ruby, I'm able to do
File.dirname("/home/gumby/bigproject/now_with_bugs_fixed/32/FOO_BAR_2096.results")
and get
"/home/gumby/bigproject/now_with_bugs_fixed/32"
but now I'd like to split up that directory string into the components, ie something like
["home", "gumby", "bigproject", "now_with_bugs_fixed", "32"]
Is there a way t...
this is copied from http://www.zenspider.com/ZSS/Products/RubyInline/Readme.html, the "home" of rubyinline, adding/moding as indicated in the comments
require 'rubygems' #added this, doesn't run otherwise
require 'inline'
class MyTest
def factorial(n)
f = 1
n.downto(2) { |x| f *= x }
f
end
inline do |builder|
bui...
Having been spoiled by ruby for so long, I now find myself having to do some Java development (Eclipse RCP). I'm wondering if anyone knows of alternatives to HashMap & ArrayList that have some of the sugar of ruby. The verbosity of dealing with an ArrayList of HashMaps drives me bonkers.
I'm also interested in finding other Ruby langua...
It appears that using ActiveRecord (which requires ActiveSupport) messes with the Logger class, resulting in difficulties. This can be seen with some example code:
require 'rubygems'
#require 'activerecord'
require 'logger'
log = Logger.new(STDERR)
log.sev_threshold = Logger::INFO
log.datetime_format = "%Y-%m-%d %H:%M:%S"
log.debug "...
I can't update the rubygems from 1.3.1 to 1.3.5. I've tried the following commands with no luck(logged in as the root)
gem update --system
gem update rubygems
gem update rubygems -v 1.3.5
gem install rubygems-update -v 1.3.5
The response for the first three command is
Updating RubyGems
Nothing to update
while for the last one t...
I'm trying to diff two strings by phrase, similar to the way that StackOverflow diffs the two strings on the version edits page. What would be an algorithm to do this? Are there gems, or other standard libraries that accomplish this?
EDIT: I've seen other diffing algorithms (Differ with Ruby) and they seem to result in the following:
>...
Hi Currently i am working on a rails project . where i have to reload a partial page .
For example Create action
def create
# Some transaction to the database
respond_to do |format|
format.html {render :text => 'Add post' }
format.js
end
end
In my views posts/create.js.rjs i would like to reload the users/...
I'm using the awesome_nested_set plugin in my Rails project. I have two models that look like this (simplified):
class Customer < ActiveRecord::Base
has_many :categories
end
class Category < ActiveRecord::Base
belongs_to :customer
# Columns in the categories table: lft, rgt and parent_id
acts_as_nested_set :scope => :customer_...
I'm trying to install Aptana Studio as Eclipse plugin in Eclipse 3.3 (Europa), and I'm following instructions on this link. However, the recommended update address for Eclipse 3.3 http://update.aptana.com/install/studio/3.2/ returns the following error message:
"Unable to access site: "http://update.aptana.com/install/studio/3.2/" [Serv...
I'm trying to write a plugin that aliases some methods in ActiveRecord in the following fashion:
class Foo < ActiveRecord::Base
include MyOwnPlugin
acts_as_my_own_plugin :methods => [:bar]
def bar
puts 'do something'
end
end
Inside the plugin:
module MyOwnPlugin
def self.included(base)
base.class_eval do
...
I've been searching for a library that can access multiple ssh connections at once, Ruby has a Net::SSH::Multi module that allows multiple ssh connections at once. However I rather prefer coding this in Python, are there any similar SSH module for python?
...
I'm currently working on a system that allows users to reply to notification emails that are sent out (sigh).
I need to strip out the replies and signatures, so that I'm left with the actual content of the reply, without all the noise.
Does anyone have any suggestions about the best way to do this?
...
So I've tried to install net::ssh::multi on mac using gems:
gems install net-ssh-multi
The installation went fine, however when I type:
require 'net/ssh/multi'
it says load error.
I have no idea whats wrong with what I'm doing!
...