ruby

Parsing XML with Ruby & Nokogiri

I have the following XML structure: <charsets> <charset> <name>ANSI_X3.4-1968</name> <aliases> <alias>iso-ir-6</alias> <alias>ANSI_X3.4-1986</alias> <alias>ISO_646.irv:1991</alias> <alias>ASCII</alias> <alias>ISO646-US</alias> <alias>US-ASCII</alias> <alias>us</alias> <alias>IBM3...

help with regex

How do I go from this: "01","35004","AL","ACMAR",86.51557,33.584132,6055,0.001499 to this: ACMAR, AL ...

Split an ORDER BY statement into an array

I am attempting to split the ORDER BY statement of a SQL query into an array. First inclination is: order_by.split(',') but that does not work for order by statements like the following: SUBSTRING('test',1,3) ASC, SUBSTRING('test2', 2,2 ) DESC The desired output for the above statement would be: ["SUBSTRING('test',1,3) ASC", "SUB...

What language is this program written in?

This looks like code in the C language, but I am not completely sure ... # define v putchar # define print(x) main(){v(4+v(v(52)-4));return 0;}/* #>+++++++4+[>++++++<-]>++++.----.++++.*/ print(202*2);exit(); #define/*>.@*/exit() ...

Is 'eval' the only way to interact with binding objects in Ruby?

I'm rather new to Ruby, and so far, figuring out how to use "binding" objects is one of the biggest pain points for me. If I'm reading the documentation correctly, they're almost entirely opaque. To access the scope inside the binding object, you have to have a string of Ruby code and eval it using the binding. Maybe I'm just a purist...

How do I convert a Twitter API Pull into an Array in Ruby On Rails?

I am trying to create a stream that includes Twitter data + my app's but I'm having trouble with this because Twitter's data isn't properly coming out as an array. This is my code: answers = Answer.find(:all, :conditions => {:user_id => @user_id }, :limit => 20) tweets = Twitter::Search.new(params[:username]) @feed = (answers + tweets)...

Installing gems tries to load the gems in my custom rake tasks before installing it

I'm developing an application using rails 2.3.5, gitorious and deploy with vlad, the OS is Linux Mint 9 Isadora. vlad:setup and vlad:update are ok. But when I vlad:migrate and have the same error than if I ssh on the server and try a rake gems:install rake aborted! no such file to load -- ya2yaml /var/www/path/to/releases/2010062...

patter matching in ruby 2

i have the value of targetfilename =/mnt/usb/mpeg4Encoded.mpeg4 how this pattren matching if (targetfilename.match(/^\//)) puts "amit" else puts "ramit" the o/p is ramit but how cud anybody help me in figuring out ......

Is there any easy way to toggle "do/end" and "{}" in ruby in Vim?

Is there any easy way to toggle "do/end" and "{}" in ruby in Vim? (TextMate does this with ^{.) ...

how to use one line regular expression to get matched content

I'm a newbie to ruby, I want to know if I can use just one line to do the job. Take the 'search' of this site for example. When user typed [ruby] regex, I can use following code to get the tag and keyword '[ruby] regex' =~ /\[(.*?)\](.*)/ tag, keyword = $1, $2 Can we write it just in one line? UPDATE Thank you so much! May I make...

Installing Cucumber with Ironruby

I'm trying to install Cucumber with ironruby. I followed instructions from http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net . It downloads version 0.8.3 of cucumber and version 2.0.2 of gherkin. When i run cucumber i get the following error: c:/ironruby/lib/ironruby/gems/1.8/gems/gherkin-2.0.2-universal-dotnet/lib/gherki ...

ASP MVC vs Ruby on Rails

Which are the similar features and differences between ASP MVC and RubyonRails? ...

Looking for simple poll/survey Rails plugin or gem

I am trying to find a simple poll plugin/gem (the type of single question poll that's usually found in site's sidebar). All plugins that I've found are either too complex (like having their own DSL) or they are out of date (i.e. older than couple years). Does anyone knows a Rails plugin/gem that handles simple polls? ...

JRuby gem problem

Hi, I am trying to run a rails application in Netbeans with JRuby as the underlying Ruby. When I try to run the server, I got an error like this, Missing these required gems: libxml-ruby So I tried installing the libxml-ruby gem, but I cannot install it because its a native version and jruby would not support it. Thats fine. (in...

What are the advantages of using vim to program Ruby (over Notepad++)? (other languages, too, but specifically Ruby)

I've been using Notepad++ for a while; in fact, I've even started using Launchy for that "load this resource into the editor right now" functionality that many fuller IDE's like Eclipse has. It has syntax highlighting, split window view, code collapsing, parentheses (and other delimiter) paring, automatic indent, block commenting. Howe...

Creating a Ruby on Rails 3 gem with a generator (incl. namespace)

I am trying to create a gem with a generator for Rails 3 (beta 4). I followed these instructions, and but I couldn't get it running. The problem is that when I am defining a module in the generator file, the generator gets listed with 'rails generate', but can't get executed because the generator isn't found. From the instructions (does...

embed vs link on large mongoDB sets (ruby)

Embedded vs link I'm looking for the fastest way to search a Newsletter document for a connected Email. So far I have used MongoMapper with one document for Newsletter and another for Email. This is getting really slow with +100k Emails. I was thinking maybe its faster to embed the emails in an array inside Newsletter since I'm really ...

Returning class type in ruby

I need a function that checks the namespace of the argument, and returns the class type for example: checkType(id) if id starts with "p:" return <Class Type> end I do not have an instance to use when checking the type of the id ...

Ruby Tmail error: undefined symbol: rb_get_kcode

ruby: symbol lookup error: /usr/local/lib/ruby/gems/1.9.1/gems/tmail-1.2.7.1/ext/tmailscanner/tmail/tmailscanner.so: undefined symbol: rb_get_kcode strange error that crash app. ruby 1.9.1 rails 2.3.8 tmail 1.2.7 ...

how to display more records on searching with Thinking_sphinx with rails

Hi, I have updated my searching fields records with thinking_sphinx gem and I have configured it. It is working fine but the problem, It is only displaying 20 records which is default. How to change those thing to make more records visible on view.. ...