Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. This is a rather tedious debate. Economists won't be agreeing with each other anytime soon. Right. The other side of the fence argues that people tend to get scared during crisis and not spend any money. If people aren't spending any money, people aren't making any money. Prices get raised or else businesses shut down. Now people really won't be spending money. Keeps feeding on itself. So the theory/idea is to throw a bunch of "free" money into the mix. Hope is that since it's "free" people will be inclined to spend it. People spend money, people make money, crisis abated. The overall principle is that a good chunk of the crisis is not necessarily a lack of money, but a lack of buyer/investor confidence, so money is not being spent.
  2. str_word_count returns the same thing as the [a-z]+ regex. As to whether it's more efficient than the regex...not sure about that. It's a pretty simple regex. I can't really imagine how str_word_count's internal regex could get any simpler. I don't really feel like benchmarking it, but I'll buy into str_word_count being 'easier' for people to understand. As far as not using it because of array_count_values: my mistake. I read your code wrong. Nope, I'm afraid that's false. The array expression is only run once. hmm... are you sure about that? I guess I don't see anything in the manual or user notes about it, but I coulda swore I remember seeing a thread here a while back that debated this, with benchmarks and stuff.
  3. Couple things with your code, thebadbad: Would be more efficient to strtolower the original string instead of using array_map. Also, I don't really see the point in using str_word_count when you're already using array_count_values. Also, it's technically more efficient to assign the array slice first, then use the array in the foreach, because if you put it in the loop like that, it performs array_slice every single iteration. My take: $page = file_get_contents($url); // get the page contents $page = strip_tags($page); // remove tags $page = strtolower($page); // make case-insensitive $page = preg_replace('~<script[^>]*>.*?</script>~s','',$page); // remove scripts there may be preg_match_all('~[a-z]+~',$page,$words); // get array of words $words = array_diff($words[0],$commonWords); // filter out common words $words = array_count_values($words); // count occurances arsort($words); // sort highest to lowest $words = array_slice($words,0,5); // get top 5 The only thing still lacking is validating the words as real words. Like for instance, if the page has guess what, that's going to be counted as a word. I suppose you can mostly get around that with some lookaround in the preg_match_all (would be more efficient but less accurate). Better solution would be to compare them against a list of real words.
  4. $input = explode("\n",$input); edit: if this input is a text file you are reading, you can use file
  5. you should be using $keys as first argument in array_diff. And I assume that $commons is a real array of common words instead of $commons = array("alot of words!!") ; right?
  6. make an array of common words you want filtered out, use array_keys to grab the words from array_count_values, and use array_diff
  7. So...what's the question? Seems like you have a solid plan going. Are you asking how to include each piece? include or require
  8. You can use AJAX to call a php script that sets your session variable.
  9. what are you passing to newtext?
  10. The point of it is back in the day when javascript was new enough that there were browsers that didn't know what to do with it, it was a hack to keep js from being displayed as plain text, if the browser didn't support it. So basically it's a backwards compatibility thing. Why people are still doing it I have no idea, as it's been a long time since virtually every single browser out there at least recognizes javascript.
  11. in your foreach loop, instead of echoing the link out, you have to put it into an array. I suggest validating the link before putting it into the array though. For instance, you can check for if the link is "#". Or you can check if it's not a valid link, like if someone is calling a javascript function in the href. You'd also want to decide what to do with relative links; disregard them or try to convert them into absolute urls? You'll also want to check for duplicate urls, and external urls. From there, you will need to basically run the same DOM code on every link in your array. So one way to do that is to wrap it in a function and use some recursion. Note that crawlers can very quickly timeout and max memory limits. So you'll need to setup your script to handle that. You can set a limit on links; tell the script to stop running after X links. Or set the timeout limit to something higher (or remove it) if you have the access. Store the links in a db or flatfile, instead of an array. It will make your script take longer to run, but it's the only way to tradeoff maxing out memory.
  12. array_count_values
  13. okay so they have a difference in hotkeys. Looks like in WMM you can move from frame to frame with the J and L keys. Maybe it would help if you gave a specific example of what you need that WMM doesn't offer. I mean, I know I sound like a salesman, but you did say free and so far I haven't really seen you give a solid example of what WMM doesn't offer for the examples you've given... I guess it's moot since you got adobe premiere to "work."
  14. Would help if you posted what the error is. But anyways, it looks like you're missing a closing bracket for your else.
  15. Do you really have to ask a question like that when someone dumps an entire script on the forum instead of showing relevant code snippets?
  16. Yes it makes a difference. "cleaning up" stuff is exactly the opposite of what you should do when posting regex questions.
  17. Too late, I bid $10mil!
  18. Haha nice. Too bad the feminazis are going to have a field day with that. Wanna start bets on how long it takes to get pulled?
  19. Mostly right. .*? is just some arbitrary pattern. The important part is the parenthesis. Any pattern can be inside the parenthesis. You can even have captures nested inside of captures. The variables $1, $2, $3, etc... populate in order of parenthesis appearance, from left to right.
  20. no, the opposite. (.*?) give $1 its value. (...) are captures. First set of (..) go to $1, 2nd goes to $2, etc...
  21. On the one hand I'd say gd wtf but on the other hand (the more important hand, as it is my jerkoff hand), I have to say to everybody here (and web devs in general) STFU, keep your damn mouth shut and go with it. That's the kind of shit that justifies you charging more than $2.15/hr.
  22. It is a regular expression (regex) pattern. The short story is that it does a case-insensitive, multi-line match and capture everything between [ b ] ... [/ b ] (no spaces) tags (like ubb tags).
  23. No you guys have it all wrong. Going forward, if you qualify for food stamps, tanf, medicaid, etc.. you can file for a new car too!
  24. I felt it somehow conflicted with my mod banner. Not in principle. Like, too much graphicness on the left side of the screen sort of thing.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.