Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32
  1. #21
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    Quote Originally Posted by Source View Post
    The issue comes down to the HxF community Caleb. People are extremely narrow minded and often mention about their client work in some attempt to *seem* professional.

    My personal stance is that whether it is personal, or 'client' work you should always roll out the best possible code. Otherwise you get in to bad habits, look over things and start doing a generally poor job. It comes back down to 'regex wouldn't have taken that much longer than explode in this situation'.

    It's a very bizarre stance one does have.
    I'm not attempting to sound professional, or gain respect for anything, I don't need respect, approval or belief from anyone on this forum. The way I code is the way I code, sorry that my style differs from your obviously perfect style, but that's just the way it is! I know how to code properly when I need to and I always code properly and efficiently when commissioned. When coding for myself, for a non-public website, I cut corners to save time, simply because coding bores me.

    I'm not narrow minded at all. I can accept that others have different style, as I have mine. The fact that we are now 20 posts into a thread, most of them critisizing my personal style of coding, suggests that others are narrow minded.

    Quite simply, get over the fact that I do something differently to you.
    we're smiling but we're close to tears, even after all these years

  2. #22
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    I'm not being at all narrow minded. It's a simple based point of view I have, that people who are trying to learn languages should be taught the correct way and not some half-assed bodge job by some lazy ignorant user.

    Your style, is your style. He asked for the best way to get his log reading done, and regex is the best way to achieve that.

  3. #23
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    Quote Originally Posted by Source View Post
    I'm not being at all narrow minded. It's a simple based point of view I have, that people who are trying to learn languages should be taught the correct way and not some half-assed bodge job by some lazy ignorant user.

    Your style, is your style. He asked for the best way to get his log reading done, and regex is the best way to achieve that.
    He actually asked how he could explode it, I answered that.

    Ignorant because I do something differently to you? My style is my style? Hm.
    we're smiling but we're close to tears, even after all these years

  4. #24
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    A little benchmarking...

    PHP Code:
    <?php
    $start 
    microtime(true);

    for(
    $i=0;$i<10000;$i++){ // Use explode on the string ten thousand times
        
    $string="2010.5.28 15:08:28 - 10.0.0.13 http://en.wikipedia.org/w/opensearch_desc.php *EXCEPTION* Exception site match. GET 884 0  1 200 - room4-1.domain.example";
        
    $bits=explode(" ",$string);
    }
    $stop microtime(true);

    echo 
    "Time: ".($stop-$start)." seconds"
    ?>
    On a typical shared webhost, Time: 0.0379159450531 seconds

    We're talking micro-optimisation here, personally I too wouldn't bother (unless you have 300k+ lines), you don't look at a log very often.
    Last edited by Apolva; 08-06-2010 at 04:42 PM.

  5. #25
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    Quote Originally Posted by Apolva View Post
    A little benchmarking...

    PHP Code:
    <?php
    $start 
    microtime(true);

    for(
    $i=0;$i<10000;$i++){ // Use explode on the string ten thousand times
        
    $string="2010.5.28 15:08:28 - 10.0.0.13 http://en.wikipedia.org/w/opensearch_desc.php *EXCEPTION* Exception site match. GET 884 0  1 200 - room4-1.domain.example";
        
    $bits=explode(" ",$string);
    }
    $stop microtime(true);

    echo 
    "Time: ".($stop-$start)." seconds"
    ?>
    On a typical shared webhost, Time: 0.0379159450531 seconds

    We're talking micro-optimisation here, personally I too wouldn't bother (unless you have 300k+ lines), you don't look at a log very often.
    Haha. +rep if I can.
    we're smiling but we're close to tears, even after all these years

  6. #26
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    We're not on about speed here. We're on about the most low maintenance way to perform the task. Regex fullfils that.
    Last edited by Source; 08-06-2010 at 04:59 PM. Reason: Changed wording.

  7. #27
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    Quote Originally Posted by Source View Post
    We're not on about speed here. We're on about the most reliable way to perform the task. Regex fullfils that.
    Please explain how regex is more reliable than explode?
    we're smiling but we're close to tears, even after all these years

  8. #28
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    The same way Dentafrice has mentioned already.

    If the string/pattern you are trying to match changes, changing the regex pattern is *a lot* simpler then having to go through working out what segments are what.

    Edit: People are skewing what I am trying to explain. There is nothing wrong with using explode, beyond the fact it's not the best way to achieve the result. I believe people who are asking for help should be informed correctly.
    Last edited by Source; 08-06-2010 at 04:59 PM. Reason: Removed reliability line.

  9. #29
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    The likelihood of the data changing half way through your sample is extremely low, I don't really take that as a reason for choosing regex over explode for a personal project. Try to use the right words next time, might help your argument.
    we're smiling but we're close to tears, even after all these years

  10. #30
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    It's a completely valid argument.

    Logs formats can easily change. Take the nginx log I have in front of me. It's 364,412 lines long and the format has recently changed as I installed the latest version a few months ago.

    Apache2 logs could but don't change. Handling a 132mb file with explode would be a rediculous solution. However saying that, handling a file like that in PHP would be a stupid solution.

    If I was to handle the viewing of that log with PHP, then changing the pattern would have been so much easier than re working the use of explode segments.

    I don't, but it's a hypothetical situation.
    Last edited by Source; 08-06-2010 at 05:01 PM.

Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •