Thursday, March 18, 2010

[Rails] Current CentOS-Nginx-Passenger script?

I've got bits and pieces of old install scripts but the versions are
far out of wack!
Anyone recently view or use an install script for all these goodies?
Many thanks,
David

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: render a Google Chart to a file

On Mar 18, 9:00 pm, Adam Ziemba <li...@ruby-forum.com> wrote:
> Colin Law wrote:
> >     open("http://chart.apis.google.com/chart#{CGI.escape('?cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun |Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12')}")
> > do |chart|
> >       File.open('chart.png', 'w') {|f| f.write chart.read }
> >     end
>
> I definitely understand the why you would want to escape the URI, but
> I'm not convinced that this approach will never work.
>
> The URL with the escaped characters causes Google to reject it as
> invalid parameters, which is why you got all that HTML and Javascript.
> E.g. if you use your browser to open the result of the above URI with
> escaped characters:
>
> http://chart.apis.google.com/chart%3Fcht%3Dbvg%26chbh%3Da%26chd%3Ds%3...
>
> You are redirected to the Google chart API. Retaining the original
> characters with:
>
> http://chart.apis.google.com/chart?cht=bvg&chbh=a&chd=s:vttusty&chs=5...Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12
>
> you'll get a PNG image and nothing else.
>
> Okay, so Google doesn't want the escaped characters, and the URI::open
> method doesn't want the plain characters... or does it? Is there no way
> around this? The thing is the characters used in the URL above are
> valid, or so I thought. I pass these kind of characters as parameters
> from controller to view all throughout my application, with full browser
> compatibility.
>
> I tried using backslashes for all the characters, e.g. "\&" instead of
> "&" and the URI open method still rejects it.
>
> I've seen some people successfully get images to save to the file system
> using URI, but I'm assuming all their code is outdated as I could not
> get it to work. Also, the image URL they were using actually pointed to
> a PNG image, with a PNG extension, whereas the Google Chart URL will
> return a PNG image.
>
> I appreciate all the help!
> --
> Posted viahttp://www.ruby-forum.com/.

Seems an inadequacy of Ruby URI library. Curb (Ruby libcurl bindings)
works simply and easily though:

ruby-1.9.1-p376 > require 'open-uri'
=> true
ruby-1.9.1-p376 > png = "http://chart.apis.google.com/chart?
cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|
Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12
"
=> "http://chart.apis.google.com/chart?
cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|
Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12
"
ruby-1.9.1-p376 > open png
URI::InvalidURIError: bad URI(is not URI?):
http://chart.apis.google.com/chart?cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12
from /home/xeno/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/uri/
common.rb:156:in `split'
from /home/xeno/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/uri/
common.rb:174:in `parse'
from /home/xeno/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/uri/
common.rb:626:in `parse'
from /home/xeno/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/open-
uri.rb:32:in `open'
from (irb):3
from /home/xeno/.rvm/ruby-1.9.1-p376/bin/irb:15:in `<main>'
ruby-1.9.1-p376 > require 'curb'
=> true
ruby-1.9.1-p376 > c = Curl::Easy.perform png
=> #<Curl::Easy http://chart.apis.google.com/chart?cht=bvg&chbh=a>
ruby-1.9.1-p376 > File.open("png.png", "w") {|f| f.write c.body_str}
=> 5445
ruby-1.9.1-p376 >

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Symbol as array index error ?

On Mar 18, 8:07 pm, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Mar 19, 12:37 am, Dudebot <craign...@gmail.com> wrote:> Sorry for being so dense, but why does
>
> > @monkey.delete_if{ |k,v| v[ "value" ] == '' }
>
> > Throw the same error?  Any idea what the proper syntax would be to
> > delete the element for which value is blank?
>
> Shouldn't do - apart from anything else you're not using any symbols
> in this one, and it seems to work ok on my machine.

I haven't been able to get a strategy which deletes, but have been
able to get a building strategy:

@purple = {}
@monkey.each { |k,v| @purple[ k ] = v if !v[ :value ].blank? }

which works.

Any ideas how to get syntax working which deletes instead of builds..
because I'm obsessive compulsive :)

TIA,
Craig

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Symbol as array index error ?

On Mar 19, 12:37 am, Dudebot <craign...@gmail.com> wrote:
> Sorry for being so dense, but why does
>
> @monkey.delete_if{ |k,v| v[ "value" ] == '' }
>
> Throw the same error?  Any idea what the proper syntax would be to
> delete the element for which value is blank?
>
Shouldn't do - apart from anything else you're not using any symbols
in this one, and it seems to work ok on my machine.

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Re: render a Google Chart to a file

Colin Law wrote:

> open("http://chart.apis.google.com/chart#{CGI.escape('?cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12')}")
> do |chart|
> File.open('chart.png', 'w') {|f| f.write chart.read }
> end

I definitely understand the why you would want to escape the URI, but
I'm not convinced that this approach will never work.

The URL with the escaped characters causes Google to reject it as
invalid parameters, which is why you got all that HTML and Javascript.
E.g. if you use your browser to open the result of the above URI with
escaped characters:

http://chart.apis.google.com/chart%3Fcht%3Dbvg%26chbh%3Da%26chd%3Ds%3Avttusty%26chs%3D500x300%26chxt%3Dx%2Cy%26chxl%3D0%3A%7CSun%7CMon%7CTue%7CWed%7CThu%7CFri%7CSat%7C1%3A%7C0%7C2%7C4%7C6%7C8%7C10%7C12

You are redirected to the Google chart API. Retaining the original
characters with:

http://chart.apis.google.com/chart?cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12

you'll get a PNG image and nothing else.


Okay, so Google doesn't want the escaped characters, and the URI::open
method doesn't want the plain characters... or does it? Is there no way
around this? The thing is the characters used in the URL above are
valid, or so I thought. I pass these kind of characters as parameters
from controller to view all throughout my application, with full browser
compatibility.

I tried using backslashes for all the characters, e.g. "\&" instead of
"&" and the URI open method still rejects it.

I've seen some people successfully get images to save to the file system
using URI, but I'm assuming all their code is outdated as I could not
get it to work. Also, the image URL they were using actually pointed to
a PNG image, with a PNG extension, whereas the Google Chart URL will
return a PNG image.


I appreciate all the help!
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Symbol as array index error ?

On Mar 18, 4:59 pm, Frederick Cheung <frederick.che...@gmail.com>
wrote:

> Because @monkey is a hash what gets yielded to you is an array, the
> first element is the key (ie '133' or '145') and the second is the
> value, whereas your code seems to assume that x is a hash.

Sorry for being so dense, but why does

@monkey.delete_if{ |k,v| v[ "value" ] == '' }

Throw the same error? Any idea what the proper syntax would be to
delete the element for which value is blank?

TIA,
Craig

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Rails + Mysql

On Mar 18, 12:36 am, Conrad Taylor <conra...@gmail.com> wrote:
> José, can you verify that MySQL is running by doing the following:
>
> $ mysql -u<username>

Yes it's running...

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.