ruby double question mark
I came across this piece of ruby code: str[-1]==?? What is the double question mark all about? Never seen that before. ...
I came across this piece of ruby code: str[-1]==?? What is the double question mark all about? Never seen that before. ...
Hi there, I know we can send regular html files through the tubes and have the browser open them as Excel documents (you do that by changing http headers and the file name, then excel does the conversion). BUT, is it possible to get an HTML document show up in Excel with two Worksheets/Tabs? Here's what I thought might work, but didn't...
I've read in "Design Patterns in Ruby" by Russ Olsen how Observer pattern can be implemented in Ruby. I've noticed that Ruby implementation of this pattern is much simpler than C# implementation, e.g. implementation shown in "Programming .NET 3.5" by Jesse Liberty and Alex Horovitz. So I've rewritten "Programming .NET 3.5" Observer ...
I am trying to convert a small bit of Ruby to PHP, and I have had success so far, except for this one line: string = string[16,string.length-16] I have tried these two things in PHP: $string = substr($string, 16, strlen($string) - 16); // and $string = substr($string, 16, strlen($string) - 32); But the problem is that I have no clu...
Using Ruby on Rails combined with capistrano and git, I've run into an annoying problem.. I have a controller "people" with the index action that looks something like this: def index @people = Person.find( :conditions => params[:search] ) end There is a boolean "is_admin" column in the Person table. Assuming that some of the peopl...
I'm migrating a Perl script to Ruby. The Perl script uses DB_File in DB_HASH mode. How do I read all the keys and values from such a file in Ruby? ...
On the front page of my rap lyrics explanation site, there's a place where users can try explaining a challenging line: Here's the partial I use to generate this: <div class="stand_alone annotation" data-id="<%= annotation.id %>"> <%= song_link(annotation.song, :class => :title) %> <span class="needs_exegesis"><%= annotation.ref...
I have the following two action methods: def index puts "==index== flash: #{flash.inspect}" end def create flash[:notice] = "Blah" puts "==create== flash: #{flash.inspect}" redirect_to(:action => :index) end index.fbml.erb contains this: <%= button_to_with_facebooker "Blah!", :action => :create %> The application is used t...
What's the Ruby way to do this? if params[:month] @selected_month = params[:month].to_i else @selected_month = Time.now.month end ...
I'm working on a ruby script to grab historical stock prices from Yahoo, using Hpricot to parse the pages. This is mostly straighforward: the url is "http://finance.yahoo.com/q/hp?s=TickerSymbol" For example, to look up Google, I would use "http://finance.yahoo.com/q/hp?s=GOOG" Unfortunately, it breaks down when I'm looking up the price...
What is the proper syntax for a method that checks a string for a pattern, and returns true or false if the regex matches? Basic idea: def has_regex?(string) pattern = /something/i return string =~ pattern end Use case: if has_regex?("something") # woohoo else # nothing found: panic! end ...
I get this warning when trying to install the json module via ruby gems. Any ideas? Mac-Mini poulh$ sudo gem install json Password: WARNING: File '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 /specifications/json-1.2.0.gemspec' does not evaluate to a gem specification ...
What is the best place to learn 'advanced' Ruby so I can start contributing to Rails? Any other things I should read/know would be appreciated. Thanks. ...
I have a long running rake task. Every now and then I print an update to the screen to let me know how far along the task has come. puts "Almost there..." My problem is all the puts statements seem to buffer somewhere and won't print to the screen until after the task is complete. At which point, they will be printed all at once. Is ...
Hello, I have a problem of using the where clause for limiting dates I can't even get a simple statement like on "Feb 5 2010" to work, e.g., select * from LineItems where DueDate = 2/5/2010; I tried "2/5/2010" "2010/2/5" "2010-2-5" "2010-02-05" 2010-2-5 2010-02-05 ... but none worked. Does anyone have an idea what the proper format fo...
Let's say I have two different controller/view sets that are basically identical. Business hours and Staff hours The first contains a business_id, the latter a staff_id. Otherwise they look the same. id, mon_start_time, mon_stop_time, tues_start_time, tues_stop_time, etc... 1) Is there a way I would use the same controller for these s...
I am working on my personal site with RoR. I searched and read books. But I cannot figure out. How Can I configure routes.rb for xxxxx.com/:id? For example: twitpic.com's image url or short url is "http://twitpic.com/11u1cy". ...
I need to embed a link into a generated pdf in a ruby on rails app. Is there a way to do this with prawn? Reading about this it turns out that prawn-format was the answer for awhile, but 0.7.x broke this. prawn-format uses the link_annotate(rect, options={}) function to create links. What options need to be passed into this to get it t...
How do I convert the following to a clear one-liner in ruby? def questions results = [] sections.each do |section| results = results.concat(Question.find_all_by_survey_section_id(section.id)) end results end I feel like I could use the &: (Symbol#to_proc) and returning methods in there somehow. ...
I have a rails application in which user provides his skype address.I want to able to determine the skype status of the user(online or offline) when some one sees his profile. How can i do that in my application? Does any know of a ready to use gem/plugin? ...