Jump to content

fatkatie

Members
  • Content Count

    115
  • Joined

  • Last visited

Community Reputation

1 Neutral

About fatkatie

  • Rank
    Advanced Member
  1. I have to move to W10 from my beloved W7 box. I found that most software I used on W7 is ported for W10 but I didn't find a free mysql Toad for W10. I really loved that thing. The web based 'workbench' is so clunky. Is there a free toad out there to work with mysql? Please suggest alternatives if you have something you like. (using xampp mysql) Thank you.
  2. It's probably not defined. Test for it first.
  3. fatkatie

    php optimization; 1 or 2 if's

    I just replaced the single line if using the second index array with a single value. It's still slower. $val = 22; while($count_samples--) { //if ($a_true_and_false[$count_samples] && $a_random_int_stuff[$count_samples]) { if ($a_true_and_false[$count_samples] && $val) { $hit_1_count++; } } Done. Out.
  4. fatkatie

    php optimization; 1 or 2 if's

    Finally got around to this question of mine. Using the original parameters of mostly false I ran the following code. There may be many reasons why this test is not valid. I have no advanced knowledge concerning such profiling. I tried to keep the paths equal and to wash out any time glitch issues. It was found that the nested if construct was faster - every time - than the single line short circuit. It's probably due (I'd guess) to the need to access/build the second ALWAYS_CHANGING variable in the if construct. Env: PHP 5.6+ on Win7Pro64, executed as php script in command window. <?php $micro_time_param = true; $number_of_samples = 100000; $frequency_false = 99; $a_true_and_false = array_fill(0, $number_of_samples, false); $number_of_trues = $number_of_samples - intval($number_of_samples * $frequency_false / 100); $a_random_int_stuff = array(); // always true for ($idx = 0; $idx < $number_of_samples; $idx++) { $a_random_int_stuff[$idx] = rand(1, $number_of_samples); } // Scatter the true hits within the array $count_trues = $number_of_trues; while($count_trues--) { $r_index = rand(0, $number_of_samples - 1); $a_true_and_false[$r_index] = true; } $hit_1_count = 0; $hit_2_count = 0; $hit_1_sum = 0.0; $hit_2_sum = 0.0; $hit_1_start = ''; $hit_1_end = ''; $hit_2_start = ''; $hit_2_end = ''; $wash_loop = 1000; $dec_something = $wash_loop; while ($wash_loop--) { // LOOP 1 $count_samples = $number_of_samples; $hit_1_start = microtime($micro_time_param); while($count_samples--) { if ($a_true_and_false[$count_samples] && $a_random_int_stuff[$count_samples]) { $hit_1_count++; } } $hit_1_end = microtime($micro_time_param); $hit_1_sum += (float)($hit_1_end - $hit_1_start); // LOOP 2 $dec_something--; $count_samples = $number_of_samples; $hit_2_start = microtime($micro_time_param); while($count_samples--) { if ($a_true_and_false[$count_samples]) { if ($a_random_int_stuff[$count_samples]) { $hit_2_count++; } } } $hit_2_end = microtime($micro_time_param); $hit_2_sum += (float)($hit_2_end - $hit_2_start); } echo "Time hit 1 $hit_1_sum , hit count $hit_1_count\n"; echo "Time hit 2 $hit_2_sum , hit count $hit_2_count\n";
  5. fatkatie

    php optimization; 1 or 2 if's

    barand - I think what I want is getrusage - wall clock time v/s cpu time. https://stackoverflow.com/questions/535020/tracking-the-script-execution-time-in-php
  6. fatkatie

    301 Redirect Regex

    I'm not trying to undermine gizmola here. It's a fine answer. But since the topic of recognizing a name showed up, here's an interesting post: in_array vs strpos for performance in php. It concerns the fastest way to find that needle (within some constraints). https://stackoverflow.com/questions/21070691/in-array-vs-strpos-for-performance-in-php#21070786 If posting links are not welcome here, administrator, feel free to nuke the post. Thanks.
  7. fatkatie

    php optimization; 1 or 2 if's

    barand - yah, I think you're correct. Timing the loop may be the best way. There are just too many things going on. I imagine the second assignment might change according to optimization rules - of which I have no clue. I'll try a few later. My bet? These will run at different speeds. We'll see. But ... Will microtime return the time spent actually executing? What if there is a process swap? For others, I should have stated the changing value was an integer. I've always wondered about the word 'redundant' as it relates to verbose. (Does RTFM mean what I think it does? ) Thanks again.
  8. This is simple curiosity. I'd like to know if someone really knows the answer. I've always been suspicious of performance testing with loops. I have a loop in php. Within that loop I act based on two values, let's call them MOSTLY_FALSE and ALWAYS_CHANGING. Given MOSTLY_FALSE is seldom true, is the second "double" IF faster than the 'single', or will the short-circuit take care of it? I sometimes code with the double form just to let people know that truth is exceptional. Thanks. (Just curious.) if ( MOSTLY_FALSE == true && ALWAYS_CHANGING == 1) { // do this exceptional thing } if ( MOSTLY_FALSE == true) { // access ALWAYS_CHANGING for the first time (is a field returned in sql query if (ALWAYS_CHANGING == 1) { // do this exceptional thing } }
  9. fatkatie

    when a text line wraps; is there an event?

    navbar breakpoint stuff. I have 'linear' lists, as menu items, that vary in length, and if they wrap before the nav 'breaks' the contents leak. I guess I can mess about dynamically with it's breakpoint setting. Was just wondering if I could do it myself. Thanks.
  10. As the browser is made smaller, or the text larger, and a text line no longer can be placed on a single line, is there an event that signals the browser to wrap it? Is this an event which can be used? Say the text line was contained within a div element. Could I recognize a 'wrap' event, if there is one, for text within that div element? Thank you.
  11. fatkatie

    securing file uploads from a form

    My reaction. Here's one: https://stackoverflow.com/questions/4814040/allowed-characters-in-filename I saw the null discussion elsewhere... can't locate it now.
  12. fatkatie

    securing file uploads from a form

    I saw a post somewhere where they said to check for null in the file name. Null? Your stuff looks good. Thanks.
  13. I think I have this covered but want some feedback. When I receive a file I secure it by checking these values in $_FILES name: must be a valid filesystem file name (if I'm going to use it). I never did find a library out there that would validate filesystem parameters (names, paths). I just use a regular expression to look for things I know are illegal. name: length must not exceed filesystem limit plus path size: check for zero and max size type: validate against a list of allowed types (Wondering if someone could subvert the type here and cause trouble. Is there way to look inside a file and verify 'type'?) tmp_name: nothing to check error: should be zero Got it all? Thank you.
  14. fatkatie

    post form data (textarea) as file

    YES! It's so simple.... "I thought you'd say that Dr. Watson" var big = jQuery('#idta_big').val(); var blob = new Blob ([big], { type: "text/plain" }); var fd = new FormData(); fd.append("bigstuff", blob); jQuery.ajax({ url : 'ajax_big_save.php.php', method : 'POST', data : fd }); THANK YOU! (Stuff was in the $_FILES array.)
  15. fatkatie

    post form data (textarea) as file

    Originally I failed to define the enctype, but per the other post's suggestion I included it. Still failed. Here's the code. (I thought multipart is the default. Is that correct?) <form id='idf_big' method="post" enctype="multipart/form-data"> <textarea name="nta_big" id="idta_big" rows="10" cols="80"> This is my textarea </textarea> <input type='submit' id='ids_big' value='Go'> </form> <script> jQuery(document).ready(function() { $( "#idf_big" ).submit(function( event ) { event.preventDefault(); var str = jQuery('#idf_big').serialize(); var sos = str.length; alert("length of serialized data is: " + sos); var ph = jQuery.post('ajax_big_save.php', str); ...
×

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.