ruby

Hook up into another Terminal process?

I've got two terminal instances/processes opened with different PID. Is it possible to from one of them, hook up into the other so when I type something and it outputs something, then the other terminal will see the output too (maybe the input too if possible?). Just like cloning the terminals. I want this because then I can hook up s...

Rmagic isn't work on Rails3

Hi guys , My Rmagic isn't work ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] rails -v Rails 3.0.0.beta4 irb require rubygems true require rmagick true but , I put the fllow code: gem 'rmagick', :require => false it error: checking for Ruby version >= 1.8.5... yes checking for stdint.h...

Undefined method auto_upgrade! when pushing Sinatra/DataMapper app to Heroku

Does anybody know the magic incantation required to get a Sinatra application that uses DataMapper up and running on Heroku's Bamboo stack? The Bamboo stack doesn't include any pre-installed system gems and no matter what combination of gems I try I keep getting this error: undefined method `auto_upgrade!' for DataMapper:Module (NoMetho...

Submitting a ruby gem via the API fails with HTTP error code 422

Hi, I'm trying to upload my FAKE project (http://github.com/forki/FAKE) to RubyGems from F#: let mutable rubyGems = "http://rubygems.org/api/v1/gems" let PushGem gemFileName authCode = let client = new System.Net.WebClient() client.Headers.Add(Net.HttpRequestHeader.Authorization,authCode) logfn "Uploading gem %s to %s." ...

Require file without executing code?

Here I have two files: file.rb def method puts "This won't be outputted." end puts "This will be outputted." main.rb require "./file" When running main.rb it will load all the code inside file.rb so I will get "This will be outputted." on the screen. Is it possible to load a file without having it to run the code? Cause I wan...

Execute commands inside another process?

I want to be able to start a process and send input to it immediately. Take Bash as an example. The following code will enter another Bash process and then print "Hello World!" on the screen after I have terminated the process with "exit" bash echo "Hello World!" Is there a way to enter bash and then print "Hello World!" INSIDE that...

Check if a variable is defined outside the block

Suppose we have n constants like: FOO = 'foo' BAR = 'bar' ... I need to check in the block if they exists and are non empty. %w(FOO BAR FOOBAR).each {|i| # this doesn't work fail "#{i} is missing or empty" if (! defined?(i) || i.empty?) } ...

Ruby version of the TCL-based Expect?

Expect seems to be a very powerful automation tool: http://www.nist.gov/mel/msid/expect.cfm Is there a Ruby equivalent to that tool? ...

annotate command not working, added it to my gemfile

My gem file looks like: group :development, :test do gem 'rspec-rails' gem 'annotate-models', '1.0.4' end I ran 'bundle install' and it installed the annotate-models bundle. If I type: annotate I get a command not found error. If I type: bundle show annotate I get a 'could not find gem annotate in the current bundle. If I...

Magic $-prefixed variables in Ruby; is there a complete reference somewhere?

I've seen magic variables like this used in Ruby. $_ $' $0 Is there a complete reference for what all of them mean and how they are set? ...

crc64-jones or crc64-ecma available in ruby?

I read a paper that explained that using CRCs generated from the CRC-64-ISO algorithm as hash keys is likely to result in collisions for large sets of data. Postmodern's Ruby CRC project is pretty interesting, but the CRC64 class seems to be using the CRC-64-ISO algorithm. I'm hoping to generate probably-unique ids from canonical input...

Accessing rdoc files from one place.

In Ruby, if you run the command gem server it will present you with a web page of documentation for all the gems you have installed on your machine. Can something similar be done for your local documentation, so that all of your local rdoc documentation is in one easy to access place? Any advice would be much appreciated, thanks. ...

I deleted a rails gem in the wrong way - what should I do?

So I installed rspec 2.0 beta 22 and then I deleted the folder in the library folder on my mac (I know i'm an idiot). Now I can't reinstall or uninstall. HELP!! Thanks ...

Ruby iphone develop

Hey you guys :-) Recently Apple, made an announcement about you now can code in other programming languages. So well i thought nice! Finally i can make iphone apps.. But i can't figure how to code the apps i Ruby.. So i googled - a lot! and did'nt find anything.. so if someone out there know anything.. tell me! :-)! /Oluf Nielsen ...

ruby version and gem's ruby version do not match

RubyGems is reporting a different ruby version than running ruby --version. Looking for suggestions on diagnosing and fixing this. OS is OS X 10.5. lando-macbook:rubygems-1.3.7 lando$ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0] - INSTALLATION DIREC...

making a pretty url via ruby

Ok so i want the title of an event to be in the url like /events/party-at-mikes so here is how i am doing it Event.find_by_title(params[:title]) my link <%= link_to('<span>EVENTS</span>', course_event_path(obj.golf_course.city.permalink, obj.golf_course.permalink, obj.title), :class => 'right eve_bnt') %> the obj.title is the ...

Stackoverflow error in this recursion

What's wrong with this recursion in Java? public class findPyt { public static int sum = 0; public static void main(String[] args) { findP(3, 4, 5); } public static void findP(int a, int b, int c) { sum = a+b+c; if (sum == 1000) { System.out.println("The Triplets are:...

Adding variables from object passed from model to controller

I have a Person model. When a new Person is created, I want to set a random_variable in the controller and pass it as part of the @person object. I have tried Model attr_accessor :random_variable Controller: def create @person = Person.new(params[:person]) @person.random_variable = 'A Random string' @person.save ...

How to create a server in Ruby (like rails server or gem server)?

A lot of ruby frameworks implement a server to serve up dynamic html documents. I am looking to create my own server so that I can serve up my own local rdoc documentation. How does one create a server in ruby like rails server or gem server? Can somebody give me a start or point me to some documentation on how to do this? Thanks ...

how to measure page request time in milliseconds in a rails project?

New to rails, want to test the time it takes for a given page to render in milliseconds. Where in the request pipeline do I do this? (start and stop the time, and output to the page) ...