I'm not a Ruby guy, I just play one on television. I have to modify someone's old Cron job to pull down some JSON and convert it into objects.
Here's the code
raw_json = Net::HTTP.get(URI.parse("url removed to protect the innocent"))
tags = ActiveSupport::JSON.decode(raw_json)
puts tags.count
tags.count will accurately trace as 5, ...
I have a binary file, inside of which has multiple frames. Each frame starts with FF FF FF followed by random data of varying length. For example:
FF FF FF XX XX XX XX ......... FF FF FF XX XX XX XX XX XX ......... FF FF FF XX XX XX .... FF FF FF XX XX XX XX XX XX XX XX XX ........
It's safe to assume that FF FF FF will only appear in ...
Hey there,
as i don't want to spend another hour googling forthe right regex: I want to remove the last backslash of a given string with gsub:
"C:\Program Files\".gsub(fancy_regex_here, '') # => "C:\Program Files"
Thanks in advance for any help
...
proc = Proc.new do |name|
puts "Thank you #{name}!"
end
def thank
yield
end
proc.call # output nothing, just fine
proc.call('God') # => Thank you God!
thank &proc # output nothing, too. Fine;
thank &proc('God') # Error!
thank &proc.call('God') # Error!
thank proc.call('God') # Error!
# So, what should I do if I have to pass the ...
In my program Im getting an error which says ./ruby_camping.rb:91:in `-': nil can't be coerced into Fixnum (TypeError). What I would like to do is to checkout a guest that I have just checked in. Here is the block of code for the checkout part:
def self.check_out
puts "Welcome to checkout!"
puts $camping.current_guests
puts " Her...
So, I upgraded Ruby to 1.8.7 to make a particular gem work. Hooray, it works now! But...now rails doesn't. I tried reinstalling rails through gem, but that hasn't helped, either. Rake is no longer recognized by my windows box as a valid command, and I can't even start the server without a whole string of errors.
My only thought is that...
I'm working on a plugin for Rails3. I'd like to allow users to override some settings. At the moment I'm doing this inside my plugin's Rails::Engine class like:
config.my_setting = :default_value unless config.respond_to? :my_setting
This seems like the wrong way to handle this. Is there a better method or convention most plugins use ...
As of the other day everything was working with Facebook Connect. Now I have to click "Connect" twice for it log me in.
...
I want to have datepicker in search text fields and eventually also in edit fields of jqgrid on a Ruby on Rails application.
Is there any way ?
Has any one used such combination ? Datepicker with jqGrid ?
...
Right now I have 3 files, but I'd like to do this in a way that I can add more later. Each file is a list of IDs, like this.
174535945
174538045
160515924
81712260
25241494
I'd like the output to be the items that appear in list 1 and list 2, list 2 and list 3, and those that occur in list 1 and list 2 and list 3.
Would the most ruby...
That's my code.
Now I need to SEND a cookie to the host but I can't find a solution.
def get_network_file(url=nil)
begin
http = Net::HTTP.new( @service_server, 80 )
resp, data = http.get( url, { "Accept-Language" => @locale } )
if resp.code.to_i != 200
RAILS_DEFAULT_LOGGER.error "*** return code != 200. code = #{...
I want to read metadata of already uploaded JPEGs on S3. Is there a way to do that in Ruby without downloading the file locally?
The problem I am facing is that Image(Mini)Magick doesn't take a URL as a source (or at least I didn't find the right command).
Update:
This is working:
>> image = MiniMagick::Image.from_file -path_to_file...
I have a Rails 3rc app on Ruby 1.9.2 that works fine, but Bundler keeps making a folder named "bandsintown" (bandsintown is a gem I use) in my project directory. From what I can tell, the folder has all my gems in it. I'm pretty sure that this never happened before. Is it normal behavior?
I think this might be interfering with running t...
As simple as it sounds, it seems like an extraordinarily complicated task.
...
Launching a summary technology and looking to generate analytics on the performance and usage of the different products offered. We have a widget, a bookmarklet, and soon a plugin. Need to see individual usage details and manipulate stats for meaningful performance analytics to make intelligent decisions on ux optimizing.
...
Is there a way to connect ruby to mssql without using DBI? Is there any native Ruby TDS lib that handles that?
...
I have features I would like to be portable between my own Rails applications.
I wonder if I should create a gem or a plugin for each feature I want to be portable (sharable).
They are just for Rails (for now) because they include css, html, js and image files.
But I have been wondering, the things provided with plugins could be provi...
Consider the following, StubFoo is a stub of Foo, which I wish to stub out for some tests.
class Runner
def run
Foo = StubFoo
foo = Foo.new
# using Foo...
end
end
This generates the following error message: Dynamic constant assignment
Yet, in RSpec I can do the following, which works and is perfectly legal:
i...
I'd like to change the pwd of the current shell from within a ruby script. So:
> pwd
/tmp
> ruby cdscript.rb
> pwd
/usr/bin
This is the code I have right now:
exec('cd /usr/bin')
Unfortunately, cd is a builtin command. So:
`exec': No such file or directory - cd (Errno:ENOENT)
Any workaround for this?
No way to get it working ...
Hey,
Ruby/Rails enjoy some really nice and powerful testing frameworks like Cucumber and RSpec.
Does Python/Django enjoy the same thing (I'm not talking about simple unit testing like PyUnit)?
Thanks for help and time.
...