ruby

Convert DateTime String to UTC in rails

I have a string like this: "2010-01-01 12:30:00" I need that to convert to UTC from the current local time zone. I tried this, but it seems to think that the string is already UTC. "2010-01-01 12:30:00".to_datetime.in_time_zone("Central Time (US & Canada)") => Fri, 01 Jan 2010 06:30:00 CST -06:00 I am not sure where to go from her...

Error installing mysql2 gem on ruby 1.9.2

I am currently trying to install the mysql2 gem for a ruby on rails application. I am using ruby 1.9.2. Here is the error todd-andrewss-macbook:shiftly toddOld$ gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/toddOld/.rvm/r...

learning RoR, can someone explain this boot.rb from H**ll?

I am looking at this boot.rb file: http://github.com/bestbuyremix/BBYIDX/blob/master/config/boot.rb And after trying to understand it, it is as if I have learned nothing so far. Can someone detail what is going on here? I have no idea how someone could even come up with this? # Don't change this file! # Configure your app in config/...

Is there something wrong with this python code, why does it run so slow compared to ruby?

I was interested in comparing ruby speed vs python so I took the simplest recursive calculation, namely print the fibonacci sequance. This is the python code #!/usr/bin/python2.7 def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1)+fib(n-2) i = 0 while...

RegexpError: Stack overflow in regexp matcher

I have small problem with a simple tokenizer regex: def test_tokenizer_regex_limit string = '<p>a</p>' * 400 tokens = string.scan(/(<\s*tag:.*?\/?>)|((?:[^<]|\<(?!\s*tag:.*?\/?>))+)/) end Basically it runs through the text and gets pairs of [ matched_tag , other_text ]. Here's an example: http://rubular.com/r/f88JBjfzFh Works f...

Testing part of a method with rspec

In this usps ruby gem, how should we write the following address specs: it "should build the HTTP request" # given a hard-coded address it "should parse the XML response" # given a hard-coded response I know how to get the specs to work by breaking the standardize function up into parts, but I don't want to do that because it's unnece...

How to have searchlogic initialize with no records

...

Find websites returning 503 response codes

Hi, Where can I find pages returning 503 codes so I can test a script I'm working on? Thanks ...

How to see if a website is down? - Ruby

Hi, How to create a script that checks if a website is down? something similar to http://downforeveryoneorjustme.com/ ...

ruby: how to load .rb file in the local context

How this simple task can be done in Ruby? I have some simple config file === config.rb config = { 'var' => 'val' } I want to load config file from some method, defined in main.rb file so that the local variables from config.rb became local vars of that method. Something like this: === main.rb Class App def loader load('co...

Looking for a multiple language IDE that handles incomplete code gracefully.

I program primarily in Ruby and C#. I'd like a code editor that can gracefully deal with incomplete code; by that I mean a code editor that doesn't protect itself from syntax errors by auto-adding matching braces and quotes, but one that pays attention to the tokens you add, and identifies that an unmatched quote doesn't mean it should s...

How do you use the FXMatrix class?

I am trying to format my calculator that I made in FXRuby and right now all the buttons are in one column and so I was wondering how I could use the FXMatrix class so that I can format the buttons into a much more appealing setting. Heres what the program looks like right now: require 'fox16' include Fox class Calc 50, :padRight => 5...

Ruby - Open file, find and replace multiple lines

I'm new to ruby and was hoping someone could help me figure out how to open a file, then using gsub to find and replace by multiple conditions. Here's what I got so far but this doesn't seem to work as the 2nd replace var overrides the first: text = File.read(filepath) replace = text.gsub(/aaa/, "Replaced aaa with 111") replace = text....

rails link_to :remote from within ajax-loaded content

Hey everyone, I'm working on an application and I'm having difficulty with the new Rails 3 link_to. Here's the situation - I have two divs on my "home" page, and each div is populated at document.load with ajax. This works as expected. In the content of the pages I'm loading into these divs, I want to use the link_to... :remote => true ...

can't find/retrieve results from a specific table with datamapper

I am working on a sinatra app with datamapper connected to a mysql database and am having problems retrieving/finding records from only one specific table. I can insert into it with datamapper find but when I try to do @sleepEntries = Sleep_Log.all I get the following error: ArgumentError: argument out of range. When I load everything in...

RoR web tier with Java middle/backend

I'm looking for some advice/feedback about using different languages in a layered architecture. Right now the architecture in question is an all java stack (db, middle tier, and web tier) using Spring to tie everything together. We've been tossing around the idea of using Ruby on Rails for the web tier, but I'd like to know if anyone has...

ruby active_record primary key retrieval/custom primary key update

I'm working on a legacy database system where the primary key, for some strange reason, starts with 1 and is not set to AUTO INCREMENT and the next value is always max primary key + 1 (the primary key is still an integer). Furthermore, the primary key names are all custom and set by set_primary_key. Now I want to map ActiveRecord to it ...

Is there a way to see the current log file in RubyMine?

I think it would be great to be able to see log/development.log and maybe log/test.log in the same way you see the output of a running task or tests in RubyMine. Is it possible? ...

gem_original_require: no such file to load -- spec/rails

Hi All, I have a rails 2.3.8 app with rspec tests (not written by me, just trying to get them running). When I run "rake spec" I get this error: gem_original_require': no such file to load -- spec/rails (MissingSourceFile) I have the following rspec-related gems installed: rails (2.3.8, 2.3.5) rspec (2.0.1, 1.3.0, 1.2.9, 1.2.4) rsp...

save image from url by paperclip

please suggest me a way save image from url by paperclip. thanks ...