I want to know if the mysqlplus gem is a better database driver than the common Ruby mysql gem? I used to have some problems in my Rails application, like:
ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone away
...
My application needs to deal with arrays of fixed size. The problem is that sometimes elements are nil but nil is a forbidden value. I think an easy way is to replace nil values with an the closest non-nil value (right before or right after).
The nil values can be first, last or even multiples. Here are some examples of what I'm looking...
I'm writing a project at the moment that involves running two parallel threads to pull data from different sources at regular intervals. I am using the Threads functionality in ruby 1.9 to do this but am unfortunately running up against deadlock problems. Also I have a feeling that the Thread.join method is causing the threads to queue r...
I'm working on a project that has a website in Rails and a C# GUI that use the same database and data models. I'd like to share the (active)models between the two parts. Any ideas on how this is possible?
...
Anyone have a Ruby script to grab some lyrics from somewhere?
...
I am trying to find out how many times a gem was installed via gem install or gem update.
For example, Watir 1.6.2:
it was installed 97 times via gemcutter (http://gemcutter.org/gems/watir/versions/1.6.2)
it is downloaded 4,027 times from http://rubyforge.org/frs/?group%5Fid=104
I have been told that 4,027 does not include installs ...
I have a Ruby (Rails) app that needs to make some calls to a service exposed via ONC RPC. Is there a way I can readily accomplish this in Ruby or do I need to create a proxy service using another language?
FWIW, my target platform is CentOS.
Thanks!
...
I have a table with (among other things) a name and a rank. I'd like to return the set of all unique names, but for each name returned, I'd like to pick the row with the highest rank. This is simple with two nested SELECT statements:
SELECT * FROM (SELECT * FROM foo ORDER BY rank DESC) AS ordered GROUP BY name
MySQL takes the first ...
Short version -- How do I do Python rsplit() in ruby?
Longer version -- If I want to split a string into two parts (name, suffix) at the first '.' character, this does the job nicely:
name, suffix = name.split('.', 2)
But if I want to split at the last (rightmost) '.' character, I haven't been able to come up with anything more elega...
Warning Rookie/newb mistakes contained within read at your own risk!
Ok trying to put together some code to read and print a text based maze file. This is what I have so far:
def read_maze( filename )
local_maze = []
mz_file = File.open(filename,"r")
while ! mz_file.eof? do
line = mz_file.gets.chomp
local_maze = line.scan(/./)
end
mz...
Sinatra app:
require "rubygems"
require "sinatra"
get '/' do
"Hello world. It's #{Time.now} at the server!"
end
windows XP with latest version of mongrel, sinatra, shotgun. ruby 1.8.6
running shotgun test_app.rb results in
C:\Files\sites\sinatra>shotgun test.rb
== Shotgun starting Rack::Handler::Mongrel on localhost:9393
Th...
Hello,
How can I define a relationship between two controllers. I have one controller called rides and another called registrant. Is there anyway I can access the registrant database from within the rides controller? I was thinking
@registrant = Registrant.find(:first)
from within rides, but that didn't work.
Any suggestions?
Thanks
...
I am a ruby newbie. Want to know how to read a number from a file to a variable. Anyone able to help please? Thanks in advance!
...
I feel like I'm an intermediate-advanced Rails programmer. I've written some small client apps. However, I feel like I'm missing something. I don't really understand HTTP; what a web server is; how networking works; what Mongrel is beyond just "script/server". Are there any good books to explain what HTTP is and other stuff I'm missing o...
Ok so I had to crack a Heineken for this one. Trying to solve a shortest path problem with a text file.
My research took me to:
link text
link text
pretty good information for my algorithm
Basically, I'm trying to start out at 'S' for start and quit at 'F' for finish or return no solution message
the two self styled tests or text fil...
We get our data from a sensor which records and stores data like hashes.
At any time it measures a few stuff like that:
{:temperature => 30, :pression => 100, :recorded_at => 14:34:23}
{:temperature => 30, :pression => 101, :recorded_at => 14:34:53}
{:temperature => 31, :pression => 102, :recorded_at => 14:34:24}
{:temperature => 30, :p...
hi
I want to check with "gem outdated" if there are any gem updates. Is it possible to get the result of the gem software in a script as string or value?
I don't want to execute system() oder something similar.
thanks for your help
...
I am learning RoR and trying to use accepts_nested_attributes_for and has_and_belongs_to_many to submit information that would traditionally be two forms. I have read on some sites they are compatible, some sites they aren't compatible, and some sites don't know. As reference, I am using Rails 2.3.4. I tried modeling my solution from ...
Having problems with a Ruby script that uses File.Open
Here is the code that I am speaking of...
f = File.open(Socket.gethostname().gsub!(/[[:space:].]/,"")+".log","a")
The issue is the + inside of .open, it is returning a error message saying its a undefined method.
Anyone able to help?
Edit:
Here is some code from the class which ...
I know it should be possible to communicate with a NAT/Router on a local network and ask for ports to be forwarded via UPnP, but I don't know any of the specifics.
I've found a gem that looks like it might be useful, but beyond that I'm at a loss (The gem's homepage appears to be down).
Does anyone have any pointers?
...