Hello, I''ve been toying with my regex for a while and still has some problem with this. I would like to get the web hostname of URLs : "get_domain(url) ": such as: http://yahoo.com --> yahoo.com http://www.yahoo.com/ --> www.yahoo.com http://www.yahoo.com/cool/dir --> www.yahoo.com http://sub1.sub2.google.com --> sub1.sub2.google.com http://sub1.sub2.google.com/abc/def/aa?? --> sub1.sub2.google.com I would appreciate any help and pointer. Thanks in advance!! Thanks, -Chris --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, 2008-07-25 at 19:17 -0700, Chris Nowlan wrote:> Hello, > > I''ve been toying with my regex for a while and still has some problem > with this. > > I would like to get the web hostname of URLs : "get_domain(url) ": > > such as: > > http://yahoo.com --> yahoo.com > http://www.yahoo.com/ --> www.yahoo.com > http://www.yahoo.com/cool/dir --> www.yahoo.com > http://sub1.sub2.google.com --> sub1.sub2.google.com > http://sub1.sub2.google.com/abc/def/aa?? --> sub1.sub2.google.com > > I would appreciate any help and pointer. Thanks in advance!!---- split(''/'')[2]>> @a="http://www.yahoo.com"=> "http://www.yahoo.com">> @b="http://www.yahoo.com/cool/dir"=> "http://www.yahoo.com/cool/dir">> @c="http://sub1.sub2.google.com/abc/def/aa"=> "http://sub1.sub2.google.com/abc/def/aa">> @c="http://sub1.sub2.google.com/abc/def/aa"^C >> @a.split(''/'')[2]=> "www.yahoo.com">> @b.split(''/'')[2]=> "www.yahoo.com">> @c.split(''/'')[2]=> "sub1.sub2.google.com" 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wow, that was easy. Thanks for sharing your ruby-fu :) On 25 Jul, 19:31, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> On Fri, 2008-07-25 at 19:17 -0700, Chris Nowlan wrote: > > Hello, > > > I''ve been toying with my regex for a while and still has some problem > > with this. > > > I would like to get the web hostname of URLs : "get_domain(url) ": > > > such as: > > > http://yahoo.com --> yahoo.com > > http://www.yahoo.com/ -->www.yahoo.com > > http://www.yahoo.com/cool/dir -->www.yahoo.com > > http://sub1.sub2.google.com --> sub1.sub2.google.com > > http://sub1.sub2.google.com/abc/def/aa?? --> sub1.sub2.google.com > > > I would appreciate any help and pointer. Thanks in advance!! > > ---- > split(''/'')[2] > > >> @a="http://www.yahoo.com" > > => "http://www.yahoo.com">> @b="http://www.yahoo.com/cool/dir" > > => "http://www.yahoo.com/cool/dir">> @c="http://sub1.sub2.google.com/abc/def/aa" > > => "http://sub1.sub2.google.com/abc/def/aa">> @c="http://sub1.sub2.google.com/abc/def/aa"^C > >> @a.split(''/'')[2] > => "www.yahoo.com" > >> @b.split(''/'')[2] > => "www.yahoo.com" > >> @c.split(''/'')[2] > > => "sub1.sub2.google.com" > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
On Jul 25, 2008, at 10:31 PM, Craig White wrote:> On Fri, 2008-07-25 at 19:17 -0700, Chris Nowlan wrote: >> Hello, >> >> I''ve been toying with my regex for a while and still has some >> problem >> with this. >> >> I would like to get the web hostname of URLs : "get_domain(url) ": >> >> such as: >> >> http://yahoo.com --> yahoo.com >> http://www.yahoo.com/ --> www.yahoo.com >> http://www.yahoo.com/cool/dir --> www.yahoo.com >> http://sub1.sub2.google.com --> sub1.sub2.google.com >> http://sub1.sub2.google.com/abc/def/aa?? --> sub1.sub2.google.com >> >> I would appreciate any help and pointer. Thanks in advance!! > ---- > split(''/'')[2] > >>> @a="http://www.yahoo.com" > => "http://www.yahoo.com" >>> @b="http://www.yahoo.com/cool/dir" > => "http://www.yahoo.com/cool/dir" >>> @c="http://sub1.sub2.google.com/abc/def/aa" > => "http://sub1.sub2.google.com/abc/def/aa" >>> @c="http://sub1.sub2.google.com/abc/def/aa"^C >>> @a.split(''/'')[2] > => "www.yahoo.com" >>> @b.split(''/'')[2] > => "www.yahoo.com" >>> @c.split(''/'')[2] > => "sub1.sub2.google.com" > > CraigOr, require ''uri'' url = "http://sub1.sub2.google.com/abc/def/aa?param1=foo¶m2=bar" URI.parse(url).host => "sub1.sub2.google.com" -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Nowland
2008-Aug-24 23:24 UTC
Simple Persistence for ruby (without using Activerecord?)
Hello, Hope everyone''s doing great. I have a simple problem and maybe someone could help -- my requirement is pretty simple: o I do a lot of scripting in Ruby, for plumbing our Rails web and Java legacy applications. o I need to persist [string1,string2,string3] data, such as: "apple", "november", "5" o I do this quite often with different data sets o Performance is not a major concern o Simplicity is best o I need to be able to retrieve them and update them easily I have been using ActiveRecord (object.new, object.save, etc) to do this with a table with 3 columns, however I found it a bit too heavy-duty for this simple purpose because I have to use different databases since the data are in different locations.. I wonder if anyone could share some Ruby-Fu or a Ruby library tips on this. Thanks in advance! Chris ------ Buy text links SEO : http://www.ask2link.com/market_place?cnow Sell text links : http://www.ask2link.com/refer/rails ------ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2008-Aug-25 00:25 UTC
Re: Simple Persistence for ruby (without using Activerecord?)
On Mon, Aug 25, 2008 at 1:24 AM, Chris Nowland <chrisnow7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> o I need to persist [string1,string2,string3] data, such as: > "apple", "november", "5" > o I do this quite often with different data sets > o Performance is not a major concern > o Simplicity is best > o I need to be able to retrieve them and update them easilyFor such simple persistence Marshal may do: data = %w(foo bar baz) File.open(''data.db'', ''wb'') do |fh| fh.write(Marshal.dump(data)) end File.open(''data.db'', ''rb'') do |fh| data = Marshal.load(fh.read) end --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-25 09:19 UTC
Re: Simple Persistence for ruby (without using Activerecord?)
On Aug 25, 1:25 am, "Xavier Noria" <f...-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> On Mon, Aug 25, 2008 at 1:24 AM, Chris Nowland <chrisn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > o I need to persist [string1,string2,string3] data, such as: > > "apple", "november", "5" > > o I do this quite often with different data sets > > o Performance is not a major concern > > o Simplicity is best > > o I need to be able to retrieve them and update them easily > > For such simple persistence Marshal may do: >Or yaml if human readability is important (and easier to read on other platforms) 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---