ruby

Are there any Simple and Clean Methods to implement Maps (Google or otherwise) in RoR 3?

I'm looking into building a group work app for my final year project next year. One of the core parts is organising group meetings. I plan to make this as powerful as possible and adding a map can help get rid of excuses such as "I didn't know where it was". I have been unable to find any simple solutions to embed maps into my Rails app...

Parsing dictionary entries with regex

I'm trying to pull data from Jim Breen's WWWJDIC. The raw data returned has a lot of information delimited in several different formats. The data pulled in the example below is from here: http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?1ZUJ%E5%85%88%E7%94%9F 先生 [せんせい] /(n) (1) teacher/master/doctor/(suf) (2) with names of teach...

BCrypt says long, similar passwords are equivalent - problem with me, the gem, or the field of cryptography?

I've been experimenting with BCrypt, and found the following. If it matters, I'm running ruby 1.9.2dev (2010-04-30 trunk 27557) [i686-linux] require 'bcrypt' # bcrypt-ruby gem, version 2.1.2 @long_string_1 = 'f287ed6548e91475d06688b481ae8612fa060b2d402fdde8f79b7d0181d6a27d8feede46b833ecd9633b10824259ebac13b077efb7c24563fce0000670834215...

Clean solution to this ruby iterator trickiness?

k = [1,2,3,4,5] for n in k puts n if n == 2 k.delete(n) end end puts k.join(",") # Result: # 1 # 2 # 4 # 5 # [1,3,4,5] # Desired: # 1 # 2 # 3 # 4 # 5 # [1,3,4,5] This same effect happens with the other array iterator, k.each: k = [1,2,3,4,5] k.each do |n| puts n if n == 2 k.delete(n) end end puts k.join(",") ha...

How to render a Partial from a Model in Rails 2.3.5

I have a Rails 2.3.5 application and Im trying to render several Partials from within a Model (i know, i know -- im not supposed to). The reason im doing this is im integrating a Comet server (APE) into my Rails app and need to push updates out based on the Model's events (ex. after_create). I have tried doing this: ActionView::Base.n...

class_eval in ruby?

I don't understand class_eval in ruby. class Module def attr_ (*syms) syms.each do |sym| class_eval %{def #{sym}= (val) @#{sym} end} = val end end end What does the % mean? What does class_eval do? And where is (val) coming from? Thanks ...

Get underlined text with markdown

Greetings, I am using BlueCloth as a Markdown library for Ruby and I can't find any syntax for getting a text underlined. Any ideas? Peter ...

Parse a certain value ie current temperature from a website using RUBY

Hi Friends, I have to parse only the 'current temperature' value in a webpage and display it. Kindly help me out please. ...

ruby 1.9.1 in netbeans?

i have installed ruby 1.9.1 and when i in the command prompt type: ruby -v i see the latest version. however, in netbeans when i create a new project i can only select 1.8.7 version. how do i tell netbeans to use the latest ruby version that i have installed? thanks ...

How can I perform an idiomatic non-recursive flatten in ruby?

I have a method that returns an array of arrays. For convenience I use collect on a collection to gather them together. arr = collection.collect {|item| item.get_array_of_arrays} Now I would like to have a single array that contains all the arrays. Of course I can loop over the array and use the + operator to do that. newarr = [] ...

trouble with ruby passenger

when i paste this code in MAMP's httpd.conf: LoadModule passenger_module /Volumes/Private/ajsie/.rvm/gems/ruby-1.9.1-p378/gems/passenger-2.2.14/ext/apache2/mod_passenger.so PassengerRoot /Volumes/Private/ajsie/.rvm/gems/ruby-1.9.1-p378/gems/passenger-2.2.14 PassengerRuby /Volumes/Private/ajsie/.rvm/rubies/ruby-1.9.1-p378/bin/ruby then...

how to use ruby in the web?

so now (finally after 4 hours) i have installed ruby 1.9.1, rvm and passenger. but how do i use ruby with http? in php you just embed php with html in a .php file. how do you do it with ruby (note: i dont want to use frameworks for that, just pure ruby + html to learn how it works). thanks ...

Something similar to while(!kbhit)(in c++) in ruby??

I want to continue with a process unless a keyboard key has been pressed... One method is injecting the C++ code but thats ugly... Is there any other method to do the same? ...

Rails Engine: Extend model with application class

I Have an engine in vendor/plugins. My problem is, that i seemingly can´t extend the engine-model with a model in the base application. My folder structure: APPNAME -app -models -item.rb -vendor -plugins -image_gallery -app -models -image_gallery.rb Nothing special... in my image_gallery.rb i have just this...

ruby language syntax(how platform_info variable is used

class EncodeDemoTest < Test #inheritance in ruby def setup(platform_info, logdir) @telnet_ip = platform_info["telnet_ip"] @telnet_login = platform_info["telnet_login"] @telnet_password = nil @filesys_path = platform_info[...

How long will it take a coder to learn ruby?

How long will it take for a developer to learn ruby. And develop a production website like stackoverflow ? Normally. If the developer have .NET experience but no ruby and MYSQL or PostgreSQL experience. ...

Regular expression ending with the first of two options

In Ruby, I'm trying to extract from text a string that starts with "who" and ends with the first of either a ")" or "when" (but doesn't include the ")" or the "when"). I've tried the following: who.*(?=when\b|\)) which fails the case where it finds both a "when" and a ")". Any ideas? Many thanks ...

Fetch main model and translations in one query with globalize2

Is there a way to fetch the model and the translations in one query when using globalize2? For example, having a model called Language which have two fields, code and name of which the second is translatable I do the following: en = Language.find_by_code("en") and it runs this query: SELECT SQL_NO_CACHE * FROM `languages` WHERE (`l...

Will_Paginate - How to add a separator between the inner_window and outer_window values?

I have implemented the following custom link renderer class: class PaginationListLinkRenderer < WillPaginate::LinkRenderer def to_html links = @options[:page_links] ? windowed_links : [] links.unshift(page_link_or_span(@collection.previous_page, 'previous', @options[:previous_label])) links.push(page_link_or_span(@collec...

Ruby Challenge - efficiently change the last character of every word in a sentence to a capital

Hi All I recently was challenged to write some Ruby code to change the last character of every word in a sentence into a capital. Such that the string: "script to convert the last letter of every word to a capital" becomes "scripT tO converT thE lasT letteR oF everY worD tO A capitaL" This was my optimal solution however I'm sur...