The first parser generator I've worked with was Parse::RecDescent, and the guides/tutorials available for it were great, but the most useful feature it has was it's debugging tools, specifically the tracing capabilities ( activated by setting $RD_TRACE to 1 ). I am looking for a parser generator that can help you debug it's rules.
The t...
I tried to uninstall datamapper using the command gem uninstall dm-core.
But it seems that a whole bunch of dependent gems also need to be uninstalled.
C:\>gem uninstall dm-core
You have requested to uninstall the gem:
dm-core-0.9.11
dm-migrations-0.9.11 depends on [dm-core (= 0.9.11)]
dm-cli-0.9.11 depends on [dm-core (= 0.9...
I was just about to install a Ruby gem by someone I hadn't heard of. But something made me think "Who is this guy?". Is there any risk of a Ruby gem accessing private data on your machine and transmitting it elsewhere - since the gem system has Internet access? Or are there protections against this?
...
Is it possible to implement the ?? operator in Ruby?
a = nil
b = 1
x = a ?? b # x should == 1
x = b ?? 2 # x should == 1
...
I would like users of my ruby on rails app to be able to upload documents (Word Documents, Spreadsheets, PDFs, etc). What is the best way of doing this?
...
Hey guys!
Im a beginner in Merb, so want to know, what is the best practices to cache data?
For example i have a page that shows list of books, that changes not really often, so im looking for a way to cache the data. There can be 2 choices: cache data from db or cache all page (html).
So, is there any tools to make simple and fast?
Th...
It seems my rspec route for :controller => 'phones', :action => 'edit' works...it should be 'phones/123/edit', and IS according to rspec tests and rake routes. But when I create a redirect_to expectation, the expectation fails.
Here's the routes test for the url:
it "maps #edit" do
route_for(:controller => "phones", :action ...
Does anybody know how I can convert html to plain text with Ruby. Well really I need to convert RedCloth to plain text, either way would be fine.
I'm not talking about just striping out the tags (that is all I've done so far). For example I would like an ordered list to retain the numbers, unordered lists to use an astrix for bullets et...
I am writing an application, which shall work with networks.
As a GUI I am using rubyqt.
To determine if a Server is up I have to ping it (with net/ping).
But I ran in to a problem. If the server is down,
the GUI freezes for the timeout, even if I put the code in a Thread or IO.popen loop eg.
Thread.new('switch') do
if Net::PingE...
I am looking for a static analysis tool for Python, Ruby, Sql, Cobol, Perl, PL/SQL, SQL similar to find bugs and check style. I am looking for calculating the line count, identify bugs during the development, and enforcing coding standard.
...
I was looking through the Datamapper directories and opened up dm-core/tasks/dm.rb. Just generally speaking, what the heck is going on in this file? It looks like Greek to me. Particularly this thing about "specs" - what are those for? Is that similar to a software spec which defines what a project is supposed to encompass?
require 'spe...
Hi, I have a rake file, which can be executed successfully at command line. When I set a cronjob to run this rake file, the line "require 'json'" fails. My guess is that cronjob has a different env variable. It doesn't work when I tried to put "puts ENV" in the ruby script. So I'm wondering what I should do to check the different env var...
This is driving me crazy. I run into this every now and then on a new ubuntu/debian server.
Basically I can't do a exec! through net-ssh. Note, that I can require 'net/ssh' perfectly fine.
sample code
require 'rubygems'
require 'net/ssh'
Net::SSH.start('my.random.box', 'myuser', :forward_agent => "true") do |ssh|
#output = ssh.exec...
If I have this folder structure:
rexml
rexml/document
Is the following syntax not a recursive reference that includes everything below it?
require 'rexml'
Or do I need to write the following if I also want to access what's in 'document'?:
require 'rexml/document'
The reason I'm confused is I see some code where the author writes...
I have some content from feeds. In these feeds, UTF-8 characters are often encoded as character references, ie "å" is "å". To avoid double encoding these in my views (ie "å") I want to convert these back to normal UTF_8 characters. How can I do this in Ruby?
I want:
"å".convert_to_utf8 => "å"
...
When rails serializes an object to store in the database it uses YAML. I want to also use
Base64 encoding/decoding when doing this so the YAML will be much more compact on INSERT and UPDATE statements. The objects I am serializing are rather large, and Base64 encoding is reducing my insert and update statement times by 70%.
I've been cr...
I came across the following while reading about how easy it is to redefine methods in Ruby:
class Array
alias :old_length :length
def length
old_length / 2
end
end
puts [1, 2, 3].length
Sure, it's a bad idea, but it makes the point. But it bothered me that we switch between :length and length and :old_length and old_length s...
Let's say I have Book model and an Author model. I want to list all authors sorted by their book count. What's the best way to do that?
I know how to do this in SQL, either by doing where .. in with a nested select or with some join. But what I'd like to know is how to do this nicely with ActiveRecord.
...
I need to have a setup and teardown method for some Rails tests that is class or system wide, yet I have only found a way to define a regular setup/teardown that works on a per test level.
For example:
class ActiveSupport::TestCase
setup do
puts "Setting up"
end
teardown do
puts "tearing down"
end
end
will execute th...
Hey there!
Im developing web-application with Merb and im looking for some safe and stable image processing library. I used to work with Imagick in php, then moved to ruby and start using RMagick. But there is a problem. Long running scripts causing memory leaks. There are couple solution exists, but i don't know which one is the most s...