ruby

Is there a reason I should not start with C#

I think I'm leaning toward C# and .net as a concentration language for learning web development. I would like to learn good programming fundamentals and I've looked at pretty much everything else. The four I've narrowed it down to have been C#, Python, Ruby and PHP. Is there a reason to stay away from C# (and I don't think the cost iss...

Ruby Terminology Question: Is this a Ruby declaration, definition and assignment, all at the same time?

If I say: x = "abc" this seems like a declaration, definition and assignment, all at the same time, regardless of whether I have said anything about x in the program before. Is this correct? I'm not sure what the correct terminology is in Ruby for declarations, definitions and assigments or if there is even a distinction between thes...

Ruby on Rails: New controller for photos?

I have a one-to-many relationship between my Profile class and Photos class. Profile holds the user's information and photos holds the user's pictures. Currently, the "Upload photo" link shows at the bottom of the profile view. I want to have the link show up on a separate view instead of cramming everything on the same form. Should I ju...

Click event in Shoes

On clicking a slot , I change the contents of the slot to provide user feed back, then call some code which takes several seconds to run. However the changes to the slot do not render until after the 'slow' process has completed. Is there any way I can force the rendering to happen before the 'slow' code runs. In the following example t...

Ruby: Mysql timestamp/datetime problem

Is there solution for '0000-00-00 00:00:00' problem, without changing table? I have "[]" in this query: dbh.select_all("select j.n, j.name, j.dsc, j.flag, j.td from job j where j.td='0000-00-00 00:00:00'") I look solution for this: http://rubyforge.org/tracker/index.php?func=detail&aid=22243&group_id=234&atid=967 ...

Should I learn Ruby or Python?

I'm a C(++)/C# programmer and I would like to learn a scripting language to create small tools (text processing, build scripts, a little web development, etc). I would like to learn either Ruby or Python. Is there a good reason to chose one over the other? I looked at some sample code in both languages and they seem very similar to me....

How can I add a page to a Gtk Notebook widget at runtime?

I have the following code : require "gtk2" # adds a page to the notebook with the given label def create_page(nb,label="untitled") # create a textview tx = Gtk::TextView.new # append it nb.append_page(tx,Gtk::Label.new(label)) end Gtk.init window = Gtk::Window.new window.set_default_size(800,600) window.signal_connect...

how to make acts_as_list behave with groupings

I have a small rails app that is using acts_as_list to implement drag and drop via ajax. The app has 3 main models: forms, sections, and questions. As it is designed, forms have many sections, and sections have many questions. I want a user to be able to do 3 things: reorder the sections in forms reorder the questions in the secti...

How to parse a remote website and create a link on every single word for a dictionary tooltip?

I want to parse a random website, modify the content so that every word is a link (for a dictionary tooltip) and then display the website in an iframe. I'm not looking for a complete solution, but for a hint or a possible strategy. The linking is my problem, parsing the website and displaying it in an iframe is quite simple. So basicall...

What's the best way to validate multiple emails and handle errors in Rails?

In the current app I'm building I've got a textarea where a user will enter a comma-delimited list of email addresses. I'm currently splitting the list into an array and then saving one by one. But if, say, I have this input... [email protected], test@example, [email protected] ... then [email protected] will be saved, but saving test@ex...

Mimic AES_ENCRYPT and AES_DECRYPT functions in Ruby

Hello there! I need to mimic what MySQL does when encrypting and decrypting strings using built-in functions AES_ENCRYPT() and AES_DECRYPT(). I have read a couple of blog posts and apparently MySQL uses AES 128-bit encryption for those functions. On top of that, since this encryption requires a 16-bit key, MySQL pads the string with x0...

How can I send a parameter to a before filter?

I'd like to create a before_filter method in my application controller like this... def check_role(role_name) unless logged_in_user.has_role? role_name flash[:notice] = 'Access to that area requires additional privileges.' redirect_to :back end end However, it doesn't look as though before filters can take parameters. Is ...

Redefining Helper methods in Ruby On Rails.

I have a situation where the header partial is called by the standard layout. (This is fairly common I assume) In the header is a search box - just like on stackoverlow. However, when the user is on the search page, I want to remove the search box from the header. What I attempted to do was put a method in the ApplicationHelper.rb file...

Are data structures used in higher level languages?

Hello, I am currently still in school and taking a class on implementing data structures in c++. In my spare time I enjoy programming in "higher level" languages (mostly Ruby with some c#). So since these higher level languages manage the memory for you, what would you use data structures for? I can understand the need for queues and st...

Create static graphics files (png, gif, jpg) using Ruby or Python

I'd like to create a graphic image on the fly based on user input, and then present that image as a PNG file (or jpg or gif if necessary, but PNG is preferred). This is actually for an astrology application; what I'd like to do is generate the chart in PNG for display. Python or Ruby is fine; in fact, the library available may determin...

Haskell binding with Ruby through FFI ?

Since both ruby and Haskell supports FFI, Is it possible to call Haskell code from ruby, may be through FFI ? Is there any Haskell binding in Ruby ? ...

adding a method to built-in class in rails app

I want to add a method to the Array class in a rails app. Where should I put this method? EDIT to be clearer, obviously I put it in a file somewhere, but how do I tell the rails app about where to find it? ...

What design patterns should I use for a lightweight IDE?

I'm writing a lightweight IDE. I chose Ruby+Gtk2 for the task. I already have a minimal prototype for it, but right now, most of the code is inside my window class. I'll soon start working on the "real deal", but I would like to know what design patterns should I make use of. I'm planning for plugin support too, so that the app will be e...

Printing Reports and invoices with Ruby?

I just learn Ruby, and i wonder how to generate Reports and Invoices (with Logo, adressfield, footer, variable number of invoice-items (sometimes resulting in more than one page), carry over of the amount to pay from one page to the next, free-floating 2-column text (left-and-right-justified) below the resulting cash-informations). Curr...

Where is the methods and operators defined that allow to do "class << self; def foo; end; end" inside class definition?

How is this explained? Can I replace self with some other object? ...