Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
About Us Register FAQ Members List Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old September 3rd, 2003   #1 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
ngemus quote script

is it stored in a database or in a text file, if its in text can i have a copy 'cause there all really great quotes.
elachys is offline   Reply With Quote
Old September 3rd, 2003   #2 (permalink)
Registered User
 
scottlc's Avatar
 
Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
Re: ngemus quote script

You can find quotes easy if you ask Google.
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10
scottlc is offline   Reply With Quote
Old September 3rd, 2003   #3 (permalink)
Registered User
 
GSDragoon's Avatar
 
Join Date: Oct 2001
Location: Ohio
Posts: 1,970
Re: ngemus quote script

I would like a copy of the too. I was keeping a txt file of the really good ones, but my comp took a crap last week and I had to format without able to back anything up. But at least they're back on the main page.
__________________

Athlon64 3400+ @10.5x250MHz, 2.625GHz | DFI NF3 250GB
2x512 Corsair pc3200 | BFG FX6800 OC 128MB | X-Fi XtremeGamer
GSDragoon is online now   Reply With Quote
Old September 4th, 2003   #4 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
Re: ngemus quote script

i know how to make a quote script that not the question, this question is that i like the quotes and would like a copy ! Ž_Ž
elachys is offline   Reply With Quote
Old September 7th, 2003   #5 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: ngemus quote script

I would hope they are stored in the database, for speed... and, you can probably find a great list if you just copy one of them and shuck it into Google with "s around it. Maybe add "quotes" to the query... you'll find a lot, I'm sure.

-[Unknown]
[Unknown] is offline   Reply With Quote
Old September 7th, 2003   #6 (permalink)
Registered User
 
scottlc's Avatar
 
Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
Re: ngemus quote script

Actually, in this situation using a database would not give speed increase since you are only reading the data and not querying the data.

For quotes:
http://www.brainyquotes.com/
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10
scottlc is offline   Reply With Quote
Old September 7th, 2003   #7 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
Re: ngemus quote script

thanks for the info, i thought database for speed also but then i thought a txt file would be easier to add quotes to.
elachys is offline   Reply With Quote
Old September 7th, 2003   #8 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: Re: ngemus quote script

Quote:
Originally Posted by scott_uk5
Actually, in this situation using a database would not give speed increase since you are only reading the data and not querying the data.

For quotes:
http://www.brainyquotes.com/
Yes, but if you have a long list of items, it being indexed can greatly increase the speed of things.

File based method:
PHP Code:
$quotes file('quotes.txt');
echo 
trim($quotes[rand(0count($quotes) - 1)]); 
(slow)

Database method:
PHP Code:
SELECT quoteauthor
FROM quotes 
ORDER BY RAND
()
LIMIT 1 
(faster because there's less database access, and the file will be cached better by MySQL.)

Full files and eval'd data are faster as flat files, however.

-[Unknown]
[Unknown] is offline   Reply With Quote
Old September 8th, 2003   #9 (permalink)
Registered User
 
scottlc's Avatar
 
Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
Re: ngemus quote script

But if you store them in seperate files:

Code:
$number = int(rand(9)) + 1;
open(FILE, "<$number.txt");
print while <FILE>;
close FILE;
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10
scottlc is offline   Reply With Quote
Old September 8th, 2003   #10 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: Re: ngemus quote script

Quote:
Originally Posted by scott_uk5
But if you store them in seperate files:

Code:
$number = int(rand(9)) + 1;
open(FILE, "<$number.txt");
print while <FILE>;
close FILE;
True, but then you limit yourself - your example can only have a fixed number of quotes. Plus, you'll fill the directory with a kabillion files, and the shear file access alone might slow your server. (because it will be harder to cache a lot of files than a single file.)

-[Unknown]
[Unknown] is offline   Reply With Quote
Old September 8th, 2003   #11 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
Re: ngemus quote script

unless they have a section in the admin panel then inputing them into a database would be a load of crap and even with that you'd have to put them in one at a time so unless they have no life then there is no scence to that methot, a txt file although slower would be alot easier to update and make the initial file for and thus they still have a life. besides since you mainly build a site for the 56K user (which is what most people use, although some may question this) it wouldn't make anysort of noticable difference to the speed .
elachys is offline   Reply With Quote
Old September 8th, 2003   #12 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: Re: ngemus quote script

Quote:
Originally Posted by little knipper
unless they have a section in the admin panel then inputing them into a database would be a load of crap and even with that you'd have to put them in one at a time so unless they have no life then there is no scence to that methot, a txt file although slower would be alot easier to update and make the initial file for and thus they still have a life. besides since you mainly build a site for the 56K user (which is what most people use, although some may question this) it wouldn't make anysort of noticable difference to the speed .
That kind of thinking is what makes programs and sites slow. Every thing adds up, and before long you've added .05 seconds to the load time. (which is noticable, especially when the load gets higher and more people are browsing, ie. on sites like this.)

It would not be that difficult, you just parse the stupid text file into a few inserts (read in the lines and output every 500 or so as inserts.) and then chug it in top the database. Just because you use phpMyAdmin and prefer to insert manually for some reason doesn't mean everyone does.... how do you think this forum works? Some fool inserts every post as it's made?

It can easily be done - admin interface or not - and it's faster... so there's no reason to limit yourself.

Sorry, I was a bit sarcastic - I've had a bad day so far... didn't mean anything by it.

-[Unknown]
[Unknown] is offline   Reply With Quote
Old September 9th, 2003   #13 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
Re: ngemus quote script

>>
Sorry, I was a bit sarcastic - I've had a bad day so far... didn't mean anything by it.
hey no problem at least your willing to argue your point, i also think its nice that you think bobbi and the others don't have lives and would rather enter hundreds of quotes all day
personally since i have 8 months to do 2 years worth of work (i'm a last year GCSE studient )
i'd love to know how bobbi and the staff have time to even moderate the forums let alone spend a couple of hours a week updating the quotes.
hehe i had a bad day as well and its only 8 in the morning
elachys is offline   Reply With Quote
Old September 9th, 2003   #14 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: ngemus quote script

Quote:
Originally Posted by little knipper
i'd love to know how bobbi and the staff have time to even moderate the forums let alone spend a couple of hours a week updating the quotes.
hehe i had a bad day as well and its only 8 in the morning
Heh... happens to the best of us . Moderating a forum is hard - I should know, I'm an administrator on like 5 of them.

And... are the quotes ever updated?

Anyhow... to show some proof, you could just parse the file like so: (I'm not a fan of obfusication, so I'll give PHP not Perl :P.)
(note that this is rough, it's not like I'm planning to package and distribute this :P.)
PHP Code:
$quotes file('quotes.txt'); // Get the file, split by newlines.
$count_quotes count($quotes); // Don't recalculate each iteration.
$query '';
for (
$i 0$i $count_quotes$i++)
{
    
$query .= '
    (' 
addslashes(rtrim($quotes[$i])) . '),';

    if ((
$i 1) % 50 == 0)
    {
        
mysql_query('
  INSERT INTO quotes (quote)
  VALUES' 
substr($query0, -1));
        
$query '';
    }

However ugly that may look, that could easily and quickly insert all the quotes right into the database. You can administrate them qith simple queries like this: (assuming you put a quote_id column on the table that was auto_increment..)

# Get the ID of a quote for editing or something.
SELECT quote_id
FROM quotes
WHERE quote LIKE '%Einstein%';

# Change something in all quotes.
UPDATE quotes
SET quote = REPLACE(quote, 'Einstein', 'Onemug');

So... I don't see how this is harder to work with... the SQL query aspect only seems to make it easier than the clunky "search and replace" tools of text editors.

-[Unknown]
[Unknown] is offline   Reply With Quote
Old September 9th, 2003   #15 (permalink)
Registered User
 
scottlc's Avatar
 
Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
Re: ngemus quote script

What's wrong with Perl? It is easy to read.
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10
scottlc is offline   Reply With Quote
Old September 9th, 2003   #16 (permalink)
Registered User
 
elachys's Avatar
 
Join Date: Jan 2003
Location: England, drinking tea.
Posts: 547
Re: ngemus quote script

ok fine you've shown off enough
i'll shut up and leave you alone
elachys is offline   Reply With Quote
Old September 10th, 2003   #17 (permalink)
Nice to met you! ^_^
 
Kingo's Avatar
 
Join Date: Aug 2002
Location: Mexico B.C.
Posts: 278
Re: ngemus quote script

Try downloading e-books use a p2p or google
there itīs a lot of info out there.
__________________
MegaKore By Kingo
Kingo is offline   Reply With Quote
Old September 10th, 2003   #18 (permalink)
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 53
Re: Re: ngemus quote script

Quote:
Originally Posted by little knipper
ok fine you've shown off enough
i'll shut up and leave you alone
Eh?

Sorry, I was meaning to help. Got on a side arguement... didn't mean to "push you out of the way" so to speak...

That's how you'd do it though - it's tough at first (for everyone, me, you, Bill Gates, etc.) but that's only more reason to go ahead and do it..

-[Unknown]
[Unknown] is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 21:38.

© 2006 - 2008 Emu Forums | About Emu Forums | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.7.0 Release Candidate 3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5