-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Think of it as addition for strings. 8 + 8 = 16 '8' . '8' = 88
-
Again, I'd like to see where you're getting your numbers. javascript is native, built-in to browsers. Flash is a plugin. Without even looking at the numbers it would be logical to put your chips on javascript being more widely enabled.
-
estimated 90% of users have js disabled eh? I'd like to see where you got that number...we use tracking systems like google analytics, yahoo analytics, and omniture's site catalyst with our clients at my job; lots of big name companies that get upwards of a million hits a day. Numbers show us an estimated 2% of users do not have javascript enabled. That metric calculated by number of noscript image requests generated vs. total hits.
-
regex is not really good for that sort of thing. It does not handle nested tags very well. Stick with DOM.
-
I thought that wasn't possible with php? Like, I know you can do forking..sort of..but that's not really the same thing..
-
well something has to execute the script. If it's done through a request, the user will have to wait around until it's done, as it would make the request and wait for a response. Only other way is to get the server to do it independently of the user, which would be by setting up a cronjob.
-
You mostly understood right. okay to be clear: "2009-06-14 17:50" is not a timestamp. It is a string that represents the date, that is readable by humans. As far as php (or computers in general) is concerned, it's just some arbitrary string. Computers keep track of time via timestamps. And a timestamp is that long number, which is the number of seconds since the unix epoch. So if you want to find out the number of minutes between two strings that you interpret as a date/time, you would first convert them into their timestamp equivalent so php can understand it. Then subtract the two. The result would be the difference in seconds. Since you want it to be in minutes, you would then divide by 60, since there are 60 seconds in a minute. So for your example times, you would do this: edit: woops, accidentally hit post instead of preview... example: $dateA = strtotime('2009-06-14 17:00'); $dateB = strtotime('2009-06-14 17:50'); $diff = ($dateB - $dateA) / 60; echo $diff . " minutes difference"; I'd also like to just throw out there that if both of these date/times are in sql, you can have sql perform these operations and just return you the difference. Not really sure about your setup though, so that may not be applicable.
-
[SOLVED] comparing characters, possibly an algorithm?
.josh replied to sw45acp's topic in PHP Coding Help
okay well hold up, as far as suggesting the next best answer, something like levenshtein() should do the trick for you. For some reason in my last post I was still thinking about your OP. similar_text() and levenshtein() are indeed useful for figuring out a "next best answer" sort of thing. Why? Because they return how many "steps" it takes to get from one string to another, so you can loop through each wrong answer, comparing them to the right answer, and the smaller the number returned, the "closer" that string is to the answer. -
which (sub)array/element of $arr your stuff will be in depends on the regex. $arr[0] always contains the full regex match. $arr[1] contains the first full captured match (the regex within parenthesis). $arr[2] would have the matches from the 2nd capture, etc.. Consider the following string: $string = "<a href='blah'>something</a>"; //This will only return $arr[0] and that will contain the whole string. preg_match_all("~<a[^>]*>.*?</a>~",$string,$arr); // $arr[0] : <a href='blah'>something</a> // This will return $arr[0] and $arr[1] preg_match_all("~<a[^>]*>(.*?)</a>~",$string,$arr); // $arr[0] : <a href='blah'>something</a> // $arr[1] : something // This will return $arr[0] and $arr[1] and $arr[2] preg_match_all("~<a href='([^']*)'[^>]*>(.*?)</a>~",$string,$arr); // $arr[0] : <a href='blah'>something</a> // $arr[1] : blah // $arr[2] : something
-
if by now() you mean time(), that's called a unix timestamp. It's a numeric representation of time, in seconds, since the unix epoch. You would convert your time strings into their timestamps and subtract. The result would be in seconds, so you would want to divide by 60 to get minutes.
-
[SOLVED] comparing characters, possibly an algorithm?
.josh replied to sw45acp's topic in PHP Coding Help
No. And neither does levenshtein. What those 2 functions do (in their own ways) is calculate the shortest amount of "moves" or "changes" it takes to get from one string to another. So for instance, if I compared "something" vs. "somethings" : it would take one "move" to make them equal: remove the "s" "something" vs. "osmething" : would return 2 etc.. which mostly seems like the opposite of what he wants, but it is not always the opposite, so you can't even exploit the oppositeness. Not really going to get into the why's of that, as frankly, I do not fully understand the those algorithms, just that in short, as mentioned, they try to calculate the shortest amount of changes it would take to make string1 into string2. Now, if the OP would like to take a different approach to his game or whatever, those 2 functions might indeed be something of interest to him, but again, they can't really be used for what he's asking. -
Uh oh. Sounds like someone didn't get enough of a beating the first time around, and is looking for seconds
-
you can only use server-side scripting (or even client-side scripting, like js) to grab cookies off the same domain, and even then, you can only operate within the scope of the directory for which it is set. For instance, if you set a cookie with a scope of www.site1.com/folder1/ script running from site2 cannot access it, but even www.site1.com/folder1/folder2/script.php cannot access it. which is how it should be. I do not want random sites being able to grab cookies off other sites. Huge security breech.
-
Just for that, I'm going to mention how you're not privy to our epic limerick thread.
-
No longer than 130 characters, right? right? RIGHT?? You automaton.
-
So that's the thanks I get, after you complained about missing out on all those other posts. This actually started behind closed doors, but I moved it here just for you. Bastard.
-
[SOLVED] how to show errors with php that appear on my browser
.josh replied to justAnoob's topic in Javascript Help
but seriously, it's a javascript error(s). That's the message IE gives you on the bottom right of the browser window. If it's an IE specific js error, you can double click on it and hope it's not too vague. But first you should try running it in a real browser, like FF. open up the error console and be amazed. -
I know you're asking an honest question here, but links of that nature are not allowed. They have been removed. Please refrain from posting links to stuff like that. Doesn't matter that there's no material right now. crawlers will index it on our site and it will be indexed when you do have content.
-
[SOLVED] how to show errors with php that appear on my browser
.josh replied to justAnoob's topic in Javascript Help
That means there are javascript errors on the page. And no, it's not okay to start new posts asking the same thing. Stop. I deleted one of your threads, closed the other. If you don't stop, I will end you. -
the error is pretty obvious. you are trying to use a table that doesn't exist. You probably typoed something somewhere. And I don't think it's that line of code you singled out, considering it does not make use of that table.
-
[SOLVED] comparing characters, possibly an algorithm?
.josh replied to sw45acp's topic in PHP Coding Help
function compareWords($word, $guess, $caseSensitive = false) { if ($caseSensitive == false) { $word = strtolower($word); $guess = strtolower($guess); } $c = strlen($word); for ($pos = 0;$pos < $c;$pos++) { if ($word{$pos} === $guess{$pos}) $num++; } return $num; } // end compareWords example use: echo compareWords('something','something'); // output: 9 echo compareWords('Something','something',true); // output: 8 echo compareWords('something','gomthenig'); // output: 3 -
You have to grab the image file and then write a script that will scan the picture and try to pick apart the pixels and determine what the characters are. That is obviously not an easy task to accomplish. Which is the point of captchas.
-
What the fuck is this twitter shit. Yeah, I've seen the sales pitch, listened to the guy on the Oprah&Co shows. I see them hyping it up as a more real-time way to stay in touch with people, because stuff like forums and email are not so, well, real-time. And for some reason, people buy into this bullshit. But I can't but help look at it from the other side of the fence. What the fuck was wrong with instant messaging? They are instant! You know what I think of twitter? I think it's a glorified chatroom. That's what twitter is. A chatroom that caters to cell phone users. How the hell is that impressive? I mean, clearly it is impressive to lots of people, but I'm just not getting it, and I want to know. People have been directly texting their friends long before twitter came around. Sure, people can now follow tweets of random famous people, bands, networks, companies, etc.. but you know what I think of that? I think that's a way to get people to willingly sign up to receive advertisements. That's all that twitter really offers beyond what people have already been doing with texting each other's numbers directly or logging into their IM service on their phones: yet another way for people to shove advertisement down each others' throats. A glorified chatroom where people can spam adverts to each other. You sign up to follow some famous person/network/company's tweet, and you get advertised to. You know, this whole advertisement thing really boggles my mind. Out loud we say we hate ads, but virtually everything we do revolves around them. Which reminds me. I went to the movies a couple weeks ago, saw the new Star Trek movie. I rarely go to the movies, but I had to go see Star Trek. Not because I'm particularly a huge fan; I would by no means call myself a trekkie. Or a going-to-the-movies fan. Truth be told, I'd rather wait until it comes out on dvd and watch it at home. I mean, I have this comfy couch. Big screen TV. Surround sound. $2 worth of popcorn will fill a garbage bag instead of my hand. Get smashed. In short, I get to really get into it without paying a fortune to be cramped in some moldy-stained fold-out lawnchair, fighting to have my arms any which way other than crossed over my chest, just so I don't makeout with the other fat guy sitting next to me. So why do I go to the movies? I make it a policy to go to movies that involve large outdoor scenes. Epic space battles. Giant fields full of thousands of warriors screaming, trying to pummel each other. Whatever. Even if I'm not a big fan of the movie itself. I mean, I can watch a movie just fine on my own tv but come on, scenes that involve outdoors on a massive scale are best seen as big as you can get it. So I'm willing to shoulder rub the left and rights and kick the head of the belows (assuming I can unsticky my feet from the floor...) and brave getting shit dumped on me from the aboves to see that sort of stuff. But only for outdoors type movies, which isn't all that often. So maybe they've been doing this for a while and I'm just now getting around to notice, so pardon my noobness if this is old news, but wtf is up with advertisements before the movie? I'm not talking about previews. I like the previews. Unless the preview just sucks. But that's rating the movie/preview itself. In general, I like previews. How can you not? Previews are always all the good scenes from a movie. I'm talking about blatant fucking advertising. I sat there for like 15 minutes watching standard commercials like I would see on tv. Why the fuck do I go to the movies again? I'm already spending like $10 for a fucking ticket, just to be sardined into a stale popcorn and sweat smelly place, being charged a week's salary for a kid's meal portion snack assortment. And now I'm paying to have people spam their shit on a 50 foot screen? Fuck that noise. It's already depressing how crappy movies are getting these days. Seriously, I have to find increasingly innovative ways to dumb myself down just to tolerate shit anymore. I feel like I'm living a real-life version of mystery science 3000. I just need a couple of robots, and the picture will be complete. Cool robots, though. Not those dumbass robots. Mine would have finger lasers. And they'd actually use them. And not spend an hour being dramatic and building up to it. "Hey man, how's it goi<ZAP>". Sometimes I really fucking hated that show. All the time, actually. The idea was great, don't get me wrong. But too many times they utterly failed to deliver. I swear half the time my friends and I sat around making fun of Joel and his retarded robots, rather than the supposedly stupid movie they were watching. They should have hired me to write it. So what does all this have to do with twitter? Absolutely fucking nothing. I went off on some tangent. Let's get back on track here. I recently read (I shit you not, I actually do read, and also, I really read this), and I quote from memory: "With the advent of twitter, it is for the first time possible for us to conclusively determine in a very scientific way, the legitimacy of ESP". That's short for Extra-Sensory Perception, not Electromagnetically-Shrunken Ponies. I know, I was pretty disappointed too! But hey, I guess this other ESP is a pretty hot topic, too, right? Seriously?? THANK GOD for Twitter. After thousands of years of all of history's most brilliant minds trying to figure this shit out, we now have the means to put this dog to rest. And how is this modern miracle of science possible? These scientists are going to post pictures of scenes around different areas, and people will use twitter's advanced never-before-seen technology to send in their best estimation of what location they are referring to. 1 real pic, 3 look-alikes. You tweet in door #1, door #2, door#3 or door #4. If enough people tweet the right answer, holy shit, ESP must be real! An actual excerpt from some random article I found: I'm sorry..but how the fuck does that count? That sounds more like a memory test to me.. but I guess that's why he's the scientist and I'm the lay-person. And by that I really mean I get laid and he doesn't, because he's a retard wasting my tax dollars on retarded shit. I know what this is really about. Yet another geek trying to figure out the secret to getting inside peoples' heads so they can take the guess-work out of getting inside their pants. Dude, it's not a fucking secret. Read your tweet subscriptions. Any one of them will tell you how. All you have to do is buy their product and it will guarantee some hot chick will be all over your nads. For real. Really real this time.
-
Halo 3 Saved Film HD Recording Service - Testers Needed
.josh replied to HaLo2FrEeEk's topic in Beta Test Your Stuff!
Well stop pasting your function all over the place and it won't be as visible. The more visible you make something, the more it will be scrutinized. You can either be upset that someone tells you it sucks, or you can learn to make it better. Start by asking the person who told you it sucks how they would make it better. If you want to nitpick about respect, be respectful and stop spamming stuff all over the place.