Ok, I'm confused. I'm trying to send back the magic headers from my server that will prevent a client from hitting the server again until a resource is stale.
I understand how ETag or Last-Modified works (Validation) - the client will ALWAYS still hit the server, and the server needs to validate the date or etag against the current val...
I want to test whether a equals 1 or 2
I could do
a == 1 || a == 2
but this requires repeating a (which would be annoying for longer variables)
I'd like to do something like a == (1 || 2), but obviously this won't work
I could do [1, 2].include?(a), which is not bad, but strikes me as a bit harder to read
Just wondering how do to ...
Untill now I used soap4r as my SOAP-client with Ruby 1.8.x, but now I am moving on to Ruby 1.9.x. Unfortunately soap4r doesn't work with Ruby 1.9.x I just get the "invalid multibyte escape" which seems not solvable, mostly because the soap4r gem wasn't updated since 2007, so I assume the project is dead.
I had a look at handsoap but the...
On the change of a 'select', I'm calling a method in my controller, 'get_sched'.
That method just sets a couple variables, then I do a redirect with:
respond_to do |format|
format.html { redirect_to :action => "index", :id => params[:id] }
end
My log shows that it's redirecting, but the data on my page isn't updating. Do i need to d...
MacRuby 0.5 includes a ruby compiler built on LLVM called macrubyc.
Does anyone know if it would be possible to dynamically load gems from compiled code? Or compile the gems and link them in? Is this planned? Or how compiled code will be able to make use of gems in general.
...
Is there a more elegant way of doing this logic in ruby
a = nil #=> obviously 'a' can have value but I am just setting it nil to make the eg more clear
b = a
unless b
b = "value"
end
so that we have the value of b set in the end. We could have another variation of the above code like so
a = nil
b = a
b ||= "value"
and I can also ...
Hello,
I have the following statement -
Mail.defaults do
pop3 'mail.server.com', 110 do
user 'user'
pass 'pass'
end
end
How can the default variables be assigned manually?
I have the above running fine on localhost - but it breaks and give a NoMethodError pop3 when I push it up to Heroku.
...
I want to have a form saved every 10 seconds or so, or maybe onchange. I'm using rails and have tried observe_fields and periodic_remote_call, but I don't know how to send a full full parameter with periodic and how to send a full form with observer.
...
Im looking for a ruby regex to match this
@variables{
color1 | #FFFFFF | links;
color2 | #c1dfee | frame;
}
however - what is inside the braces is not important. I just want to capture that @variables{} with its content. So I guess Im looking for something like /@variables{MATCH-ANYTHING}/m
Thanks.
...
i know that these 2 languages require oop.
but inside the classes, could you have procedural code?
and for the mvc part, that pattern comes with their frameworks right?
nothing to do with the actual language itself?
...
i want translate old asp site to rails.
old site has mixup code and static file in one big tree
like
.
..
blabla/
-img/
--aaa.jpg
-js/
--aaa.js
blabla.asp
blabla2/
-img/
--aaa.jpg
-js/
--aaa.js
blabla2.asp
it's big site and still replace static files.
and i didn't want sync issue.
so i do ...
Im using xmpp4r and trying to get the hang of a basic chat feature that I wish to implement later in my Rails app. My fundamentals on Ruby Threads is still a bit shaky so I would appreciate any help on this.
Though I register the callback i dont get a response from my gmail account. I am able to send a message but my ruby program termi...
Hello, I'm writing an IRCd. For this topic it doesn't really matter if you know much about IRC. Its a simple code style problem.
Quick overview of the problem:
No message may be longer than 512 characters
If the message is more, it must be broken into pieces
The NAMES reply sends all the nicknames of users on a channel, and quickly gr...
Here is a sample program:
def worker(from, to)
puts "#{from}..#{to}"
for i in from..to do
if i == 42
puts "kill the rest of the threads"
break;
end
puts i
sleep 1
end
end
if __FILE__ == $0
threads = []
for i in 0..9 do
threads << Thread.new { worker(i*10, i*10+10) }
end
threads.each { |th...
I have an older powerbook running 10.4. It has Ruby 1.8.2 on it but I want to upgrade to 1.9. Other people suggested using macports and I tried it but am getting some weird errors. Can anyone assist?
sudo port install ruby19 +nosuffix
---> Computing dependencies for ruby19
---> Configuring gperf
Error: Target org.macports.configure r...
I have some big fixed-width files and I need to drop the header line.
Keeping track of an iterator doesn't seem very idiomatic.
# This is what I do now.
File.open(filename).each_line.with_index do |line, idx|
if idx > 0
...
end
end
# This is what I want to do but I don't need drop(1) to slurp
# the file into an array.
File.op...
So given the following java class:
class Outer
{
private int x;
public Outer(int x) { this.x = x; }
public class Inner
{
private int y;
public Inner(int y) { this.y = y; }
public int sum() { return x + y; }
}
}
I can create an instance of the inner class from Java in the following manner:
Outer o = new Outer(1);...
Is using 50 if-else statements too resource-intensive for one action?
I'm doing something like this:
if team.players.count > 1
assign_team_type(..)
elsif team.players.count > 3
assign_team_type(..)
...
etc.
...
end
Also, is it more efficient to place the 50 if-else statements in your create action inside your controller instead...
I need to parse following String into a DateTime Object:
30/Nov/2009:16:29:30 +0100
Is there an easy way to do this?
...
I fire up Gnu screen and start editing a Ruby file with syntax coloring on and choose a vim colorscheme that uses boldface and a colored background (e.g. evening). Then I quit vim. The terminal doesn't return to the way it was before, but takes on some of the properties of the colorscheme I was using in Vim.
This doesn't happen if I'm u...