I am trying to do some basic scripting using ruby to log in to a windows machine via telnet and pull some files over using the dos command line ftp. When I do this manually everything goes swimmingly but when I try it via ruby I'm getting an error in the login call.
Here is my test program in its entirety:
require 'net/telnet'
tn = Ne...
I am converting some of my link_to_remote generators with link_to as the AJAX calls were creating issues with my browser back button. (Silly noob mistakes!)
My application has many pages that have a long wait cycle (for various reasons out of my control). I have been relying on the link_to_remote's ability to use :before and :after call...
Hi All,
I'm having a slight issue with one of my Rails models. It's nothing I can't work around (as I've already done so), but I'm interested in the actual issue.
Basically, I have an ActiveRecord-based class named "Events" that I've connected to a remote database using "establish_connection". It all works fine and I can even perform...
In Java, one can create an IO stream from a String like so:
Reader r = new StringReader("my text");
I'd like to be able to do the same in Ruby so I can take a string and treat it as an IO stream.
...
Hi all, here's a beginner rails question...
After I do:
format.xml { head: ok}
How do I return from the controller endpoint without showing the view? If I drop off the end of the function at this point, I get what I expect, but if I call 'return', I end up in the view (or in my case in a missing view template). I can code up lots...
The default way to output JSON in rails is some thing like:
Code:
render :json => friends.to_json(:only => [:username, :avatar_file_name, :id ])
Output
{"friends" :
[{"user":
{"avatar_file_name": "image1.jpg", "username": "user1", "id": 1}},
{"user":
{"avatar_file_name": "image2.jpg", "username": "user2", "id": 2}},
...
I have a small application that process emails as downloaded from a imap-server with fetchmail. The processing consists of finding base64-encoded attachments with a XML-file inside.
Here is the code (somewhat stripped):
def extract_data_from_mailfile(mailfile)
begin
mail = TMail::Mail.load(mailfile)
rescue
return nil...
I perform a lot of tests that create e-mail messages. I store each message in separate eml file. (I can change file extension if needed.)
I would like to open each file in any mail client and take a screen shot, so I could visually inspect e-mails later.
The idea is that I could use a image viewing application to look at several screen...
I need to inverse a variance-covariance matrix in Ruby and vector by matrix multiplication. Which numerical Ruby library/Gem should I use?
...
I'm writing a ruby extension that defines a class.
If I use Data_Wrap_Struct() to implement my callback for rb_define_alloc_func(), do I need to manually mark and free the instance variables? Or is that still handled for me?
...
I'm looking to use the latest Twitter gem for a Rails app I'm working on.
However, executing the following line:
oauth = Twitter::OAuth.new(ServiceAPIKeys.twitter['api_key'], ServiceAPIKeys.twitter['secret_key'])
Triggers the following exception:
uninitialized constant Twitter::OAuth
I do have the gem configured in my environment....
I've written a very basic finance module in Ruby to ease my own calculations, as sometimes it's just a lot easier to enter irb and start calling functions. But the odd thing is, that in my module I have a submodule with a method called future_value (Finance::CompoundInterest.future_value) ... but according to irb it doesn't exist? It's...
I trying to write a ruby program that parses web log and makes sure each part of the log is valid. I trying to deal with the case of in the request string of the log, it has additional double quotes besides the starting and ending ones. I made the web log in the form of a regular expression because it's easier to read that make variables...
Hi ,
I'm reading a file line by line in a simple program and when I print the the lines to the screen the last line can't be seen at the ouput window in Netbeans 6.5.1 IDE on Windows XP but when I run the program directly from the command line as "ruby main.rb" there is not a problem (i.e the last line can be seen).I'm using Ruby 1.8.6....
Is there a project archetype (or whatever the ruby community calls it) for a jruby + rack + Sinatra project that creates a WAR deployment file with all required dependencies all ready to go?
What I want is the equivalent to "rails appname" that creates a ready to go project with ant/rake scripts and a basic directory hierarchy all ready...
Hello folks,
Currently im working on some sort of music project, so dealing with user mp3 uploads. And the problem is that i cant find id3 library, that will work correctly for all files.
I have tried libs: id3-ruby, Mp3Info, but still none of them gives me correct results.
For example, most common problems:
wrong stream parameters ...
I have a class that contains some private attributes. What I would like to do is to dynamically add some setters for these only for the execution of a specific block.
Example of what I would like to be able to:
class Content
attr_reader :a, :b
def initialize
@a = 1
@b = "plop"
end
def set(&block)
extend(Setter)
...
I am trying to clean up a string that I get from a website using mechanize
here is an except from the string with the junk characters
"Mountain</b></a><br>ΓÇÄ1hr 39minΓÇÄΓÇÄ - Rated PGΓÇÄΓÇÄ - Action/Adventure/Science fictionΓÇÄΓÇÄ - EnglishΓÇÄ - <a href="
Does any one know where they characters come from and how I can...
Hey guys,
So I installed Ruby 1.9 into /usr/local/bin and kept Ruby 1.8.7 in /usr/bin. Renamed all my 1.8 ruby, rails, rdoc, etc. executables to ruby18, rails18, etc.
So, going ruby --version at the command line gives me:
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.7.0]
If I start up an irb session and look at the $: va...
In ramaze (2009.06.04) the link helper has changed and I have some problems to use it. I want to create a link to the MainController -> test action
#{a('Testlink', r(:test))}
This works if the URL is not in a specific controller. If the user is in a other controller like http://site/othercontroller/testtwo, the Testlink are linked to ...