Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by requinix

  1. Does your sql_mode setting include ANSI or ANSI_QUOTES? SELECT @@GLOBAL.sql_mode; SELECT @@SESSION.sql_mode;
  2. It's (cough) possible I saw the number 86400, thought "oh I recognize that", and went straight into the DST explanation. Which is wrong for two reasons: that number is for a day not an hour, and because we're dealing with UTC here. But what I was right about was the apparent vs. elapsed issue. Look at the dates - just the dates: 2017-06-26 => 2017-07-09 = 4 days of June + 9 days of July = 13 days 2018-03-05 => 2018-03-18 = 13 days Good 2017-12-08 => 2018-02-15 = 24 days of December + 31 days of January + 15 days of February = 69 days 2018-03-05 => 2018-05-12 = 27 days of March + 30 days of April + 12 days of May = 69 days Good But that's elapsed time and diff deals with apparent time. And apparently, 2017-06-26 => 2017-07-09 = 0 months + 13 days (overflowing after 30) = 13 days 2018-03-05 => 2018-03-18 = 0 months + 13 days = 13 days Same 2017-12-08 => 2018-02-15 = 2 months (December with 31 days, January with 31 days) + 7 days = 69 days 2018-03-05 => 2018-05-12 = 2 months (March with 31 days, April with 30 days) + 7 days = 68 days Oh no The results are even more off when you have to deal with February and its mere 28 days. It's weird, but that's what you get when you try to do date math. And unfortunately there's no simple moral to this story: sometimes a diff-ed DateInterval is appropriate (tends to look nicer across DST boundaries), sometimes a diff-ed timestamp is appropriate (tends to work more like what you'd want), and using the wrong one will screw you up.
  3. If I remember correctly, ->diff measures the apparent difference between dates. Like the difference between 00:00 and 05:00 is apparently five hours. But timestamps are a measure of elapsed time. 00:00 to 05:00 could be five hours, or it could be four or six if it crosses a DST boundary.
  4. Odd. The forum editor shows no description for any of those, so it's not like some backfill process set those automatically. At least not in that way. Anyway, saving with an empty description seems to have fixed them.
  5. The mod_rewrite docs list a number of flags that can be passed to RewriteRule. Like typically you should be using [L]ast to stop further rule processing, but it's not always required. In your case you would want [QSA] - query string append. Because normally if you set your own query string in the replacement URL then mod_rewrite won't carry over any that were in the original source. But if someone puts a ?page= or ?id= in the original URL, as in /story/33?page=1, then that will overwrite the one you're setting through the replacement. So I would avoid [QSA] in general and instead make use of the fact that PHP only cares about the last value: RewriteRule ^(.*?)/(.*?)/?$ view.php?%{QUERY_STRING}&page=$1&id=$2
  6. Well that doesn't sound good. If you want your code to change then you'll have to try something. Why are you going to Google when PHP has perfectly good documentation online? Find out what FRENCH_COLLATION actually means and decide what to do with it. That's nice but it doesn't help you find out what you have to do with your PHP code.
  7. What have you tried? It's not like the code is particularly cryptic...
  8. You're right, it was deprecated in 5.3 and removed in 5.4. OP probably had warnings hidden.
  9. Fixed. I've also noticed that some of the CSS uses hardcoded colors so it doesn't properly fit into the theming system (which allows for overriding them through a UI). I didn't change too many from the defaults so this probably shouldn't be much of an issue, but it may explain some inconsistencies. Or it may end up looking better. Hard to say.
  10. Where? The page background should be a darker blue, the background for forum groups slightly lighter, and the headers even more. Fixed.
  11. Because we're programmers. To switch to it, apparently there isn't a page I can link for you to visit, but there is a Theme selector at the bottom of probably every page. Based on Dark Theme. If you have suggestions about colors to change, reply here.
  12. The official docs. It's not like these are particularly complicated. Go for Serializable and serialize/unserialize. They work with serialized strings, so there's more work than with __sleep's array, but the principle is the same: serialize all the data you need plus the information needed to recreate the connection (and not the connection itself), then you recreate the connection when unserializing.
  13. To add to that, only put variables into (double-quoted) strings if you want a string and it's going to be more than just the contents of that variable. Like writing "$foo" is making it unnecessarily complicated - just $foo is enough. Meanwhile "abc $foo xyz" makes sense because you've got the "abc" and "xyz" bits in there too. unless you want to cast the variable to a string, which "$foo" would do and $foo would not, but if that's the case then you should cast it like (string)$foo instead
  14. You cannot serialize (which is what you need to do) resources like database connections. Which is why methods like __sleep/wakeup and serialize/unserialize exist: for you to customize the behavior before, during, and after the serialization process. So you could serialize the information needed to restore a connection once the object unserializes.
  15. Don't just copy and paste stuff people give you. Understand what the command is actually doing, then you should be in a better shape to know if it needs changes and what they are.
  16. Your code. Not Laravel. Because the problem is going to be with your code, not theirs.
  17. Look at the backtrace to find what part of your code is running. Look for problems there. If you can't find the problem, post the code for the method.
  18. Do you know what /.../g does? Also I didn't point out that .test() is on the RegExp, not the string. Look more carefully at his code. And .test is the appropriate function to use. Because it tests for a match. Which is exactly what you want to do.
  19. Besides the use of .test(), note the ^ $ in Barand's pattern. Those are required to make sure the regex tests the entire value from beginning to end: without, it only tests if the value contains something matching the pattern.
  20. As I recall slash can find in my email archive (~summer 2017 was when the discussion first started), ==> was the preferred syntax for a while because Hack uses it, however PHP couldn't implement closures in the same way Hack does (IIRC) so this would break compatibility with HHVM. Plus there would be difficulties in coercing the parser into reading it. And there was a bit of "let's please not establish a precedence of copying Hack". So it couldn't work. => was proposed early but was initially rejected because it would conflict with arrays. Similarly -> would conflict with objects. Another option was ~> but too many people thought it looked weird, and apparently it too had some parser problems. Ruby's |x| form didn't last long in the conversation either. \()=> came up for a while but enough people objected to Yet Another Backslash. And there were other assorted arrangements of symbols - braces, brackets, pipes, you name it. But => did win out once people realized that the ambiguity problem could be resolved by using it as keyword()=>. So then the question was what keyword. "function" already exists but was too long for something that's supposed to be short and easy to type. "lambda" was another but was maybe sounded too technical. "fn" finally won as being short and concise. Whether fn()==> could also have worked, I don't know...
  21. Emphasis on "think". The nicest thing arrow functions have to offer is implicit variable binding. $a = 1; $add = fn($b) => $a + $b; // function($b) use ($a) { return $a + $b; } echo $add(2); // 3 The bad thing is that the binding is strictly by-value. As in a regular use() and by a by-ref use(&). Which means it's very much not like how Javascript works (which goes by scope, not bindings). $a = 2; echo $add(2); // 3 because $add still thinks $a=1 var a = 1; var add = (b) => a + b; console.log(add(2)); // 3 a = 2; console.log(add(2)); // 4
  22. If they have an API that does what you need then that's going to be the best way to go. Even if it's not the greatest. Because scraping stuff correctly and accurately is difficult. Disable your antivirus's web scanning part and (carefully) try viewing the docs again?
  23. array_reduce is a great function for this. Quite rare to see it in the real world, which means bonus points for actually using it. $numbers = array(1, 3, 7, 8, 10, 13); // assuming there is at least one even number >= 0 $max = array_reduce($numbers, function($max, $n) { return ($n % 2) == 0 && $n > $max ? $n : $max; }, 0); Or with PHP 7.4's arrow functions, $max = array_reduce($numbers, fn($max, $n) => ($n % 2) == 0 && $n > $max ? $n : $max, 0);
  24. requinix

    stuck block

    If you want a simple animation like to move to the top and bottom every 2 seconds then CSS's animations can do it better.
  25. Ohh, okay, that's what you meant. Can you upload a sample of what it produces?
  • 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.