ruby

Learning programming in general - virtual mentoring

I know some programming. I know little bit of Java, I know some C#, I know some GW Basic. I've followed those 30 minute Ruby, Python tutorials and so on. I took some computer courses in college but didn't take them very seriously at that time. After I finished school, I got an IT job but my luck (or bad luck) I ended up doing non-coding ...

Insert Only: ActiveRecord or Queries?

All that I will do is insert records into the database. However, I would definitly like the database-independence that Ruby/ActiveRecord can offer me. What would be the reccommended choice? Using simple insert queries, and rewriting them, and also maintaining my own database class for things as batch insertions; Using the power of Act...

declarative_authorization and namespaces

Hi, Do you know - can declarative_authorization control access to namespace'd resources or not? I've tried something like has_permission_on [:admin, :users], :to => [:index, :show, :new, :create, :edit, :update, :destroy, :search] but it's not working :( any ideas on this? ...

Learning programming in general - virtual mentoring

I know some programming. I know little bit of Java, I know some C#, I know some GW Basic. I've followed those 30 minute Ruby, Python tutorials and so on. I took some computer courses in college but didn't take them very seriously at that time. After I finished school, I got an IT job but my luck (or bad luck) I ended up doing non-coding ...

Ruby HAML with Django?

Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML. I also love Python and Django. So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python (SHPAML and other...

Can I use Ruby and Python together?

Is there something like JRuby but for Ruby and Python? Not that it would actually be useful to me, but just wondering. ...

Please help me find a way to programmatically determine the number of seeds and peers of an arbitrary torrent file

For a site I've been working on, the client needs a torrent tracker for creative commons/public domain files. My initial approach was simply to write a ruby script to parse uploaded .torrent files, connect to the tracker and use simple iteration through the peers to figure out which were seeds. The problem is, that only worked with torr...

Three "final" versions of Ruby?

I've played around with IronRuby lately, but I would like to install the reference implementation also. Needless to say, I'm a noob when it comes to Ruby, so I have a very stupid question. On the RubyForge download page, there are three different final versions of the Ruby installer (for Windows): rubyinstaller-1.8.6-p398.exe rubyinst...

Ruby framework to write a API in?

Hi I'm looking to write a multiplatorm tasks application for technical people. I want to handle as many platforms as I can (web, shell, desktop) and therefore I have decided to begin with a server/API. I want to write it in Ruby, however i think that Rails is a bit too heavy for this, even though it would do the job. Sinatra also doesn'...

CSV to DataMapper Import

This is probably very simple, but I'm quite new to ruby and active record. I've got a CSV dump of a database which I'm trying to import to a database using DataMapper. I'm having trouble understanding which type of relationships I should define in the models so that it matches what is defined CSV. Here's what data I've got from the CS...

Starting Ruby on Rails from an Objective-C background

Hi, Right now I program exclusively with Objective-C using the Cocoa frameworks to write applications for the Mac OS X and iPhone/iPad platforms. I'm fairly fluent using the Objective-C language as well as the Cocoa and Cocoa Touch frameworks. I also know just enough C to be able to understand ObjC. One of my projects requires that I ...

How do I replace all the values in a hash with a new value?

Let's say I have an arbitrarily deep nested Hash h: h = { :foo => { :bar => 1 }, :baz => 10, :quux => { :swozz => {:muux => 1000}, :grimel => 200 } # ... } And let's say I have a class C defined as: class C attr_accessor :dict end How do I replace all nested values in h so that they are now C instances with the dict attri...

What is the oldest version of rubygems that is supported?

What is the oldest version of rubygems that still allows you to download gems from rubygems.org? ...

Rails: load_paths for directory and all subdirectories

In environment.rb I can add the line config.load_paths += %W( #{RAILS_ROOT}/app/models/foos ) where 'foos' is a folder. This loads all files inside the foos folder. However it doesn't load any of its subdirectories. If I knew the names of all the subdirectories in the 'foos' folder, this problem would have an easy solution: %W[fold...

script/console won't work; reports "Missing the Rails gem. Please `gem install -v= rails`..." even though rails shows as installed

I'm trying to learn RoR, and running script/console fails, returning: Loading development environment (Rails 2.3.5) Missing the Rails gem. Please gem install -v= rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version i...

How do I spawn a new process to do a task in Ruby?

I would like to write a Ruby script that runs a daemon Ruby process, so that I can do something like the following: $ task start Started... # start a daemon to do useful work; don't block # Some time later: $ task end Finished. What's the best way to go about this? ...

How to login to a website programmatically from the server

Using any language (php, java, ruby, python), what's the best way to login to a website programmatically from the server? (for example, login to amazon, jetblue, etc. ) Are there are some frameworks to make this easier? ...

A ruby array question!

Hey ,Guys ,I have a question. I want to transform the array.[[1, [-1, 1]], [1, [20, 8]], [1, [30, 4]], [1, [40, 2]], [1, [41, 6]], [1, [70, 243]]] into this style [1,[[-1,1],[20,8],[30,4]...] or a hash [1=>...] How can i do this trick? thank you ! ...

if(!x) vs if(x==false) in ruby

I don't understand the following code: ruby-1.9.1-p378 > puts "nil is false" unless nil nil is false => nil ruby-1.9.1-p378 > puts "nil isn't false" unless nil == false nil isn't false => nil In most languages (of a C-base, at least), if(!cond) and if(cond==false) evaluate the same. What's going on here to make that not the case? ...

Writing an entire application on top of Capistrano

I am working on a task that needs to checkout source from a github repositroy, and then modify some files from the checked out repository based on some existing configuration data that's coming from a separate call to a different web service as JSON. The changes to the checked out code are temporary and will not be pushed back to github...