Hello, i want to be able to do event handling with ruby. I know there is no native way to do this, but i found a solution here in stackoverflow:
class EventBase
def initialize
@listeners = Hash.new
end
def listen_event(name, *func, &p)
if p
(@listeners[name] ||= Array.new) << p
else
...
I want to edit the following text so that every line begins with Dealer:. This means no wrapping/line breaks. For lines starting with System, wrapping is fine.
What would a solution in ruby look like? Thanks
This is located in a .txt file
Dealer: 5 seconds left to act
Dealer: hitman2714 wins the pot (9)
Dealer: Hand #1684326626D
Deale...
What is a good approach to a client proxy written in ruby that I can use to create a custom filter.
So far I've found
Ruby Proxy using webrick
Mousehole, a scriptable Ruby proxy by _why (UPDATE this was not robust)
A little on the fringe, this guy wants to Use rack as thin proxy with his question. I don't think he got an answer; or...
Hi all, I've tried to create simple facebook app with iFrame,, but I always get nested iFrame on every I click link on my application, I already tried a solution from site http://railsrant.com/2009/10/14/creating-a-facebook-iframe-app-using-ruby-on-rails-facebooker/
it's work on Firefox and Chrome, but doesn't work at IE
Any idea or sug...
I have created a image crop facility that I can click on an image and crop it and it saves the new cropped image over the old one, then redirects back to the original page where the image was show.
But it still shows the old image even after a redirect and doesn't display the new one till I refresh the page.
I have tried just using an ...
Hi there,
Our host does not allow us to modify the passenger config file (i.e. the apache config OR the vhosts file), but we'd like to run rails in dev mode. So we have to specify the environment (prod/dev/test) in one of the files that rails loads AS the application is restarted. Anyone know how to do this?
We've tried the following wi...
hi all
I have successfully implemented jcrop and paperclip to crop images by going to another page ie the crop.html.erb
but i want to be able to do all cropping on my current page where i upload the image(s) in a popup div / dialog.
so somehow i need to load this the crop.html.erb page into a popup div on click. Here is the code on t...
If i have a configuration file like this
# config/environments/integration.rb
config.action_controller.session = {
:domain => ".example.com"
}
How do Ii get the value from within my application controller, e.g:
# app/controller/application_controller
class ApplicationController < Mcc::CoreSupport::FrontendController
def some_meth...
This is a challenge to come up with the most elegant JavaScript, Ruby or other solution to a relatively trivial problem.
This problem is a more specific case of the Longest common substring problem. I need to only find the longest common starting substring in an array. This greatly simplifies the problem.
For example, the longest subst...
class Setter
attr_accessor :foo
def initialize
@foo = "It aint easy being cheesy!"
end
def set
self.instance_eval { yield if block_given? }
end
end
options = Setter.new
# Works
options.instance_eval do
p foo
end
# Fails
options.set do
p foo
end
Why does the 'set' method fail?
EDIT
Figu...
I couldn't find resources on how to use authlogic with sinatra. Or at least no documentation about a canonical way to do authentication with authlogic ...
Anyone has pointers to some tutorials, sample code or can sketch out a minimal authlogic/sinatra example?
Thanks in advance.
...
How can I add span tags to the following link?
<%= link_to 'demo', :action => 'test', :path => '' %>
Should display like this:
<a href="/test"><span>demo</span></a>
...
Full code: http://friendpaste.com/5TdtGPZaEK0DbDBa2DCUyB
class Options
def method_missing(method, *args, &block)
p method
end
end
options = Options.new
options.instance_eval do
foo
foo = "It aint easy being cheesy!"
end
puts "#===---"
options.foo
options.foo = "It still aint easy being cheesy!"
This returns:...
@xs stores urls like www.yahoo.com, www.google.com
for x in @xs
y = x... #do something with x
@result += y #i want to do something like that. i want to store them in @result. What do i have to write in here?
end
Sorry for noob question. By the way how do you call @result ? Is it an instance variable or an array ?
...
I have a legacy database that has integer data stored as chars that I would like to treat as numerical. Is there a quick and easy way to convert this is one place? The values are from 0-5 and it defaults to 0 so there are no nulls.
I can't just fix the data because the legacy db will still be updated by the legacy app.
So I am basica...
Hey,
So I am generating XML data in my RoR application for an external source to consume. The method in my controller is as follows...
def allOffers
@ridesall = Ride.find(:all)
respond_to do |format|
format.xml
end
end
I have a allOffers.xml.builder file that looks like this...
xml.instruct!
xml.rides do
@ridesall.each do |r...
Hello,
I defined a before filter in my controller:
before_filter :find, :only => [:caller]
and I want to catch exceptions in "find" method :
def find
begin
...
rescue Exception
redirect_to somewhere
end
end
but how can I prevent the "caller" method from continuing executing ?
...
I am writing a search engine using the Lucene Java framework.
What I want to do is to create an index of Ruby source code files. For that I would like to have the option of using a stop word filter, i.e. I want the stop words of the ruby language be ignored when indexing the files.
--> Does anyone know of a nice complete list of Ruby s...
We are planning to write a highly concurrent application in any of the Very-High Level programming languages.
1) Do Python, Ruby, or Haskell support true multithreading?
2) If a program contains threads, will a Virtual Machine automatically assign work to multiple cores (or to physical CPUs if there is more than 1 CPU on the mainboard...
I want to build a web-based information management application for a client. The application will be used to store passwords and critical documents online.
I want to know:
(1) Which language/framework to go with: PHP or Ruby on Rails (RoR) or any other?
(2) What type of hosting for good-security, Linux or Windows? Any other thing to b...