All pastes #196976 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-10-11 00:23 UTC
rendered paste body
[05:33] * majd_ has joined #web
[05:34] <majd_> Hey, do you think it's worth it to write a mysql querying class such that my methods don't have to run any actual queries or do you think it's unnecessary overhead?
[05:34] <Zeros> That'd seem rather mean honestly, take her out on the date and be nice, just don't be flirty.
[05:34] <rixth> Does IE have problems with dynamically generated tables? http://rixth.dyndns.org/feed-grabber-display3.php look in IE and Firefox. http://rixth.dyndns.org/hashweb.html that is a direct copy & paste of the code generated by the javascript. How can I get the table to be all on one line?
[05:34] <sipher> dude.. Google's gonna have like 80% of the online video market now
[05:34] * murali has joined #web
[05:35] <hax> yeah, google wins
[05:35] <majd_> rixth: you're arabic?
[05:35] <Zeros> majd_, use ADODB, it'll do most of the leg work for you.
[05:35] <hax> can we not talk about youtube?
[05:35] <hax> sipher: honestly, half of us in here could have written youtube, and be billionaires
[05:35] <Zeros> Didn't we beat the YouTube thing to death like 8 hours ago?
[05:35] <hax> i just don't even wanna hear about it
[05:35] * jasonb has joined #web
[05:36] * Ocoth has joined #web
[05:36] <rixth> majd_, nope
[05:36] <sipher> Google's keeping their video site seperate apparently.. which is a huge mistake imo
[05:37] <majd_> Zeros: ADODB seems slower than straight up mysql, according to their benchmarks
[05:37] <sipher> nobody cares about Google Video. They should just merge them to avoid confusion
[05:37] <Zeros> majd_, well of course, since its abstracting the database for you. But it'll make it much easier to change to Postgres or something else later majd_
[05:37] <murali> Hi to all
[05:38] <majd_> i would use google video over youtube anyday
[05:38] <sipher> why?
[05:38] <rixth> Same.
[05:38] <Zeros> murali, hi to you
[05:38] <majd_> i like it, the videos resize to the size of the window, i can just download to ipod, it looks less cluttery than youtube
[05:38] <rixth> I hate the whole social network feel of YouTube.
[05:38] <Zeros> Google Video's search feature is quite a bit better.
[05:39] <sipher> They'll add all those features to YouTube
[05:39] <majd_> Zeros: tbh, is there a point in using a database abstraction layer?
[05:39] <Zeros> majd_, YES!
[05:39] <majd_> i guess the biggest thing is that the vids are bigger in google video
[05:40] <majd_> Zeros: heh, ok i'll do some more research
[05:40] <Zeros> majd_, you never know if you're going to need to change databases in the future, and with php there are 100 different functions for each database
[05:40] <Zeros> was it addslashes() mysql_escape_string() or mysql_real_escape_string() that I need?
[05:40] <sipher> I miss the play in place thumbnail previews on google video
[05:40] <majd_> haha
[05:40] <sipher> that they had for like a week
[05:41] <Zeros> majd_, with an abstraction layer you don't even have to care.
[05:41] <majd_> yeah i remember that sipher
[05:41] <majd_> Zeros: does it change the way i query the database? (i still haven't done the research, you could tell me to RTFM)
[05:41] * Zeros is waiting for mysql_extremely_escape_string() with php6
[05:42] <rixth> Lets help me.
[05:42] <Zeros> majd_, that depends how fancy your queries are, SELECT, UPDATE, DELETE syntax is pretty much the same for everyone if you follow the SQL standard.
[05:43] <majd_> Zeros: here's one of the more complex queries i need to use:
[05:43] <Zeros> JOIN syntax is generally the same too, though different dialects have different extensions for various things
[05:43] <Zeros> majd_, pastebin if its long
[05:43] <Zeros> :P
[05:43] <sipher> and hax, we couldn't have done it because none of us have the kind of money it would take to distribute the load and pay for bandwidth
[05:44] <Zeros> well they got Capital to do it
[05:44] <Zeros> and burned it waiting for someone to buy them
[05:44] <majd_> http://rafb.net/paste/results/kOEgs539.html
[05:44] <sipher> Zeros: Just read they make 200k/month
[05:45] <sipher> Which makes it seem like a really bad deal for Google
[05:45] <Zeros> majd_, that should work just fine on most databases, nothing there is special. Bind your parameters too (use prepared statements.) don't ever append parameters to the query string.
[05:46] <Zeros> as in don't pass the session_id() like that
[05:46] <majd_> Zeros: why not?
[05:46] <majd_> btw that last statement made no sense whatsoever
[05:47] <majd_> Zeros: i was thinking, changing a php script to python shouldn't be that hard
[05:47] <majd_> considering you use mostly functions you write
[05:47] <sipher> "Google stock rose 8.5% today based on rumors of the sale." <-- omg
[05:47] <Zeros> majd_, you could inject your database and that would be bad.
[05:47] <majd_> you can? i thought you can't fake the session_id
[05:48] <majd_> hence i didn't quote_smart() it
[05:48] <rixth> majd_, it's just a cookie...
[05:48] <majd_> and you can fake cookies?
[05:48] <majd_> oh well
[05:49] <Zeros> majd_, http://phplens.com/lens/adodb/docs-adodb.htm#bind
[05:49] <majd_> i'll just hope no one does anything bad till the rewrite comes live
[05:49] <Zeros> see how cool ADODB is? binding parameters is different with each database API for php, its all the same with ADODB
[05:49] <majd_> so binding=concatenating?
[05:50] <Zeros> not really
[05:50] <Zeros> its more like adding a place holder in the SQL string
[05:50] <Zeros> and you pass that to the server and it goes "ok heres the script of WHAT to do, and WHERE variables go"
[05:50] <Zeros> then you pass it the variables and it know what to do it WITH
[05:51] <majd_> oh so it's like printf() in C
[05:51] <Zeros> but if that variable contains something like "DELETE FROM users" the server won't even execute it, because its a variable, its not executable code.
[05:52] <majd_> You define two places for variables, the first variable you provide goes in the first placeholder, the second one in the second
[05:52] <Zeros> majd_, similar yeah; think like execf( "echo %i", my_bar );
[05:52] <majd_> yeah exactly
[05:52] <majd_> And that's better because mysql/adodb does checks on the variables?
[05:52] <Zeros> the server does the check
[05:53] <majd_> so i don't even need to worry about mysql injection?
[05:53] <Zeros> It eliminates almost all cases of it yes
[05:54] <majd_> wow
[05:54] <majd_> so many pointless function calls
[05:54] <hax> majd_: i could afford... maybe one share of goog
[05:55] <Zeros> like I've said before all the mysql_escape functions shouldn't even exist, the _only_ way to do a query with parameters should be binding.
[05:55] <Zeros> it'd save so much php code from security holes
[05:55] <majd_> hax: haha
[05:55] <hax> Zeros: from what i hear, rails jobs are becoming prevalent
[05:55] <majd_> Zeros: now when you say parameters, you mean variables..right?
[05:55] <hax> Zeros: a friend of mine was just looking for work as a php guy in north jersey/nyc
[05:55] <Zeros> majd_, yeah
[05:55] <hax> Zeros: and he said there were tons of people looking for ruby coders, especially for rails
[05:55] <majd_> ok
[05:56] <Zeros> hax, yeah its starting to grow in the market, its also a flavor of the month too, so keep your eye out. :)
[05:56] <murali> hey dudes give me a tip to search inserting an image in a tooltip dynamically on a web page
[05:56] <hax> Zeros: true
[05:57] <hax> Zeros: someone famous said that you should look out for companies hiring ruby/python/perl guys
[05:57] <hax> Zeros: because it means they're actually doing something
[05:57] <Zeros> haha
[05:57] <Zeros> Well I use ruby all the time to automate things at work even though we're a CF shop.
[05:57] <hax> damn, google maps should work in IE, right/
[05:57] <Zeros> yes
[05:58] <hax> heh, wtf am i doing wrong then
[05:58] <mikedub> ugh work
[05:59] <mikedub> ugh sleep
[05:59] <hax> i hear that
[05:59] <Zeros> majd_, A properly designed database abstraction layer will work wonders too, though I don't think ADODB is quite that powerful. Hibernate (its for Java) for instance implements a unified SQL dialect you can use that gets optimized into the SQL for the server you're using.
[06:00] <Zeros> CF's method unifies variable binding behind standard datatypes implemented by the driver and makes calling a stored procedure the same for every database
[06:00] <hax> majd_: for python you want sqlalchemy, i think
[06:00] <Davey> complex type 'operationType': The content model is not determinist. - anybody perhaps know what the heck this is?
[06:00] <mikedub> tonight i finally used something in a project I had originally learned in university. i think this marks the second time ever.
[06:01] <mikedub> man, that $40k i invested sure paid off.
[06:01] <Davey> lol
[06:01] * majd_ has quit IRC ("Leaving")
[06:01] * Ocoth has quit IRC (Read error: 145 (Connection timed out))
[06:02] * Ocoth has joined #web
[06:02] * majd_ has joined #web
[06:02] <rixth> Does IE have problems with dynamically generated tables? http://rixth.dyndns.org/feed-grabber-display3.php look in IE and Firefox. http://rixth.dyndns.org/hashweb.html that is a direct copy & paste of the code generated by the javascript. How can I get the table to be all on one line?
[06:02] <Zeros> mikedub, what was it?
[06:02] <majd_> Zeros: http://rafb.net/paste/results/Gm1lNX72.html
[06:02] <mikedub> modulus
[06:02] <majd_> that's what i have so far
[06:02] <mikedub> :P
[06:02] <hax> the operator?
[06:03] <Zeros> majd_, $this->$output_html don't use that syntax
[06:03] <hax> it's a fine operator, but i don't know if it's worth $40k
[06:03] <Zeros> never prefix a field name with $
[06:03] * mattmcc has quit IRC ("At least there is symmetry.")
[06:03] <Zeros> $foo->$bar is an error in php5
[06:03] <mikedub> well, yes the operator.. but i was thinking more like the theory behind it.
[06:03] <Zeros> $foo->bar is correct
[06:03] <majd_> Zeros: really?
[06:03] <Zeros> yes
[06:03] <mikedub> but you're right.. not worth 40k
[06:04] <majd_> omg
[06:04] <majd_> how did i make that kind of mistake?
[06:04] <Zeros> majd_, I'm assuming you're using php4 since that's what that code conforms to, but $foo->bar syntax will save you time and money later
[06:04] <mikedub> voodoo trickery
[06:04] <sipher> You guys seen the way to get peoples history in most browsers? You just add a bunch of top level links and check if the computed style color is visited.. and you know it's in the persons history. o_O You could use a server side script to grab the visited page, return all the links to the client, check if they're visited, return the visited to the server, grab those, repeat etc. to construct a list of links they navigated
[06:04] <mikedub> is $foo->{$bar} valid?
[06:04] <Zeros> mikedub, yeah who'd have thought you'd ever need the remainder?
[06:04] <Zeros> mikedub, if you want to dynamically access a field yes
[06:04] * Lapmann has joined #web
[06:04] <mikedub> interesting
[06:06] <mikedub> okay, well i'm gonna go to bed. gf has been there for a while now.
[06:06] <mikedub> damn bish ;/
[06:06] <Zeros> mikedub, however $foo->$bar is actually getting the field named bar from the object stored in $foo
[06:06] <majd_> Zeros: :%s/\$this->\$/\$this->/g
[06:06] <majd_> :-D
[06:06] <Zeros> why they allowed that in php4 I have no idea
[06:07] <mikedub> heh wtf
[06:07] <mikedub> typo
[06:07] <Zeros> majd_, get your head out of the Java world :|
[06:07] <majd_> g'night mikedub
[06:07] <mikedub> later
[06:07] <Zeros>  elseif($this->getDebugLevel() == 3) { }  elseif($this->getDebugLevel() == 4){} etc.
[06:08] <Zeros> use a switch()
[06:08] <GwaiLo> that looks more like vim than java
[06:08] <majd_> Zeros: =\
[06:08] <hax> ok, i think i'm out
[06:08] * merriam has quit IRC (Connection timed out)
[06:08] <Zeros> majd_, the swtich() is faster, and you do the same thing for a ton of those cases :P
[06:08] <Zeros> switch()
[06:08] <majd_> later has
[06:08] <majd_> *hax
[06:09] <Zeros> case 1: case 2: case 3: // shared stuff
[06:09] <Zeros> night hax
[06:09] <majd_> yeah yeah i know
[06:09] <majd_> lol
[06:09] <Zeros> :P
[06:09] <hax> peace bitches :)
[06:09] * xahlee has quit IRC
[06:10] <Zeros> Java has scarred many a programmer with its crippled switch() statement, C++ at least lets you use any non-object and C# lets you use strings too.
[06:10] * merriam has joined #web
[06:10] <Zeros> but no Java is still stuck in the dark ages with integers and enums
[06:11] <majd_> Zeros: yeah when i think OOP i think java, but in regular programming i use switches regularly
[06:11] <majd_> cau
[06:11] <majd_> cause most of my exposure to OOP was through java
[06:11] <Zeros> :)
[06:11] <Zeros> well you'll figure it out
[06:11] <majd_> is the code overall decent though?
[06:11] <Zeros> teaching Java as the first language in colleges I think is a mistake, since the language is so crippled
[06:11] <majd_> i tried really hard to make it slim
[06:12] * xahlee has joined #web
[06:13] <Zeros> majd_, why do Citations bind to a view?
[06:13] <Zeros> A citation should be agnostic of the view, the view should transform the citation. :)
[06:13] <majd_> Zeros: because they send HTML back to the viewer and add it to the object. I dont' want any classes apart from the View to handle the display of HTML
[06:13] * majd_ defines agnostic in google
[06:14] <Zeros> as in it doesn't care
[06:14] <Zeros> what happens if you want RSS instead?
[06:14] <majd_> A word first used by Professor Huxley, to indicate one who believes nothing which cannot be demonstrated by the senses.
[06:14] <majd_> wtf
[06:14] <Zeros> in a religious sense that's what it means
[06:14] <Zeros> I meant indifferent
[06:15] <majd_> ok, good question
[06:15] <majd_> hmmm
[06:15] <Zeros> your MlaCitation shouldn't create HTML
[06:15] <Zeros> it should just have fields
[06:15] <majd_> i'm tightly coupling the Citation class aren't i?
[06:15] <Zeros> to the view year
[06:15] <Zeros> -r
[06:15] <majd_> Zeros: this is the client code that i was shooting for
[06:15] <majd_> Citation::registerCitation(MlaCitationObject,$_POST)
[06:16] * Ocoth` has joined #web
[06:16] <majd_> wait...i don't define a view there....
[06:16] <Zeros> and that does?
[06:16] <majd_> i need to think
[06:16] * Ocoth has quit IRC (Read error: 145 (Connection timed out))
[06:16] <Zeros> write all your logic for the database and the user without ever even thinking about HTML presentation
[06:16] * Ocoth` is now known as Ocoth
[06:16] <Zeros> think about what does a Citation have, what parts does a MLACitation have
[06:17] <Zeros> it might have getAuthor() and getPublisher()
[06:17] <Zeros> etc.
[06:17] <Zeros> now your view takes a MLACitation object and it calls those methods and transforms it into the desired format
[06:17] <majd_> Zeros: I was having trouble with that part, having trouble figuring out the responsibilities of the Citation class as opposed to the MlaCitation class. What
[06:17] <Zeros> So you might have a view for RSS, a view for HTML
[06:18] <majd_> Zeros: so I would need to make a CitationView class? or embed that into the original View class?
[06:18] <rixth> Does IE have problems with dynamically generated tables? http://rixth.dyndns.org/feed-grabber-display3.php look in IE and Firefox. http://rixth.dyndns.org/hashweb.html that is a direct copy & paste of the code generated by the javascript. How can I get the table to be all on one line?
[06:18] <rixth> There are no <tr's> in sight, yet IE seems to be adding one.
[06:19] <Zeros> majd_, Well your smarty template formats the View into whatever you need
[06:20] <Zeros> so you could have a CitationView class that loads a specific smarty template and then passes it the Citation object (MLA,APA) and then the Smarty template formats it
[06:22] <majd_> So you're saying i pass an object into smarty?
[06:22] <Zeros> yes
[06:22] <Zeros> $citation = $user->getMLA()->getNewestCitation(); $view = new CitationView(CitationView::RSS); $view->render( $citation );
[06:22] <Zeros> now you have nicely formatted RSS for that citation
[06:22] <Zeros> pass CitationView::HTML and you get HTML back instead
[06:22] <majd_> Zeros: oh I Love it when you help me, you speak my language
[06:23] <Zeros> :)
[06:23] <majd_> ok i'm really tryin hard to get this straight. So the $user->getMLA()->getNewestCitation(); string would return an object?
[06:24] <majd_> whose attributes are the values of the various fields?
[06:24] <majd_> again, sorry for being slow
[06:24] <majd_> i'm kinda figuring this out as i go
[06:25] <murali> hi how to draw a gif image using javascript
[06:25] <Zeros> yes
[06:25] <Zeros> the object returned would be a MlaCitation which has methods like getAuthor(); getPublisher(); getTitle()
[06:25] <majd_> Zeros: but that would mean creating a class for every type of MLA citation...no?
[06:25] <majd_> cause different types of citations require different information
[06:26] <majd_> hence different attributes
[06:26] <Zeros> so either make different classes or make one class with lots of accessor methods that return null if that data isn't required for that type of citation
[06:27] <majd_> mhm, that's what i had in mind
[06:28] <Zeros> the way I presented it before I think was something like $user->getMLA()->getStyle(CitationStyle::FOO_STYLE)->getNewestCitation();
[06:28] <Zeros> and from that the MlaCitationsCollection (whats returned by getMLA) can have methods to get a specific style or all of them, or find by title, author etc.
[06:29] <sipher> murali: You can't
[06:29] * remi has joined #web
[06:29] <majd_> Zeros: ok..i'm gonna draw this out
[06:29] <Zeros> when you call getStyle() you just get another MlaCitationCollection majd_, only now it has only the ones of that style in it
[06:29] <Zeros> so you don't need to write 1000 different classes :)
[06:30] * Davey has quit IRC
[06:30] <majd_> ok, let's walk through this step by step, what kind of object is $user?
[06:31] <majd_> so CitationStyle::FOO_STYLE is a contstant which contains all the attributes that are needed
[06:31] <Zeros> you said that each citation is attached to the username right? So $user is a User object that allows you to access citations for that user. Probably created with something like new User( $userid ) where $userid is the unique id assigned to the user in the database
[06:31] <majd_> oh wow, heh that was the next part of my problems
[06:32] <majd_> dude i need to donate some money to you when this thing is out the door
[06:33] <Zeros> I'd make FOO_STYLE be an integer
[06:34] <majd_> Zeros: a bunch of 1's and 0's?
[06:34] <Zeros> just a unique number
[06:34] <majd_> that correlates to a certain style?
[06:35] <Zeros> yes, inside the getStyle() method you'd query the table for that style
[06:35] <majd_> ok, let's see what we got here. This is what i've picked up from the conversation
[06:35] <Zeros> if you were looking for optimization you could do all kinds of dynamic SQL stuff to prevent extra queries, but that's a bit complicated for now.
[06:35] * Davey has joined #web
[06:36] <majd_> User - a class which refers to a user who'se identified by a unique number (id)
[06:36] <Zeros> mmhm
[06:36] <majd_> getMLA() a method of User which returns all the records in the database that are MLA citations made by that user
[06:36] * Hendy has quit IRC (Remote closed the connection)
[06:36] <Zeros> yep
[06:37] <majd_> getStyle(), takes the info returned from getMLA() (which contains a whole lot of nulls), strips the array of values of those nulls, and organizes them into the correct set of info
[06:37] <majd_> getNewestCitation() - returns the last record in the array
[06:38] <majd_> MlaCitationCollection - an object returned by getMLA() which is kind of like an array. It's what i refer to in my description of getStyle()
[06:38] <Zeros> right
[06:38] <Zeros> and getStyle() returns one of them too, it just has fewer things inside it
[06:38] <majd_> right
[06:39] <Zeros> getNewestCitation() would either search based on the date, or provided they were already ordered that way give you the last one
[06:39] <majd_> so MlaC.C. would have an attribute which is an array that holds the data? or how would i hold the data?
[06:40] <majd_> s/i/it
[06:41] <Zeros> well if you wanted to do it all in php it'd probably keep it all in an array
[06:41] <majd_> Zeros: i have to, hosting is php
[06:43] <Zeros> Well no, I mean you could move all that to the database and make it faster
[06:43] <Zeros> Since you're filtering the data inside php now. Here give me a second and I'll mock up something quick for you
[06:43] <majd_> you really dont' have to
[06:44] <murali> how to draw an image using javascript
[06:45] <majd_> Zeros: something I dont' understand, MlaCitationCollection hold information we just got out from the database. Why would it have anything left to do with the database?
[06:50] <Zeros> because grabbing every citation from the database and using php to determine which one we want is rather slow
[06:50] * unix_infidel has quit IRC ("Leaving")
[06:50] <Zeros> Though if you're assuming on 3 or 4 citations you may not care, it's best not to use php to filter data though
[06:51] * unix_infidel has joined #web
[06:53] <majd_> Zeros: ok
[06:53] <majd_> So MlaCitationCollection doesn't actually go though the rows returned and filters out the nulls, it instead points to what values to get when requested
[06:54] <majd_> As you can probably tell by now, I like to repeat everything in my own words to make sure i know what you mean
[06:55] * MetaPhaze has quit IRC (Read error: 110 (Connection timed out))
[06:55] <babo> Anyone here have experience with php5 ? ... I've asked on #php already ...
[06:55] <majd_> babo: what about it?
[06:55] <babo> or just oo in general ...
[06:55] <babo> If I want to set a variable in my constructor, and I don't want that variable to change in any of my objects ... what's the best way ?
[06:56] <babo> s/variable/class variable/
[06:56] <Zeros> majd_, yeah
[06:56] <rixth> Does IE have problems with dynamically generated tables? http://rixth.dyndns.org/feed-grabber-display3.php look in IE and Firefox. http://rixth.dyndns.org/hashweb.html that is a direct copy & paste of the code generated by the javascript. How can I get the table to be all on one line? There are no <tr's> in sight, yet IE seems to be adding one.
[06:57] <majd_> lol rixth you've asked the question 5 times
[06:57] <majd_> i have no idea
[06:57] <majd_> hence my no response
[06:58] <Zeros> rixth, no idea
[07:00] <babo> majd_: any idea ?
[07:02] <rixth> Zeros, thanks, I'll stop posting it for a while
[07:03] <majd_> babo: personally no
[07:03] <majd_> sorry
[07:03] <majd_> facebook is pretty damn awsome
[07:03] <majd_> in pretty much every way
[07:04] * [sellout] has quit IRC (Remote closed the connection)
[07:04] <babo> facebook ?
[07:04] * Lapmann has quit IRC (Read error: 110 (Connection timed out))
[07:05] <babo> majd_: what do you use it for ?
[07:05] <Zeros> majd_, make sense now though?
[07:05] <babo> majd_: are you in college ?
[07:06] <majd_> Zeros: I think so. I'm sure i'll have more questions though when it comes to the nitty gritty
[07:06] <Zeros> :)
[07:06] <majd_> especially with the MlaCitationCollection. It's the one I least foresee the implementation of
[07:08] <majd_> babo: yeah
[07:08] <babo> majd_: shouldn't you be in class :P
[07:08] <babo> ?
[07:08] <majd_> heh no it's 2am
[07:09] <babo> majd_: past your bedtime then ;-)
[07:09] * babo is joking
[07:09] * Madpilot has joined #web
[07:09] <babo> majd_: what are you studying btw ?
[07:10] * GwaiLo_ has joined #web
[07:11] <majd_> computer/electrical
[07:11] <majd_> tbh i think it's a waste of time
[07:11] <majd_> i know i will eventually teach myself everything
[07:11] <majd_> i need to know
[07:12] * p0windah has joined #web
[07:12] * Hagfish2 has quit IRC (Read error: 113 (No route to host))
[07:13] * Ortzinator is now known as Ortz|Away
[07:14] * Gatewayy has joined #web
[07:14] * slide23 has joined #web
[07:15] <majd_> ok Zeros, i'm going to sleep, good night, and thanks sooooooooo much for the help, I will mention you on the site :D