I'm trying to use Treetop to parse an ERB file. I need to be able to handle lines like the following:
<% ruby_code_here %>
<%= other_ruby_code %>
Since Treetop is written in Ruby, and you write Treetop grammars in Ruby, is there already some existing way in Treetop to say "hey, look for Ruby code here, and give me its breakdown" with...
I have been using the devise gem for rails and I have facebook login system working. My problem is that there is so much going on in the background that I find it difficult to customize this. For example how do I change the path to the page the user is redirects to after the first time facevbook login, not the usual facebook login.
It a...
I have some thinking-sphinx tests that I need to turn off transactions for to prevent mysql locks, but in doing so I break a lot of other tests previously written, so I need to be able to toggle the setting.
I have found similar questions regarding rspec, but none for Test::Unit.
I have tried self.use_transactional_fixtures = false whi...
I have to read some text files with the following content:
\u201CThe Pedlar Lady of Gushing Cross\u201D
In ruby 1.9 terminal, when I create a string with this content:
ruby-1.9.1-p378 > "\u2714 \u2714 my great string \u2714 \u2714"
=> "✔ ✔ my great string ✔ ✔"
In ruby 1.8, I don't get the unicode codes converted to their character...
Can somebody explain why multiplying by 100 here gives a less accurate result but multiplying by 10 twice gives a more accurate result?
± % sc
Loading development environment (Rails 3.0.1)
>> 129.95 * 100
12994.999999999998
>> 129.95*10
1299.5
>> 129.95*10*10
12995.0
...
I am using an S3-like storage server EMC called ATMOS. I have tried to access this server following examples in both the multipart-post gem and the rest_client gem.
The only response I am ever able to receive is "400 - bad request". The server is active and my headers at least appear to be in order.
I just don't know where to turn to ...
Let's say I have a string like so:
"Lorem ipsum de color [post]57[/post]
sit amet [post]103[/post] desectator."
I want to find all occurrences of [post]*[/post] and replace it with the title of the post represented by the number. I'd end up with something like so:
"Lorem ipsum de color Angry Turtle sit
amet Fuzzy Rabit dese...
Hi, I'm a bit stuck on this issue. I'm trying to make a newline using '\n'. I'm opening a file, then replacing the text, then writing it back as an html file:
replace = text.gsub(/aaa/, 'aaa\nbbb')
But this results in:
aaa\nbbb
I'm trying to make do:
aaa
bbb
...
I'm getting this error since I updated to ruby 1.9.2p0 (2010-08-18 revision 29036) & Rails 3.0.1. How can I fix it?
undefined method `getlocal' for Sat, 30 Oct 2010 08:32:42 +0000:DateTime
activesupport (3.0.1) lib/active_support/time_with_zone.rb:75:in `localtime'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/quo...
I am working on the acts_as_taggable_on plugin, but there is something I can't really understand (even if it is just a very simple code line).
puts "before: " + cache.inspect
# cache.delete_if { |key, value| key.id == owner.id TaggableUser id: 1, name: nil>=>["dog"]}
after: {# TaggableUser id: 1, name: nil>=>["dog"]}
My problem is tha...
I need to add a getlocal method to DateTime in Ruby 1.9.2, as per the suggestion on this page. How do I do this? Thanks for reading
...
rake jobs:work works just fine
But RAILS_ENV=development ./script/delayed_job start (or any of its permutations) doesn't work on 1.9.2. I can run it just fine on 1.9.1.
Anyone have a solution for this?
...
I have a timestamp that is in UTC
"2010-10-25 23:48:46 UTC"
I need to convert it into ISO 8601
"2010-10-29 06:09Z"
The documentation is confusing as hell - what is the easiest way to do that?
...
I want to create a new object, passing it some initial values, and then saving to the db and return the saved object.
how can I do this?
example:
create a new user object
initiaze the user.user_age property to 35
save and return the saved object b/c I need access to the user.user_id value.
What's the ruby way of doing this?
...
I have several versions of a Ruby gem installed on my machine. I'm using one version for development, but the other is used for production and deployment, so I need them both. Is there a simple way to specify which version of the gem should be used?
Since they are the same gem, their binary names conflict, and I have to physically remo...
Hi all,
I want to create a ruby extension that uses c. But when I compile it with gcc, I am getting this error:
gcc rubyext.c -orubyext -I /usr/local/include/ruby-1.9.1/
In file included from rubyext.c:1:
/usr/local/include/ruby-1.9.1/ruby/ruby.h:25:25: error: ruby/config.h: No such file or directory
In file included from rubyext.c:1:...
I Know using wmi query "WIN32_product" one can read the list of installed applications but the list is different from add/remove program list under control panel.
Another approach would be to read Software\Microsoft\Windows\CurrentVersion\Uninstall in windows registry?
I am using the following few lines of ruby code to do that but it is...
I just came by the Ruby function
ncbi.esearch_count
Used in a recent post here (regarding the use of the word noval in publications), used to search in pubmed.
And I wonder how can it be done using R (via maybe Rcurl, or other library(XML) functions)?
Thanks.
...
Is there a way for me to scale and image in rmagick where i set the width, and the height auto scales so the image contain the same proportions?
...
Hello Everyone,
I am new to coding and need help understanding what is wrong with my logic and or syntax in the following method... The program is supposed to return the max and min values of an array. My goal was to have two variables (max and min) outside of the method, so that as the method ran through the array the values would get...