ruby

do ruby plugins make starting vim very slow?

Lately vim takes a long time to start up when I'm running it to edit a ruby file or a rails project. But it starts up fast when invoked on a plain text file. Is there any way to find out which ruby vim plugins are most responsible for prolonging the startup? ...

Why does Ruby module inclusion exclude the module's singleton class?

When classes are inherited in Ruby the singleton classes are also inherited: class A def self.hello puts "hello" end end class B < A end B.hello #=> "hello" Yet with modules, this is not the case: module M def self.goodbye puts "goodbye" end end class A include M end A.goodbye #=> NameError To get around this ...

How can I extract a variable number of sub-matches from a Ruby regex?

I have some strings that I would like to pattern match and then extract out the matches as variables $1, $2, etc. The pattern matching code I have is a = /^([\+|\-]?[1-9]?)([C|P])(?:([\+|\-][1-9]?)([C|P]))*$/i.match(field) puts result = #{a.to_a.inspect} With the above I am able to easily match the following sample strings: "C",...

Ruby/Python - generating and parsing C/C++ code

Hi, I need to generate C structs and arrays from data stored in a db table, and alternately parse similar info. I use both ruby and python for this task, and was wondering if anyone heard of a module/lib that handles this for either/both languages? I could do this on my own with some string processing, but wanted to check if there's a k...

rails, pass arguments in when setting a new object

Hello, In rails, is it possible to pass arguments in when making a new object, and set some values accordingly? For example, if I have a screen with a list of items, and a link to make a new item at the top. If I were to put a drop-down list of "item types" beside the "new" link, how would I pass that value to the new function on the ...

DB table getting too much data - need another solution

I have a site where people can add their favorite TV series. There is one feature that makes it possible to check off episodes that you have seen. Each episodes that is checked off, creates one record in a DB table (with user_id, show_id and episode_id). This table is now over 600.000 rows and is growing very fast! I have indexes set u...

New to Ruby on Rails

Hi, I'm new to Ruby on Rails and was hoping people can assist with the following: 1) Tutorials for the complete newb to RoR? 2) How to get RoR up and running on Mac OS X (10.5.8) - where and how to install? 3) Can RoR work with an Oracle 10g backend and if so, how? Would really appreciate your help on the above. Thanks. ...

In ruby, can you execute assert_equal and other asserts while in irb?

Can you execute assert_equal from within irb? This does not work. require 'test/unit' assert_equal(5,5) ...

transfer db from one heroku app to another faster

Is there a faster way to transfer my production database to a test app? Currently I'm doing a heroku db:pull to my local machine then heroku db:push --app testapp but this is becoming time consuming. I have some seed data but it is not nearly as accurate as simply testing with my real-world data. And since they're both stored on a nei...

Install hpricot on Mac OS X with rvm and brew

Having problems installing hpricot on Mac OS X. I suspect it might be an issue between rvm and brew? rvm 1.0.5 brew 0.7 Thoughts? Suggestions? Thanks! $ gem install hpricot Building native extensions. This could take a while... ERROR: Error installing hpricot: ERROR: Failed to build gem native extension. /Users/dhaskin/.rvm/...

Why not use object literals to create beautiful DSL in Javascript?

Coming from Ruby to Javascript, creating DSL now seems not as fun as in Ruby where it was very beautiful and elegant. Ruby Rake: task :hello do # do stuff end task :hello => [:dep1, :dep2] do # do stuff end Javascript Jake: task("hello", function() { // do stuff }); task("hello", ["deep1", "deep2"], function() { // do ...

how does RoR local give you such a nice API like: layout.side.title ?

How does the RoR localization engine take a .yaml file and produce such a nice API to access the localized text like: layout.side.title What kind of class is it that you can just create a recursive style of property accessors? ...

What is up with my gems?

ok so i installed a gem and then ran script/server and for some reason its still telling me the gem is not installed sudo gem install paypal_adaptive Successfully installed paypal_adaptive-0.1.0 1 gem installed matt@macBookPro ~/Sites/somesite[master (Time to Commit)]$ script/server => Booting WEBrick => Rails 2.3.8 application startin...

In rails, where to put a constant (variable?) that changes based on the current date?

I have an app that heavily relies on dates. There is a moderately expensive calculation that is needed to set these dates, based on the current date. As far as each request is concerned, these dates are constants -- they don't change once created -- but they do change throughout the week. The dates are used in both controllers and models...

Using Drupal and Ruby. Has anyone integrated both?

Hi, I started a small web project and used Drupal to build it. So far, so good: you can quickly set up a nice CMS oriented site, add social features via modules, and you have an extensive API to do the customizations in a nicely architected platform. The problem comes now: the site is growing beyond what was originally planned and I fi...

Dropbox API - Dropbox ruby gem (Tim Morgan): How to authorize

I want to write a ruby app for personal use that access my personal dropbox through their API. I'm using Tim Morgan gem 'dropbox' version 1.1.1 What I don't understand is the difference between a developer_key and a consumer_key. The gem docs say that I have to use the consumer_key, but when I registered my app on dropbox.com I received ...

Ruby + Nokogiri: Expand all class="..." attributes to style="..."

Hi. I'm parsing forum threads with Nokogiri and putting them on RSS feed (forum itself doesn't have RSS or any other kind of news feeds), the problem I've encountered is following: elements are styled with CSS classes and via selectors in forums style file included in the page, I can't include it into news feed so I want to replace all...

Ruby: How do I send a JSON POST request using Curb?

How can I set the request body of a CURB request to be my json string? I am trying to do a JSON POST request using Curb. My code: require 'rubygems' require 'curb' require 'json' myarray = {} myarray['key'] = 'value' json_string = myarray.to_json() c = Curl::Easy.http_post("https://example.com" # how do I set json_string to be...

can't get ruby-debug on windows

Can't get ruby-debug engaged for rails 3.0 1) when I do a "gem list ruby-debug" I get: $ gem list ruby-debug * LOCAL GEMS * ruby-debug (0.10.3) ruby-debug-base (0.10.3 mswin32) ruby-debug-ide (0.4.5) 2) when I run "rails server --debugger" I get: c:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.2/lib/bundler/resolver.rb:132:in resolve...

Ruby Garbage Collection Heap Slot size

So, ruby enterprise documentation states that all the values in the GC settings are defined in slots: http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning (e.g. RUBY_HEAP_MIN_SLOTS) We fine-tuned our app's min slot size and increment for the best performance by trial and error (we have enough ma...