taelor | 1 Aug 2007 01:08
Picon
Gravatar

clean urls, without directory structures....not sure what its called.

I have just recently learned the practice of clean uri/urls, combined
with ruby's string manipulation is a great way to pass open/
insensitive data. right now i have just one page, that controls my
whole site, except for index files that just pass the directory that
its located in to the one page that controls the whole site based on
the url address.

I find myself having to write scripts to make directories and copy the
same index page over and over and over.

I think a more elegant solution would be to handle any uri/url without
having the directory structure below.

Now I do know that maybe I'm posting in the wrong place and should be
at the local web server forum, but it probably still has to do with
some sort of apache/ruby based configuration? Maybe in the Add
Handlers section?

I tried searching some things, but I couldn't come up with the name of
this design pattern, or which site I think used it.

Thanks for any help,
taelor

Gordon Thiesfeld | 1 Aug 2007 01:20
Picon
Gravatar

Re: help with string matching

>  <at> calendar1 is a gtk calendar widget, and within ruby calling
>  <at> calendar1.date
> returns the date as 2007730, which caused Date.parse to crash as there
> is only 1 part instead of the expected 3. That is why I used the
>  <at> calendar1.year  <at> calendar1.month  <at> calendar1.day, but  <at> calendar1.month
> returns 0 based months, which is why I used  <at> calendar1.month + 1, which
> works, but looks sloppy.

Ahh, I made some pretty bad assumptions about what you were trying to
do.  I'm sorry.

> So, how would you parse a date formated as 2007730 into 2007-06-30? I
> know that I could parse it out manually, but I'm assuming there is a
> more elegant solution.
>

I guess I would do this:

Date.civil( <at> calendar1.year,  <at> calendar1.date + 1,  <at> calendar1.day).to_s

Dan Daniels | 1 Aug 2007 01:31
Picon

Re: help with string matching

Gordon Thiesfeld wrote:

> 
> Ahh, I made some pretty bad assumptions about what you were trying to
> do.  I'm sorry.
> 
>> So, how would you parse a date formated as 2007730 into 2007-06-30? I
>> know that I could parse it out manually, but I'm assuming there is a
>> more elegant solution.
>>
> 
> I guess I would do this:
> 
> Date.civil( <at> calendar1.year,  <at> calendar1.date + 1,  <at> calendar1.day).to_s

Oh, no. Your suggestions were great. I combined your earlier suggestions 
and came up with this:

logdate = Time.local( <at> calendar1.year,  <at> calendar1.month + 
1, <at> calendar1.day).strftime('%Y-%m-%d').to_s

which works the same as what you just mentioned:

logdate = Date.civil( <at> calendar1.year,  <at> calendar1.month + 1, 
 <at> calendar1.day).to_s

Thanks a ton!

Dan
--

-- 
(Continue reading)

Harry Kakueki | 1 Aug 2007 01:49
Picon

Re: Multiple matching with ()*

On 7/31/07, Alessandro Re <akirosspower <at> gmail.com> wrote:
> while i need to be sure that the pattern begins with a regex "x" and
> ends with "z"
>
> (of course, x 1 a 2 b 3 c should be regexes not just chars)
>
Sorry, I misunderstood what you wanted.
Is this more like it?

str = "lol1a2vasd"
m = /^(\w{3})(.*)(\w{3})$/.match(str).captures
m[1] = m[1].scan(/\d\w/)
p m.flatten #>  ["lol","1a","2v","asd"]

Harry

--

-- 
A Look into Japanese Ruby List in English
http://www.kakueki.com/

Dan Zwell | 1 Aug 2007 02:02
Picon

Re: problems with archive-tar-external

Bram Kuijper wrote:
> #!/usr/bin/env ruby -w
> require 'rubygems'
> require 'archive/tar_external'
> Include Archive
> 
> ...
"include" has a lower case "i".

Dan Zwell | 1 Aug 2007 02:23
Picon

change method Array.new? (Was: Unexpected behavior with multidimensional arrays)

What would you guys think about removing the second parameter from 
Array.new ? I suggest this for 2 reasons:

If the object is a pass-by-copy class such as
   Array.new(n, true), or Array.new(n, 23)
then this syntax is exactly the same as
   Array.new(n) {true}, or Array.new(n) {23}

If the object is a pass-by-reference, such as
   Array.new(n, Klass.new)
this can be represented by
   k=Klass.new
   Array(n) {k}
This syntax is less pretty, but does anybody even Array.new this way? 
It's a sort of nice piece of syntactic sugar, but I don't see how it's 
actually useful. Please correct me if I'm wrong about this.

If all of the above is true, I would suggest removing the second 
parameter from this method, because it confuses plenty of newcomers.

Thanks,
Dan

Sam Morrison | 1 Aug 2007 03:08

Re: clean urls, without directory structures....not sure what its called.

On 8/1/07, taelor <thredden <at> gmail.com> wrote:
>
> I think a more elegant solution would be to handle any uri/url without
> having the directory structure below.
>

Take a look at your .htaccess file. You could easily set up some rewrite
rules that redirect everything to a particular file. In your case, to your
index page.

--
sam
Marc Heiler | 1 Aug 2007 03:12

Re: Requiring more than one file?

Hi,

I guess I should have phrased my question differently, seeing that it 
spawned
side-questions including an even ... rather ... odd ... notice that "the 
world isn't going to run out of carriage returns or line feeds any time 
soon ...."

The question should have simply been:

  Why does require allow only one argument?

--

-- 
Posted via http://www.ruby-forum.com/.

Dan Zwell | 1 Aug 2007 03:28
Picon

Re: Bug that eats sql

Tom Bak wrote:
> Hi,
> I might have found bug that eats sql.
> 
> I can manualy execute this code on "Company$NCustomers" view:
> 
> UPDATE "Company$NCustomers" SET name = 'test' WHERE no_ = '100087'
> 
> But then i do that in rails, the attribute is not set:
> 
> 
> n = User.find_by_username('ncustomer2').n_customer; n.name = 'test
> chagne'; n.save
> 

You'll have better luck with your question in the Rails forum/mailing 
list. I don't know the URL, but google can probably help with that.

Dan

joviyach | 1 Aug 2007 03:40
Picon

Any experience with Bluehost?

I am looking for hosting for RoR, but I'd also like to be able to do
some PHP with MySQL on the same account as well. I have been looking
at Bluehost. Does anyone have anything comments good or bad about
them?

Thanks,

Jim


Gmane