I wonder if there is a way to get offsets and delimiters while I am splitting a string in ruby analagous to PHP preg_split:
preg_split("/( | |<|>|\t|\n|\r|;|\.)/i", $html_string, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE);
I imagine I can achieve it by traversing string by characters or using something heavy as treet...
Hi,
I am trying to make an arcade machine. The user will purchase credits, which will allow him to play for X minutes. I want to write "9:42 minutes left" at the left corner of the screen, even if he's playing a full screen game (UrbanTerror, for example).
I would really like if I could do this with Ruby, but any other language is OK. ...
Hi,
As I am using Ruby on Rails to build an application, which only runs locally, I am lost in the woods (a nuby without a compass). I have a simple MVC application and my view is missing one thing I could really use. I want to select a local file just to retrieve it's filename. I know it's relatively easy to use the form tag helpers fo...
Currently I am using Ruby 1.9.1 and the 'ruby-mysql' gem, which unlike the 'mysql' gem is written in ruby only. This is pretty slow actually, as it seems to insert at a rate of almost 1 per second (SLOOOOOWWWWWW). And I have a lot of inserts to make too, its pretty much what this script does ultamitely. I am using just 1 connection (sinc...
I have a simple class that is using curb to retrieve data. Everything works just find from the command line, but when I load it into my rails application WebBrick crashes on the "require 'curb'" statement.
I'm extremely new to ruby so I'm not sure how exactly to debug the error from webbrick to determine what is wrong.
If someone kno...
After hearing about git commit hooks, I was thinking maybe there are such things as email hooks...
Is it possible for me to build a program that says "hey, you just received an email, now run this ruby script"? Something like a GMail Web Hook. Is there anything out there like that? I mean I could build a cron thing that checked my em...
I'm new to Ruby, and have been working my way through Mr Neighborly's Humble Little Ruby Guide. There have been a few typos in the code examples along the way, but I've always managed to work out what's wrong and subsequently fix it - until now!
This is really basic, but I can't get the following example to work on Mac OS X (Snow Leopar...
Disclaimer: Although I'm asking in context of a Rails application, I'm not talking about Rails helpers (i.e. view helpers)
Let's say I have a helper method/function:
def dispatch_job(job = {})
#Do something
end
Now I want to use this from several different places (mostly controllers, but also a few BackgrounDRb workers)
What's the...
Hi all
If I implement a class in ruby and compile it with jrubyc than it is not possible to call it from a java class directly if I start it with java. If I see this right I have to use
org.jruby.embed... to implement a wrapper wich takes a class name and a metod to call my ruby class.
Do I have to do this also if I start the applicat...
How do I rename a file after is has been uploaded and saved?
My problem is that I need to parse information about the files automatically in order to come up with the file name the file should be saved as with my application, but I can't access the information required to generate the file name till the record for the model has been sav...
Hi there
Whilst reading through the book "The well grounded Rubyist", I came across some strange behaviour. The idea behind the code is using one's own method_missing method. The only thing I am not able to grasp is, why this code gets executed, as I do not have any Person.all_with_* class methods defined, which in turn means that the s...
Asking this question again with smaller code sample:
# this is a dummy shoulda macro that creates a context
def self.macro_context
context "macro" do
yield
end
end
# i am expecting this test to fail within the macro context
context "some context" do
macro_context do
should "test" do
fail
...
What would an equivalent construct of a monad be in Ruby?
...
Hi,
<%= image_tag this.profile.expiring_url(180) %>
keeps giving me grief when profile is nil... what can i do?
Thanks in advance!
...
Hi,
As Rails applications default run on port 3000, would it be possible to start the application on port 80? Is it really required to have a fastcgi/mod_proxy enabled web server in front? My users won't be more than three at a time. If so, how would I be able to do so?
Thanks!
...
Although the HTTP spec says that headers are case insensitive; Paypal, with their new adaptive payments API require their headers to be case-sensitive.
Using the paypal adaptive payments extension for ActiveMerchant (http://github.com/lamp/paypal_adaptive_gateway) it seems that although the headers are set in all caps, they are sent in ...
Hi,
I have built a small text based search engine on ROR which will display relevant records having a specified search word in it.since few of the records has more than 1000 words i have truncated each result set to 200 characters.My views file search.html.erb looks like this
<% @results_with_ranks.each do |result| -%>
<% content_id...
I've got a non-RoR but ruby webapp in the works.
So far, I've just been using requests, hacks, and mod_ruby; but I'd really like to try out Mongrel--which seems to work really well for RoR sites.
I looked at the examples given in GitHub, and none of them does dynamic changing of content w/o having to restart Mongrel like you can do in ...
I'm using the simple_navigation gem with RoR 2.3.5
It all seems to work correctly, I followed the info in the RDoc (seen here http://rdoc.info/projects/mexpolk/simple_navigation)
However, when I actually render out the simple_navigation menu on my main application.html.erb file it escapes all of the html in it (multiple escapes actual...
I have just installed paperclip into my ruby on rails blog application. Everything is working great...too great. I am trying to figure out how to tell paperclip not to output anything if there is no record in the table so that I don't have broken image links everywhere. How, and where, do I do this?
Here is my code:
class Post < Active...